Overview
The ipconfig functionality provides a serial terminal interface for configuring the stepper-ninja device at runtime. It allows setting network parameters (IP, MAC, port, etc.), managing timeouts, saving configurations to flash, and resetting the device — all without reflashing firmware.
Commands are entered via a serial connection, processed in real-time, and validated for correct formatting.
Prerequisites
- A serial terminal emulator (e.g. minicom) configured to connect to
/dev/ttyACM0at 115200 8N1. - Add your user to the
dialoutgroup:
sudo usermod -a -G dialout $USER
Then log out and back in for the change to take effect.
Serial Terminal Setup (Linux)
- Install minicom:
sudo apt update && sudo apt install minicom - Connect to the device:
minicom -D /dev/ttyACM0 -b 115200 - Disable flow control: press Ctrl+A, then O, select Serial port setup, set F (hardware flow) and G (software flow) to
No.
Supported Commands
Commands are case-sensitive. Commands with parameters require exact formatting. Issue save after any change to persist it to flash — otherwise changes are lost on reset.
| Command | Description | Example |
|---|---|---|
help | Show available commands | help |
check | Show full current config (MAC, IP, subnet, gateway, DNS, DHCP, port, PHY, timeout) | check |
ip <x.x.x.x> | Set device IP address | ip 192.168.1.100 |
ip | Show current IP | ip |
port <n> | Set UDP port | port 5000 |
port | Show current port | port |
mac <xx:xx:xx:xx:xx:xx> | Set MAC address | mac 00:1A:2B:3C:4D:5E |
mac | Show current MAC | mac |
timeout <µs> | Set timeout in microseconds | timeout 1000000 |
timeout | Show current timeout | timeout |
tim <n> | Set time constant value | tim 500 |
defaults | Restore factory defaults | defaults |
save | Persist current config to flash | save |
reset / reboot | Reboot device via watchdog | reset |
Usage Example
1. Connect and check current config
minicom -D /dev/ttyACM0 -b 115200
check
Example output:
Current configuration:
MAC: 00:1A:2B:3C:4D:5E
IP: 192.168.1.100
Subnet: 255.255.255.0
Gateway: 192.168.1.1
DNS: 8.8.8.8
DHCP: 1 (1-Static, 2-Dynamic)
PORT: 5000
*******************PHY status**************
PHY Duplex: Full
PHY Speed: 100Mbps
*******************************************
Timeout: 1000000
Ready.
2. Change the IP address and save
ip 192.168.1.200
save
reset
Technical Details
Input Handling
The handle_serial_input function reads characters non-blocking via getchar_timeout_us. It ignores non-printable ASCII (except \r) and stores valid input in a 64-byte buffer. When \r is received or the buffer fills, the command is processed and the buffer is cleared.
Command Processing
process_command parses commands using strcmp and strncmp. For parameterised commands, sscanf validates input (e.g. IP, MAC, port). Changes are applied to global variables (net_info, port, TIMEOUT_US, time_constant) and saved via save_configuration.
Configuration Storage
save_configuration copies settings to a flash_config structure persisted to flash via save_config_to_flash. load_configuration initialises settings from flash on startup.
Locking Mechanism
The terminal locks when timeout_error == 0 and unlocks when timeout_error == 1.
Troubleshooting
No response from device
- Verify the correct serial port:
ls /dev/tty* - Ensure baud rate is 115200.
- Check USB cable and device power.
Permission denied on serial port
sudo usermod -a -G dialout $USER
Garbled output
Verify baud rate, parity (8N1), and flow control (disabled) in minicom.
Invalid format errors
Ensure exact command syntax — e.g. ip 192.168.1.100, not ip 192.168.001.100.
Changes not persisted after reboot
Issue the save command before reset.
Limitations
- Terminal buffer limited to 63 characters — longer commands are truncated.
- The serial interface is non-blocking; rapid input may be missed if the device is busy.
- The locking mechanism (based on
timeout_error) may restrict access if network conditions trigger timeouts.