Bidirectional msgpack wire protocol with unpack support

This commit is contained in:
Ian Gulliver
2026-04-03 17:32:14 +09:00
parent d06d8b595e
commit 302f7fdb6a
8 changed files with 202 additions and 50 deletions

View File

@@ -40,8 +40,12 @@ func run(buildDir string) error {
return err
}
if dev != "" {
fmt.Printf("Sending 'b' to %s to enter BOOTSEL mode...\n", dev)
resp, err := picoserial.SendByteAndRead(dev, 'b', 2*time.Second)
fmt.Printf("Sending bootsel request to %s...\n", dev)
req, err := wire.EncodeMessage(&wire.RequestBOOTSEL{})
if err != nil {
return fmt.Errorf("encoding request: %w", err)
}
resp, err := picoserial.SendAndReceive(dev, req, 2*time.Second)
if err != nil {
return err
}
@@ -51,7 +55,7 @@ func run(buildDir string) error {
fmt.Fprintf(os.Stderr, "warning: failed to decode response: %v\n", err)
} else {
switch msg.(type) {
case *wire.RebootingBootsel:
case *wire.ResponseBOOTSEL:
fmt.Println("Device confirmed reboot into BOOTSEL mode.")
default:
fmt.Printf("Unexpected response type: %T\n", msg)