Fix RPi ZW2 data errors + improve speed on ZW1 (#35)

This commit is contained in:
Terence Boldt 2021-11-05 21:26:48 -04:00 committed by GitHub
parent 5f365e01a6
commit b01d5f3fd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -131,8 +131,9 @@ func (a2 A2Gpio) ReadByte() (byte, error) {
outRead.Out(gpio.Low) outRead.Out(gpio.Low)
// wait for the Apple II to write // wait for the Apple II to write
startTime := time.Now()
for inWrite.Read() == gpio.High { for inWrite.Read() == gpio.High {
if !inWrite.WaitForEdge(edgeTimeout) { if time.Since(startTime) > edgeTimeout {
outRead.Out(gpio.High) outRead.Out(gpio.High)
return 0, errors.New("timed out reading byte -- write stuck high") return 0, errors.New("timed out reading byte -- write stuck high")
} }
@ -181,8 +182,9 @@ func (a2 A2Gpio) ReadByte() (byte, error) {
// wait for the Apple II to finish writing // wait for the Apple II to finish writing
//fmt.Printf("wait for the Apple II to finish writing\n") //fmt.Printf("wait for the Apple II to finish writing\n")
startTime = time.Now()
for inWrite.Read() == gpio.Low { for inWrite.Read() == gpio.Low {
if !inWrite.WaitForEdge(edgeTimeout) { if time.Since(startTime) > edgeTimeout {
return 0, errors.New("timed out reading byte -- write stuck low") return 0, errors.New("timed out reading byte -- write stuck low")
} }
} }
@ -199,8 +201,9 @@ func (a2 A2Gpio) WriteByte(data byte) error {
} }
// wait for the Apple II to be ready to read // wait for the Apple II to be ready to read
startTime := time.Now()
for inRead.Read() == gpio.High { for inRead.Read() == gpio.High {
if !inRead.WaitForEdge(edgeTimeout) { if time.Since(startTime) > edgeTimeout {
outWrite.Out(gpio.High) outWrite.Out(gpio.High)
return errors.New("timed out writing byte -- read stuck high") return errors.New("timed out writing byte -- read stuck high")
} }
@ -260,8 +263,9 @@ func (a2 A2Gpio) WriteByte(data byte) error {
// wait for the Apple II to finsih reading // wait for the Apple II to finsih reading
//fmt.Printf("wait for the Apple II to finsih reading\n") //fmt.Printf("wait for the Apple II to finsih reading\n")
startTime = time.Now()
for inRead.Read() == gpio.Low { for inRead.Read() == gpio.Low {
if !inRead.WaitForEdge(edgeTimeout) { if time.Since(startTime) > edgeTimeout {
outWrite.Out(gpio.High) outWrite.Out(gpio.High)
return errors.New("timed out writing byte -- read stuck low") return errors.New("timed out writing byte -- read stuck low")
} }