loco binary is a standalone command-line tool for working with DCC-equipped locomotives. You use it to read and write configuration variables (CVs), program decoder addresses, adjust sound volume and lighting brightness, map function keys to outputs, and send direct throttle commands — all from a terminal, without the BigFred web UI. Because loco writes to stdout and reads from stdin, it fits naturally into scripts and backup workflows.
Setup
Before running anyloco command, create a configuration file at ~/.loco.yaml that tells the tool how to reach your command station.
The config file is read from
~/.loco.yaml or from a .loco.yaml in the current working directory, whichever is found first. CLI flags always take precedence over the file.CV commands — loco prog cv
Configuration Variables (CVs) store all decoder settings — address, speed curves, motor control, lighting behaviour, and more. The loco prog cv command group lets you read and write them individually, in comma-separated lists, or as ranges.
Reading CVs
loco uses the programming track when no locomotive address is given. To read CVs from a locomotive sitting on the main track (Programming on Main, PoM), pass -t pom and supply the DCC address with -l:
PoM reads are not acknowledged by all decoders. If
cv get returns ERROR on the main track, fall back to the programming track.Writing CVs
--settle flag (default 300 ms) controls the pause between consecutive writes. Increase it if your decoder needs more recovery time between programming operations.
Bit-level writes — cv set-bit
When you only need to flip one or two bits inside a CV without disturbing the rest, use set-bit. Each assignment is CVnbn=<0|1> where b0 is the least significant bit.
Backup and restore
Becauseloco prints results to stdout and accepts input from stdin, you can build complete backup and restore workflows with standard shell tools.
CV verbosity and timeouts
Allcv subcommands accept -v / --debug to print raw packet bytes to stderr (useful for diagnosing command station communication issues):
--timeout 0 means zero seconds, not “no timeout”. Every command will fail immediately with no response or unrecognized response. Always use a value of at least 1.Function commands — loco drive fn
The loco drive fn command group controls DCC functions (F0–F28) on a locomotive that is already running on the main track. Function state is managed through the command station.
Listing active functions
Turning functions on and off
Drive commands — loco drive speed
The loco drive speed command sets or reads the speed and direction of a locomotive on the main track.
Programming commands — loco prog
The loco prog command group provides higher-level decoder operations that work on top of CV reads and writes: address programming, decoder detection, volume, brightness, function mapping, and factory reset.
All prog subcommands default to the programming track (when -l 0 or no -l flag). Passing a non-zero loco address with -l switches to PoM.
Decoder detection
Identify the decoder fitted to a locomotive by reading CV7 (version) and CV8 (manufacturer):Address programming
Volume — sound decoders only
The
volume commands have no effect on decoders that do not support sound. detect-decoder can help confirm whether your decoder is a sound variant.Brightness — per-output lighting levels
Identifying which output controls which light — brightness test
Before you can set meaningful brightness levels, you need to know which physical light on the model corresponds to each decoder output. The interactive test command lights one output at a time while you watch the model and press Enter to advance.
- Turn all outputs off.
- Light each output in turn at 50% brightness (configurable with
--brightness). - Pause and wait for you to press Enter after noting which light is on.
- Restore all original brightness values when done.
loco prog mapping set.
Function mapping
Map DCC function keys to physical decoder outputs. Each assignment isFUNCTION=OUTPUTS; multiple outputs for the same function are comma-separated.
O<n>, FO<n>, AUX<n>, F0_F (F0 forward), F0_R (F0 reverse). On RailBOX RB 2112/2110, use F0_F and F0_R instead of O1 for the headlight outputs.
Factory reset
Reset the decoder back to factory defaults by writing to CV8. The exact reset value is decoder-specific (RailBOX RB23xx:1; ESU LokSound 5 and ZIMO MS/MN: 8). BigFred detects the decoder type automatically.
Common flags
These flags are accepted by mostloco subcommands:
When
--loco is 0 and --track is not set, loco automatically selects the programming track. When --loco is a non-zero address and --track is not set, it automatically selects PoM. You can override this with an explicit --track flag.