Switch to IPv4 zeroconf, add test framework with discovery test, fix serial enumeration

This commit is contained in:
Ian Gulliver
2026-04-07 06:58:39 +09:00
parent b8c0e6be66
commit e60479bad8
14 changed files with 308 additions and 33 deletions

View File

@@ -60,7 +60,7 @@ func run() error {
r.info.BoardID[0], r.info.BoardID[1], r.info.BoardID[2], r.info.BoardID[3],
r.info.BoardID[4], r.info.BoardID[5], r.info.BoardID[6], r.info.BoardID[7])
fmt.Printf(" MAC: %s\n", net.HardwareAddr(r.info.MAC[:]))
fmt.Printf(" Link-Local: %s\n", net.IP(r.info.LinkLocal[:]))
fmt.Printf(" IP: %s\n", net.IP(r.info.IP[:]))
fmt.Printf(" Firmware: %s\n", r.info.FirmwareName)
}

73
cmd/test/main.go Normal file
View File

@@ -0,0 +1,73 @@
package main
import (
"fmt"
"os"
"time"
"github.com/theater/picomap/lib/client"
)
func main() {
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "usage: test <name>\n")
os.Exit(1)
}
if err := run(os.Args[1]); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
}
func run(name string) error {
devs, err := client.ListSerial()
if err != nil {
return err
}
var testDev string
for _, dev := range devs {
c, err := client.NewSerial(dev, 2*time.Second)
if err != nil {
continue
}
info, err := c.Info()
c.Close()
if err != nil {
continue
}
if info.FirmwareName == "picomap_test" {
testDev = dev
break
}
}
if testDev == "" {
return fmt.Errorf("no picomap_test device found")
}
fmt.Printf("test %s on %s\n", name, testDev)
c, err := client.NewSerial(testDev, 10*time.Second)
if err != nil {
return err
}
defer c.Close()
result, err := c.Test(name)
if err != nil {
return fmt.Errorf("remote: %w", err)
}
for _, msg := range result.Messages {
fmt.Printf(" [remote] %s\n", msg)
}
if result.Pass {
fmt.Println("PASS")
} else {
fmt.Println("FAIL")
os.Exit(1)
}
return nil
}