Cleanup project

This commit is contained in:
Terence Boldt 2021-03-20 19:25:28 -04:00
parent a789b921c3
commit 89c8256bbb
4 changed files with 10 additions and 77 deletions

View File

@ -67,7 +67,6 @@ func main() {
os.Exit(1)
}
for {
if debug {
fmt.Printf("Check for command\n")
@ -129,7 +128,7 @@ func handleWriteBlockCommand(file *os.File) {
func handleExecCommand() {
fmt.Printf("Reading command to execute...\n")
linuxCommand,err := readString()
linuxCommand, err := readString()
fmt.Printf("Command to run: %s\n", linuxCommand)
cmd := exec.Command("bash", "-c", linuxCommand)
cmdOut, err := cmd.Output()
@ -259,7 +258,7 @@ func dumpBlock(buffer []byte) {
func readString() (string, error) {
var inBytes bytes.Buffer
for {
inByte,err := readByte()
inByte, err := readByte()
if err != nil {
return "", err
}
@ -273,7 +272,7 @@ func readString() (string, error) {
func writeString(outString string) error {
for _, character := range outString {
err := writeByte(byte(character)|128)
err := writeByte(byte(character) | 128)
if err != nil {
fmt.Printf("Failed to write string\n")
return err
@ -283,7 +282,6 @@ func writeString(outString string) error {
return nil
}
func readByte() (byte, error) {
// let the Apple II know we are ready to read
if debug {

5
RaspberryPi/go.mod Normal file
View File

@ -0,0 +1,5 @@
module github.com/tjboldt/Apple2-IO-RPi
go 1.16
require periph.io/x/periph v3.6.7+incompatible

2
RaspberryPi/go.sum Normal file
View File

@ -0,0 +1,2 @@
periph.io/x/periph v3.6.7+incompatible h1:ZfRdHbcxVekgSJZmxp3873YpxNdWs6wg7waDCF7GB18=
periph.io/x/periph v3.6.7+incompatible/go.mod h1:EWr+FCIU2dBWz5/wSWeiIUJTriYv9v2j2ENBmgYyy7Y=

View File

@ -1,72 +0,0 @@
package main
import (
"time"
"periph.io/x/periph/conn/gpio"
"periph.io/x/periph/conn/gpio/gpioreg"
"periph.io/x/periph/host"
"fmt"
)
func main() {
host.Init()
startTime := time.Now()
out_write := gpioreg.ByName("GPIO5")
out_read := gpioreg.ByName("GPIO11")
out_command1 := gpioreg.ByName("GPIO9")
out_command2 := gpioreg.ByName("GPIO10")
out_bit3 := gpioreg.ByName("GPIO22")
out_bit2 := gpioreg.ByName("GPIO27")
out_bit1 := gpioreg.ByName("GPIO17")
out_bit0 := gpioreg.ByName("GPIO4")
in_read := gpioreg.ByName("GPIO16")
out_command1.Out(gpio.Low)
out_command2.Out(gpio.Low)
out_read.Out(gpio.High)
out_write.Out(gpio.High)
for i := 0; i < 4096; i++ {
bit3 := gpio.Low
bit2 := gpio.Low
bit1 := gpio.Low
bit0 := gpio.Low
if ((i & 8) >> 3) == 1 {
bit3 = gpio.High
}
out_bit3.Out(bit3)
if ((i & 4) >> 2) == 1 {
bit2 = gpio.High
}
out_bit2.Out(bit2)
if ((i & 2) >> 1) == 1 {
bit1 = gpio.High
}
out_bit1.Out(bit1)
if (i & 1) == 1 {
bit0 = gpio.High
}
out_bit0.Out(bit0)
out_write.Out(gpio.Low)
for in_read.Read() == gpio.Low {
in_read.WaitForEdge(-1)
}
out_write.Out(gpio.High)
for in_read.Read() == gpio.High {
in_read.WaitForEdge(-1)
}
}
elapsedTime := time.Since(startTime)
fmt.Printf("Sent 2 KiB in %s", elapsedTime)
}