You've already forked Microtransactions64-server
mirror of
https://github.com/Print-and-Panic/Microtransactions64-server.git
synced 2026-01-21 10:17:31 -08:00
39 lines
888 B
Go
39 lines
888 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
|
|
"github.com/PrintAndPanic/microtransactions64-server/devices"
|
|
)
|
|
|
|
func main() {
|
|
// "n64" defaults to /dev/ttyUSB0 (The Everdrive)
|
|
n64Port := flag.String("n64", "/dev/ttyUSB0", "Serial port for the N64 Everdrive")
|
|
|
|
// 2. Parse Flags (Critical: Must be called before accessing the variables)
|
|
flag.Parse()
|
|
|
|
log.Printf("🚀 STARTING: N64 on %s", *n64Port)
|
|
// --- CONFIGURATION ---
|
|
coinPortName := "/dev/serial0"
|
|
coinPortBaud := 9600
|
|
// ---------------------
|
|
|
|
// 1. Configure the Serial Port
|
|
coinAcceptor := devices.DG600F{PortName: coinPortName, BaudRate: coinPortBaud}
|
|
coinAcceptor.Start()
|
|
defer coinAcceptor.Close()
|
|
|
|
n64 := devices.NewEverDrive(*n64Port)
|
|
n64.Start()
|
|
defer n64.Close()
|
|
|
|
// // 2. Listen for coins
|
|
for coin := range coinAcceptor.Coins() {
|
|
log.Println("Coin accepted:", coin)
|
|
n64.SendData([]byte{byte(coin)})
|
|
}
|
|
|
|
}
|