powerpods/goTool/cmd_version.go
simon 16bfbd1091 Add goTool clients subcommand for CLIENT_INFO query.
Refactor into version/clients subcommands with shared serial framing
to list registered slaves from the master over UART.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-18 22:26:42 +02:00

35 lines
709 B
Go

package main
import (
"fmt"
"google.golang.org/protobuf/proto"
"powerpod/gotool/pb"
)
func runVersion(sp *serialPort) error {
payload, err := sp.exchange(byte(pb.MessageType_VERSION), "VERSION")
if err != nil {
return err
}
var msg pb.UartMessage
if err := proto.Unmarshal(payload[1:], &msg); err != nil {
return fmt.Errorf("decode protobuf: %w", err)
}
if msg.GetType() != pb.MessageType_VERSION {
return fmt.Errorf("unexpected message type %v", msg.GetType())
}
ver := msg.GetVersionResponse()
if ver == nil {
return fmt.Errorf("response missing version_response")
}
fmt.Printf("version: %d\n", ver.GetVersion())
fmt.Printf("git_hash: %s\n", ver.GetGitHash())
return nil
}