IP Configuration

Configure network settings over USB serial using the built-in terminal interface.

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

sudo usermod -a -G dialout $USER

Then log out and back in for the change to take effect.

Serial Terminal Setup (Linux)

  1. Install minicom:
    sudo apt update && sudo apt install minicom
  2. Connect to the device:
    minicom -D /dev/ttyACM0 -b 115200
  3. 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.

CommandDescriptionExample
helpShow available commandshelp
checkShow full current config (MAC, IP, subnet, gateway, DNS, DHCP, port, PHY, timeout)check
ip <x.x.x.x>Set device IP addressip 192.168.1.100
ipShow current IPip
port <n>Set UDP portport 5000
portShow current portport
mac <xx:xx:xx:xx:xx:xx>Set MAC addressmac 00:1A:2B:3C:4D:5E
macShow current MACmac
timeout <µs>Set timeout in microsecondstimeout 1000000
timeoutShow current timeouttimeout
tim <n>Set time constant valuetim 500
defaultsRestore factory defaultsdefaults
savePersist current config to flashsave
reset / rebootReboot device via watchdogreset

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

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