simon d24b0cb5c3 Add goTool autotest with bench configs and UART scenarios.
JSON configs describe network and node MACs; scenarios run command
sequences with expect checks. Share UART client API across CLI and tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-18 23:36:28 +02:00
..

goTool

Host-side UART client for the Powerpod master ESP.

Full system documentation (roles, ESP-NOW, framing, protobuf): ../main/README.md.

Usage

cd goTool
go mod tidy
go run . -port /dev/ttyUSB0 version
go run . -port /dev/ttyUSB0 clients
Flag Default Description
-port (required) Serial port on master UART (GPIO2/3 adapter)
-baud 921600 Must match firmware UART_BAUD_RATE

Commands

Command UART payload Description
version 0x03 Prints version and git_hash from firmware
clients 0x04 Lists slaves registered on the master via ESP-NOW
unicast-test 0x07 Sends ESP-NOW unicast test to one slave (-client, -seq)
test Run an automated scenario (JSON configs under testdata/)

clients requires slaves to have responded to master discover broadcasts first.

Automated tests

Bench configs (testdata/configs/) list master/slave MACs. Scenarios (testdata/scenarios/) run a sequence of the same UART commands with input / expect checks.

go run . -port /dev/ttyUSB0 test -list-configs
go run . -port /dev/ttyUSB0 test -list-scenarios
go run . -port /dev/ttyUSB0 test -config example-lab -scenario smoke
go run . -port /dev/ttyUSB0 test -config testdata/configs/my-lab.json -scenario smoke -v

See testdata/README.md for the JSON schema.

go run . -port /dev/ttyUSB0 unicast-test -client 16 -seq 42

On success the slave serial log should show UNICAST TEST OK from master … seq=42.

Example output:

clients (2):
  [0] id=42 mac=aabbccddeeff ver=1 available=true used=false last_ping=250 last_success_ping=250

Regenerate protobuf

protoc --go_out=./pb --go_opt=paths=source_relative \
  --go_opt=Muart_messages.proto=powerpod/gotool/pb \
  -I ../main/proto ../main/proto/uart_messages.proto