Add user input for interactive development testing

This commit is contained in:
Terence Boldt 2021-10-30 09:50:00 -04:00
parent 9604c465da
commit 84479fdb01
11 changed files with 129 additions and 0 deletions

View File

@ -1,3 +1,10 @@
// Copyright Terence J. Boldt (c)2021
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
// This file defines the interface for communicating with the Apple II via
// the Raspberry Pi GPIO ports but can also be mocked out for tests or
// passed input to the user for interactive testing
package a2io
type A2Io interface {

View File

@ -1,3 +1,9 @@
// Copyright Terence J. Boldt (c)2020-2021
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
// This file is used for communicating with the Apple II data bus via the
// GPIO ports on the Raspberry Pi
package a2io
import (

View File

@ -1,3 +1,9 @@
// Copyright Terence J. Boldt (c)2021
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
// This file is used for mocking the GPIO code so that unit tests can be run
// on any machine and not just a Raspberry Pi
package a2io
import (

View File

@ -0,0 +1,69 @@
// Copyright Terence J. Boldt (c)2021
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
// This file is only used during development for interactive testing of the
// driver code. Simply replace `comm := a2io.A2Gpio{}` with
// `comm := a2io.UserIo{}` in the driver.go file to allow local testing
package a2io
import (
"errors"
"fmt"
"strings"
)
type UserIo struct {
}
func (userIo UserIo) Init() {
}
func (userIo UserIo) WriteByte(data byte) error {
fmt.Printf("WriteByte: %02X\n", data)
return nil
}
func (userIo UserIo) WriteString(outString string) error {
fmt.Printf("WriteString: %s\n", strings.ReplaceAll(outString, "\r", "\n"))
return nil
}
func (userIo UserIo) WriteBlock(buffer []byte) error {
fmt.Printf("WriteBlock:\n")
return userIo.WriteBuffer(buffer)
}
func (userIo UserIo) WriteBuffer(buffer []byte) error {
fmt.Printf("WriteBuffer:\n")
for i, b := range buffer {
if i%16 == 0 {
fmt.Printf("\n%04X:", i)
}
fmt.Printf(" %02X", b)
}
fmt.Printf("\n")
return nil
}
func (userIo UserIo) ReadByte() (byte, error) {
fmt.Printf("ReadByte: ")
var b byte
fmt.Scanf("%x", &b)
fmt.Printf("\n")
return b, nil
}
func (userIo UserIo) ReadString() (string, error) {
fmt.Printf("ReadString: ")
var s string
fmt.Scanf("%s", &s)
fmt.Printf("\n")
return s, nil
}
func (userIo UserIo) ReadBlock(buffer []byte) error {
fmt.Printf("ReadBlock: (Not supported)")
return errors.New("ReadBlock not supported")
}

View File

@ -1,3 +1,10 @@
// Copyright Terence J. Boldt (c)2020-2021
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
// This file is contains the main driver code for the Raspberry Pi side of
// the Apple2-IO-RPi hardware. Commands are sent from the Apple II and
// responses are sent back from the Raspberry Pi.
package main
import (

View File

@ -1,3 +1,8 @@
// Copyright Terence J. Boldt (c)2020-2021
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
// This file is used for handling ProDOS image block reading and writing
package handlers
import (

View File

@ -1,3 +1,8 @@
// Copyright Terence J. Boldt (c)2021
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
// This file is used for setting up the communications for the handlers
package handlers
import (

View File

@ -1,3 +1,9 @@
// Copyright Terence J. Boldt (c)2020-2021
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
// This file is contains the handler for executing Linux and internal
// commands
package handlers
import (

View File

@ -1,3 +1,9 @@
// Copyright Terence J. Boldt (c)2020-2021
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
// This file is contains the handler for retrieving the ProDOS timestamp
// based on the current time
package handlers
import (

View File

@ -1,3 +1,9 @@
// Copyright Terence J. Boldt (c)2020-2021
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
// This file is contains the handler for loading files directly from the
// Raspberry Pi onto the Apple II
package handlers
import (

View File

@ -1,3 +1,9 @@
// Copyright Terence J. Boldt (c)2020-2021
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
// This file is contains the handler for displaying the menu of choices on
// the Apple II
package handlers
import (