diff --git a/RaspberryPi/Apple2-IO-RPi.hdv b/RaspberryPi/Apple2-IO-RPi.hdv index ff56d0c..e0db749 100755 Binary files a/RaspberryPi/Apple2-IO-RPi.hdv and b/RaspberryPi/Apple2-IO-RPi.hdv differ diff --git a/RaspberryPi/Driver.go b/RaspberryPi/Driver.go index 222660c..0b5ba98 100644 --- a/RaspberryPi/Driver.go +++ b/RaspberryPi/Driver.go @@ -89,6 +89,8 @@ func main() { handleGetTimeCommand() case ExecCommand: handleExecCommand() + case LoadFileCommand: + handleLoadFileCommand() } } } @@ -144,6 +146,12 @@ func handleExecCommand() { writeString("Working directory set") return } + if linuxCommand == "a2help" { + writeString("This is a pseudo shell. Each command is executed as a process. The cd command is\n" + + "intercepted and sets the working directory for the next command. Running\n" + + "commands that do not exit will hang. For example, do not use ping without a -c 1\n" + + "or something else to limit its output.\n") + } cmd := exec.Command("bash", "-c", linuxCommand) cmd.Dir = workingDirectory cmdOut, err := cmd.Output() @@ -197,6 +205,42 @@ func handleGetTimeCommand() { fmt.Printf("Send time complete\n") } +func handleLoadFileCommand() { + fileName, _ := readString() + + file, err := os.OpenFile(fileName, os.O_RDWR, 0755) + if err != nil { + fmt.Printf("ERROR: %s\n", err.Error()) + writeByte(0) + writeByte(0) + return + } + + fileInfo, _ := file.Stat() + fileSize := int(fileInfo.Size()) + + fmt.Printf("FileSize: %d\n", fileSize) + + fileSizeHigh := byte(fileSize >> 8) + fileSizeLow := byte(fileSize & 255) + + writeByte(fileSizeLow) + writeByte(fileSizeHigh) + + buffer := make([]byte, fileSize) + + fmt.Printf("Read file %s SizeHigh: %d SizeLow: %d\n", fileName, fileSizeHigh, fileSizeLow) + + file.Read(buffer) + + for i := 0; i < fileSize; i++ { + err := writeByte(buffer[i]) + if err != nil { + return + } + } +} + func readBlock(buffer []byte) error { for i := 0; i < 512; i++ { err := writeByte(buffer[i])