Skip to main content
The 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 any loco 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

By default, 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

The --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

Because loco prints results to stdout and accepts input from stdin, you can build complete backup and restore workflows with standard shell tools.
You can also maintain a hand-curated list of CVs to snapshot:
Keep a backup file before experimenting with sound or motor tuning settings. If results are unsatisfactory, restore the original values with a single cat backup.txt | loco prog cv set -- - command.

CV verbosity and timeouts

All cv subcommands accept -v / --debug to print raw packet bytes to stderr (useful for diagnosing command station communication issues):
You can also raise or lower the response timeout:
--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

Example output when two functions are active:

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.
Speed values depend on the speed-step mode in use:
--loco is required for speed set and speed get. The command will refuse to run without it.

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 on all lighting functions on the vehicle before the test starts. The tool will:
  1. Turn all outputs off.
  2. Light each output in turn at 50% brightness (configurable with --brightness).
  3. Pause and wait for you to press Enter after noting which light is on.
  4. Restore all original brightness values when done.
Use the output numbers reported by the test when running loco prog mapping set.

Function mapping

Map DCC function keys to physical decoder outputs. Each assignment is FUNCTION=OUTPUTS; multiple outputs for the same function are comma-separated.
Supported output tokens: 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.
A factory reset overwrites all CV values, including any motor tuning, sound configuration, and function mappings you have set. Back up your CVs first with loco prog cv get cv1-cv255 > backup.txt.

Common flags

These flags are accepted by most loco 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.