Refactor CLI, add refresh command, fix port detection, add device tracking
- Remove build/upload/monitor subcommands (projects are self-contained) - Remove ctrlc dependency (only used by removed monitor watch mode) - Update next-steps messaging to reference project scripts directly - Add 'anvil refresh [DIR] [--force]' to update project scripts to latest templates without touching user code - Fix Windows port detection: replace fragile findstr/batch TOML parsing with proper comment-skipping logic; add _detect_port.ps1 helper for reliable JSON-based port detection via PowerShell - Add .anvil.local for machine-specific config (gitignored) - 'anvil devices --set [PORT] [-d DIR]' saves port + VID:PID - 'anvil devices --get [-d DIR]' shows saved port status - VID:PID tracks USB devices across COM port reassignment - Port resolution: -p flag > VID:PID > saved port > auto-detect - Uppercase normalization for Windows COM port names - Update all .bat/.sh templates to read from .anvil.local - Remove port entries from .anvil.toml (no machine-specific config in git) - Add .anvil.local to .gitignore template - Expand 'anvil devices' output with VID:PID, serial number, and usage instructions
This commit is contained in:
@@ -1,29 +1,38 @@
|
||||
# {{PROJECT_NAME}}
|
||||
|
||||
Arduino project generated by Anvil v{{ANVIL_VERSION}}.
|
||||
Arduino project generated by [Anvil](https://github.com/nexusworkshops/anvil) v{{ANVIL_VERSION}}.
|
||||
|
||||
This project is self-contained. After creation, it only needs `arduino-cli`
|
||||
in PATH -- the Anvil binary is not required for day-to-day work.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Check your system
|
||||
anvil doctor
|
||||
# Compile only (verify)
|
||||
./build.sh
|
||||
|
||||
# Find connected boards
|
||||
anvil devices
|
||||
|
||||
# Compile only (no upload)
|
||||
anvil build --verify {{PROJECT_NAME}}
|
||||
|
||||
# Compile and upload
|
||||
anvil build {{PROJECT_NAME}}
|
||||
# Compile and upload to board
|
||||
./upload.sh
|
||||
|
||||
# Compile, upload, and open serial monitor
|
||||
anvil build --monitor {{PROJECT_NAME}}
|
||||
./upload.sh --monitor
|
||||
|
||||
# Open serial monitor (no compile)
|
||||
./monitor.sh
|
||||
|
||||
# Persistent monitor (reconnects after reset/replug)
|
||||
./monitor.sh --watch
|
||||
|
||||
# Run host-side unit tests (no board needed)
|
||||
cd test && ./run_tests.sh
|
||||
./test/run_tests.sh
|
||||
```
|
||||
|
||||
On Windows, use `build.bat`, `upload.bat`, `monitor.bat`, and
|
||||
`test\run_tests.bat` instead.
|
||||
|
||||
All scripts read settings from `.anvil.toml` -- edit it to change
|
||||
the board, baud rate, include paths, or compiler flags.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
@@ -44,6 +53,9 @@ cd test && ./run_tests.sh
|
||||
CMakeLists.txt Test build system
|
||||
run_tests.sh Test runner (Linux/Mac)
|
||||
run_tests.bat Test runner (Windows)
|
||||
build.sh / build.bat Compile sketch
|
||||
upload.sh / upload.bat Compile + upload to board
|
||||
monitor.sh / monitor.bat Serial monitor
|
||||
.anvil.toml Project configuration
|
||||
```
|
||||
|
||||
@@ -52,7 +64,7 @@ cd test && ./run_tests.sh
|
||||
All hardware access goes through the `Hal` interface. The app code
|
||||
(`lib/app/`) depends only on `Hal`, never on `Arduino.h` directly.
|
||||
This means the app can be compiled and tested on the host without
|
||||
any Arduino SDK.
|
||||
any Arduino hardware.
|
||||
|
||||
Two HAL implementations:
|
||||
- `ArduinoHal` -- passthroughs to real hardware (used in the .ino)
|
||||
@@ -72,3 +84,9 @@ extra_flags = ["-Werror"]
|
||||
[monitor]
|
||||
baud = 115200
|
||||
```
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- `arduino-cli` in PATH with `arduino:avr` core installed
|
||||
- For host tests: `cmake`, `g++` (or `clang++`), `git`
|
||||
- Install everything at once: `anvil setup`
|
||||
|
||||
Reference in New Issue
Block a user