powerpods/Makefile
simon 2e88358c53 Add feature development guide and fix ESP-NOW proto generation.
Document UART-to-ESP-NOW flow using Find me; align proto_generate_espnow with uart (python3, -I .).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-19 22:09:24 +02:00

76 lines
2.5 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 gotool-serve
TEST_CONFIG ?= example-lab
SERVE_ADDR ?= :8080
TEST_SCENARIO ?= smoke
default:
@echo "Targets: proto_generate gotool-build gotool-clients gotool-version …"
@echo "Set PORT=$(PORT) (current) for goTool targets."
proto_generate_espnow:
cd main/proto && python3 ../../libs/nanopb/generator/nanopb_generator.py \
-I . -I ../../libs/nanopb/generator/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 \
--go_opt=Mnanopb.proto=powerpod/gotool/pb/nanopb \
-I ../main/proto \
-I ../libs/nanopb/generator/proto \
../main/proto/uart_messages.proto
@sed -i '/powerpod\/gotool\/pb\/nanopb/d' $(GOTOOL_DIR)/pb/uart_messages.pb.go
proto_generate_uart:
cd main/proto && python3 ../../libs/nanopb/generator/nanopb_generator.py \
-I . -I ../../libs/nanopb/generator/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-serve: $(GOTOOL)
$(GOTOOL) -port $(PORT) serve -addr $(SERVE_ADDR)
$(GOTOOL): gotool-build