Quicksand

You inherited a motor controller command interface. It receives ASCII commands over UART1 ("FWD", "REV", "STOP") and drives GPIO outputs accordingly. The parser uses a context struct that holds the receive buffer and a pointer to the GPIO output register.

Short commands work perfectly in bench testing. But in the field, the system occasionally receives longer diagnostic strings from the host software before normal motor commands resume. After one of these long messages, the motor outputs go dead and the firmware stops responding.

Expected behavior for valid commands: "FWD" -> set PA5 HIGH, respond "DIR:FWD\n" "REV" -> set PA5 LOW, respond "DIR:REV\n" "STOP" -> clear outputs, respond "DIR:STOP\n" other -> respond "ERR\n"

The firmware should handle any input gracefully, regardless of length. Find and fix the bug.

Loading the interactive arena.