Partial fix for command execution

This commit is contained in:
Terence Boldt 2020-12-23 22:53:20 -05:00
parent 3176e6112e
commit 8d62b0c57e
2 changed files with 25 additions and 14 deletions

View File

@ -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

View File

@ -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
}
}