-
Notifications
You must be signed in to change notification settings - Fork 0
Testing.md
Ready to ensure Bang is rock-solid for your Arduino’s command-line takeover? This page covers testing strategies to validate ! (shell), & (sketch uploads), and @ (macro) commands, making sure BANG("echo Hello"), BANG("&blink\n"), and BANG("@play") work flawlessly. With Bang’s lean design for Arduino’s tight memory, these tests keep your project bulletproof. Let’s hammer those bugs and make your microcontroller unstoppable!
- Purpose: Verify Bang’s functionality across Arduino and host.
-
Key Areas:
- Serial-USB communication.
- Shell command execution (
!). - Sketch uploads (
&). - Dynamic macro management (
@add_macro,@play,@delete_macro).
-
Tools: Arduino IDE, Serial Monitor,
arduino_exec.py, example sketches.
- Goal: Confirm Arduino-host Serial-USB connection.
-
Test:
-
Upload a simple sketch:
#include <Bang.h> Bang bang(Serial); void setup() { Serial.begin(38400); while (!Serial) ; } void loop() { BANG("echo Test Serial"); delay(1000); }
-
Run
arduino_exec.py:sudo python3 arduino_exec.py -p /dev/cu.usbserial-00100 -b 38400
-
Open Serial Monitor (Arduino IDE, 38400 baud).
-
-
Expected Result: Serial Monitor shows
Test Serialevery second. -
Fixes: Check baud rate, port, or
arduino_exec.pystatus (see Troubleshooting).
-
Goal: Verify
!commands execute correctly on the host. -
Test:
-
Use
cmd.inofromexamples/or this sketch:#include <Bang.h> Bang bang(Serial); void setup() { Serial.begin(38400); while (!Serial) ; } void loop() { BANG("echo Hello World"); delay(1000); BANG("date"); delay(1000); }
-
Run
arduino_exec.py(as above). -
Open Serial Monitor.
-
-
Expected Result: Serial Monitor shows
Hello World, current date. - Fixes: Verify command syntax, host shell compatibility.
- Goal: Test macro definition, invocation, listing, and deletion.
-
Test:
-
Upload a macro test sketch:
#include <Bang.h> Bang bang(Serial); void setup() { Serial.begin(38400); while (!Serial) ; } void loop() { BANG("@add_macro:play:osascript -e 'tell application \"Music\" to play'"); delay(1000); BANG("@play"); delay(5000); BANG("@list_macros"); delay(1000); BANG("@delete_macro:play"); delay(1000); BANG("@list_macros"); delay(5000); }
-
Run
arduino_exec.py(as above). -
Open Serial Monitor.
-
-
Expected Result:
- Music plays (macOS).
- Serial Monitor shows
Macro 'play' created, macro list withplay, then empty list after deletion.
-
Fixes: Check macro syntax,
sudoforarduino_exec.py(see Python Agent).
-
Goal: Confirm
&sketch_name\nuploads new sketches. -
Test:
-
Use
upload.inofromexamples/:#include <Bang.h> Bang bang(Serial); void setup() { Serial.begin(38400); while (!Serial) ; } void loop() { BANG("&blink\n"); // Uploads blink.ino delay(10000); }
-
Place
blink.inoinarduino_exec.py’s directory. -
Run
arduino_exec.py(as above). -
Open Serial Monitor.
-
-
Expected Result: Arduino restarts, Serial Monitor shows
blink.inooutput (e.g.,Blink Example). -
Fixes: Verify
arduino-cli, sketch path,sudo(see Dynamic Uploading).
-
Arduino Side:
-
Create a test sketch to cycle through commands:
#include <Bang.h> Bang bang(Serial); void setup() { Serial.begin(38400); while (!Serial) ; Serial.println("Test Start"); BANG("echo Test Shell"); BANG("@add_macro:test:echo Macro Test"); BANG("@test"); BANG("@list_macros"); BANG("@delete_macro:test"); BANG("&blink\n"); } void loop() {}
-
Check Serial Monitor for expected outputs.
-
-
Host Side:
-
Add logging to
arduino_exec.py:print(f"Test: {command}, Result: {result}")
-
Run tests and verify logs.
-
-
Test Fails: Check Serial Monitor logs, ensure
arduino_exec.pyruns withsudo. -
Macro Errors: Use
BANG("@list_macros")to debug. -
Upload Issues: Test
arduino-climanually (see Troubleshooting). - Memory Limits: Simplify test sketches to fit Arduino’s RAM.
- Check Contributing for adding tests.
- Explore Examples for tested sketches.
- See FAQ for testing questions.