From 8d62b0c57ede4d84296f1b564b8eb16a8aa41ca0 Mon Sep 17 00:00:00 2001 From: Terence Boldt Date: Wed, 23 Dec 2020 22:53:20 -0500 Subject: [PATCH] Partial fix for command execution --- Apple2/driver_assemble.sh | 16 ++++++++-------- RaspberryPi/Driver.go | 23 +++++++++++++++++------ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Apple2/driver_assemble.sh b/Apple2/driver_assemble.sh index d0ca23f..d2c46b2 100755 --- a/Apple2/driver_assemble.sh +++ b/Apple2/driver_assemble.sh @@ -1,12 +1,12 @@ #!/bin/sh ca65 Driver.asm --listing Driver.lst ld65 Driver.o -o Driver.bin -t none -ca65 Firmware.asm -D STARTSLOT=\$c000 -o Slot0.o -ca65 Firmware.asm -D STARTSLOT=\$c100 -o Slot1.o -ca65 Firmware.asm -D STARTSLOT=\$c200 -o Slot2.o -ca65 Firmware.asm -D STARTSLOT=\$c300 -o Slot3.o -ca65 Firmware.asm -D STARTSLOT=\$c400 -o Slot4.o -ca65 Firmware.asm -D STARTSLOT=\$c500 -o Slot5.o -ca65 Firmware.asm -D STARTSLOT=\$c600 -o Slot6.o -ca65 Firmware.asm -D STARTSLOT=\$c700 -o Slot7.o +ca65 Firmware.asm -D STARTSLOT=\$c000 -o Slot0.o +ca65 Firmware.asm -D STARTSLOT=\$c100 -o Slot1.o --listing Firmware1.lst +ca65 Firmware.asm -D STARTSLOT=\$c200 -o Slot2.o --listing Firmware2.lst +ca65 Firmware.asm -D STARTSLOT=\$c300 -o Slot3.o --listing Firmware3.lst +ca65 Firmware.asm -D STARTSLOT=\$c400 -o Slot4.o --listing Firmware4.lst +ca65 Firmware.asm -D STARTSLOT=\$c500 -o Slot5.o --listing Firmware5.lst +ca65 Firmware.asm -D STARTSLOT=\$c600 -o Slot6.o --listing Firmware6.lst +ca65 Firmware.asm -D STARTSLOT=\$c700 -o Slot7.o --listing Firmware7.lst ld65 Slot0.o Slot1.o Slot2.o Slot3.o Slot4.o Slot5.o Slot6.o Slot7.o -o Firmware.bin -t none diff --git a/RaspberryPi/Driver.go b/RaspberryPi/Driver.go index 32c1eb5..e351877 100644 --- a/RaspberryPi/Driver.go +++ b/RaspberryPi/Driver.go @@ -113,13 +113,22 @@ func handleWriteBlockCommand(file *os.File) { } func handleExecCommand() { + fmt.Printf("Reading command to execute...\n") linuxCommand,err := readString() + fmt.Printf("Command to run: %s\n", linuxCommand) cmd := exec.Command("bash", "-c", linuxCommand) cmdOut, err := cmd.Output() if err != nil { fmt.Printf("Failed to execute command\n") + writeString("Failed to execute command") + return + } + fmt.Printf("Command output: %s\n", cmdOut) + err = writeString(string(cmdOut)) + if err != nil { + fmt.Printf("Failed to send command output\n") + return } - writeString(cmdOut) } func handleGetTimeCommand() { @@ -210,10 +219,10 @@ func dumpBlock(buffer []byte) { } func readString() (string, error) { - inByte := byte(0) + inByte := byte(255) var inBytes bytes.Buffer var err error - for inByte == 0 { + for inByte != 0 { inByte,err = readByte() if err != nil { return "", err @@ -223,10 +232,12 @@ func readString() (string, error) { return string(inBytes.Bytes()), nil } -func writeString(outBytes []byte) error { - for outByte := range outBytes { - err := writeByte(byte(outByte)) +func writeString(outString string) error { + for _, character := range outString { + fmt.Printf("Out: %s\n", character); + err := writeByte(byte(character)|128) if err != nil { + fmt.Printf("Failed to write string\n") return err } }