Single-binary CLI that scaffolds testable Arduino projects, compiles, uploads, and monitors serial output. Templates embed a hardware abstraction layer, Google Mock infrastructure, and CMake-based host tests so application logic can be verified without hardware. Commands: new, doctor, setup, devices, build, upload, monitor 39 Rust tests (21 unit, 18 integration) Cross-platform: Linux and Windows
75 lines
1.8 KiB
Cheetah
75 lines
1.8 KiB
Cheetah
# {{PROJECT_NAME}}
|
|
|
|
Arduino project generated by Anvil v{{ANVIL_VERSION}}.
|
|
|
|
## Quick Start
|
|
|
|
```bash
|
|
# Check your system
|
|
anvil doctor
|
|
|
|
# Find connected boards
|
|
anvil devices
|
|
|
|
# Compile only (no upload)
|
|
anvil build --verify {{PROJECT_NAME}}
|
|
|
|
# Compile and upload
|
|
anvil build {{PROJECT_NAME}}
|
|
|
|
# Compile, upload, and open serial monitor
|
|
anvil build --monitor {{PROJECT_NAME}}
|
|
|
|
# Run host-side unit tests (no board needed)
|
|
cd test && ./run_tests.sh
|
|
```
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
{{PROJECT_NAME}}/
|
|
{{PROJECT_NAME}}/
|
|
{{PROJECT_NAME}}.ino Entry point (setup + loop)
|
|
lib/
|
|
hal/
|
|
hal.h Hardware abstraction interface
|
|
hal_arduino.h Real hardware implementation
|
|
app/
|
|
{{PROJECT_NAME}}_app.h Application logic (testable)
|
|
test/
|
|
mocks/
|
|
mock_hal.h Google Mock HAL
|
|
sim_hal.h Stateful simulator HAL
|
|
test_unit.cpp Unit tests
|
|
CMakeLists.txt Test build system
|
|
run_tests.sh Test runner (Linux/Mac)
|
|
run_tests.bat Test runner (Windows)
|
|
.anvil.toml Project configuration
|
|
```
|
|
|
|
## Architecture
|
|
|
|
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.
|
|
|
|
Two HAL implementations:
|
|
- `ArduinoHal` -- passthroughs to real hardware (used in the .ino)
|
|
- `MockHal` -- Google Mock for verifying exact call sequences in tests
|
|
|
|
## Configuration
|
|
|
|
Edit `.anvil.toml` to change board, baud rate, or build settings:
|
|
|
|
```toml
|
|
[build]
|
|
fqbn = "arduino:avr:uno"
|
|
warnings = "more"
|
|
include_dirs = ["lib/hal", "lib/app"]
|
|
extra_flags = ["-Werror"]
|
|
|
|
[monitor]
|
|
baud = 115200
|
|
```
|