powerpods/Makefile
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

66 lines
2.1 KiB
Makefile

# Serial port for goTool (override: make gotool-clients PORT=/dev/ttyACM0)
PORT ?= /dev/ttyUSB0
GOTOOL_DIR := goTool
GOTOOL := $(GOTOOL_DIR)/gotool
GOTOOL_RUN := cd $(GOTOOL_DIR) && go run . -port $(PORT)
.PHONY: default proto_generate proto_generate_uart proto_generate_espnow \
gotool-build gotool-proto gotool-tidy gotool-test-units \
gotool-version gotool-clients gotool-unicast-test gotool-deadzone-get gotool-deadzone-set \
gotool-test
TEST_CONFIG ?= example-lab
TEST_SCENARIO ?= smoke
default:
@echo "Targets: proto_generate gotool-build gotool-clients gotool-version …"
@echo "Set PORT=$(PORT) (current) for goTool targets."
proto_generate_uart:
python libs/nanopb/generator/nanopb_generator.py main/proto/uart_messages.proto
proto_generate_espnow:
python libs/nanopb/generator/nanopb_generator.py main/proto/esp_now_messages.proto
proto_generate: proto_generate_uart proto_generate_espnow
gotool-proto:
cd $(GOTOOL_DIR) && 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
gotool-tidy:
cd $(GOTOOL_DIR) && go mod tidy
gotool-build: gotool-tidy
cd $(GOTOOL_DIR) && go build -o gotool .
gotool-version: $(GOTOOL)
$(GOTOOL) -port $(PORT) version
gotool-clients: $(GOTOOL)
$(GOTOOL) -port $(PORT) clients
# CLIENT=<slave id> SEQ=42 (optional)
gotool-unicast-test: $(GOTOOL)
@test -n "$(CLIENT)" || (echo "Usage: make gotool-unicast-test CLIENT=16 [SEQ=42]"; exit 1)
$(GOTOOL) -port $(PORT) unicast-test -client $(CLIENT) -seq $(or $(SEQ),1)
gotool-deadzone-get: $(GOTOOL)
$(GOTOOL) -port $(PORT) deadzone -client $(or $(CLIENT),0)
# DEADZONE=100 CLIENT=0 (local) or slave id
gotool-deadzone-set: $(GOTOOL)
@test -n "$(DEADZONE)" || (echo "Usage: make gotool-deadzone-set DEADZONE=100 [CLIENT=16]"; exit 1)
$(GOTOOL) -port $(PORT) deadzone -set -value $(DEADZONE) -client $(or $(CLIENT),0)
gotool-test-units:
cd $(GOTOOL_DIR) && go test ./...
# CONFIG=example-lab SCENARIO=smoke
gotool-test: $(GOTOOL)
$(GOTOOL) -port $(PORT) test -config $(TEST_CONFIG) -scenario $(TEST_SCENARIO)
$(GOTOOL): gotool-build