From 20fea02b7804515c160e06379da4a1f9b57e6242 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 18 May 2026 23:16:29 +0200 Subject: [PATCH] Add Makefile shortcuts for goTool and ignore built binary. Expose common gotool targets (build, clients, version, unicast-test, deadzone) with configurable PORT, and add goTool/.gitignore for gotool. Co-authored-by: Cursor --- Makefile | 46 +++++++++++++++++++++++++++++++++++++++++++++- goTool/.gitignore | 7 +++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 goTool/.gitignore diff --git a/Makefile b/Makefile index 3f2f1bd..aaf22cd 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,17 @@ +# 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-version gotool-clients gotool-unicast-test gotool-deadzone-get gotool-deadzone-set + default: - echo "no default rule" + @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 @@ -8,3 +20,35 @@ 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= 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): gotool-build diff --git a/goTool/.gitignore b/goTool/.gitignore new file mode 100644 index 0000000..7f9b3dd --- /dev/null +++ b/goTool/.gitignore @@ -0,0 +1,7 @@ +# Built binary (make gotool-build) +/gotool + +# Go toolchain artifacts +*.exe +*.test +*.out