REWIND command for serial device

This commit is contained in:
minjaesong
2025-10-07 23:43:24 +09:00
parent 769b6481da
commit f918cd429c
3 changed files with 60 additions and 1 deletions

View File

@@ -395,6 +395,27 @@ class TestDiskDrive(private val vm: VM, private val driveNum: Int, theRootPath:
fileOpenMode = -1
statusCode.set(STATE_CODE_STANDBY)
}
else if (inputString.startsWith("REWIND")) {
// Rewind the stream to beginning for seeking
if (readStreamActive && file.isFile) {
try {
closeReadStream()
// Reopen the file at position 0
readInputStream = FileInputStream(file)
readStreamActive = true
readFileSize = file.length()
blockSendCount = 0
statusCode.set(STATE_CODE_STANDBY)
}
catch (e: IOException) {
closeReadStream()
statusCode.set(STATE_CODE_SYSTEM_IO_ERROR)
}
}
else {
statusCode.set(STATE_CODE_NO_FILE_OPENED)
}
}
else if (inputString.startsWith("READ")) {
//readModeLength = inputString.substring(4 until inputString.length).toInt()