Files
esdi/esdi.go
T
esilva eea5925b90 Added an interface to support multiple games
- In the same way, I expect the addition of the ability of holding
multiple sinks in memory like outputting to a TUI, GUI and other
hardware devices
2024-10-19 21:42:54 +01:00

36 lines
594 B
Go

package main
import (
"log"
"github.com/tarm/serial"
)
type ESDI struct {
SerialConfig *serial.Config
SerialConn *serial.Port
Source GameSource
}
func (e *ESDI) Close() {
err := e.SerialConn.Close()
if err != nil {
log.Fatalf("couldn't close serial connection: %v", err)
}
}
func ESDIInit(port string, baud int) (ESDI, error) {
sConfig := &serial.Config{
Name: port,
Baud: baud,
}
// Open the serial port
sPort, err := serial.OpenPort(sConfig)
if err != nil {
return ESDI{}, err
}
return ESDI{sConfig, sPort, nil}, nil
}