Syntax
Arguments
Options
When invoked without a subcommand, lists SPI nets on the box (or shows configuration for the specified net).
Subcommands
config
Configure SPI bus parameters. Settings persist across subsequent commands.
SPI Modes:
Examples:
transfer
Perform a full-duplex SPI transfer. Sends data while simultaneously receiving response. If provided data is shorter than NUM_WORDS, the remaining words are padded with the fill value. If longer, data is truncated.
Examples:
read
Read data from an SPI slave device. Sends fill bytes while clocking in the response.
Examples:
write
Write data to an SPI slave device. Performs a full-duplex transfer and displays the received response.
Examples:
Hex Data Formats
Data arguments accept multiple hex formats. Parsing behavior depends on word size: 8-bit word size (default):
16-bit or 32-bit word size:
Values are validated against the configured word size range.
Fill Value Format
The--fill option accepts hex or decimal values:
Frequency Format
Clock frequencies accept numeric values with optional suffixes:Supported Hardware
LabJack T7 clock: a request of 800 kHz or more runs at about 800 kHz. The T7 firmware fails a multi-byte transfer at most rates between about 1 kHz and 800 kHz. For a multi-byte transfer, the driver therefore runs a request in that range at about 1 kHz and prints a warning once. A single-byte transfer, and a request at or below about 1 kHz, use the requested rate.
LabJack U3
A U3 runs SPI through a firmware command of the U3, not through LJM. SPI on a U3 needs U3 hardware version 1.21 or later. Pins: the default channelFIO4-FIO7 assigns the pins in the order CS, CLK, MISO, MOSI. That order is different from the T7 order, which is CS, CLK, MOSI, MISO. For other pins, create the net with lager nets add and the options --cs, --sck, --mosi and --miso. FIO0-FIO3 cannot carry SPI. The EIO and CIO lines are on the DB15 connector of the U3.
Limits:
- A transfer is at most 50 bytes: 50 words at an 8-bit word size, 25 words at 16 bits, or 12 words at 32 bits.
- The clock runs from about 5.4 kHz to 71.4 kHz, and the box never runs it faster than the request. A request outside that range is clamped.
configprints the rate that the hardware uses. When that rate differs from the request, it prints the request in brackets:
config shows the default request, (requested 1000000Hz). The CLI does not show a warning for a clamped clock, so read the rate in the config output.
Chip select: the U3 firmware drives CS low for each transfer and releases it at the end. It has no polarity control and no hold control. The box refuses --cs-active high. In auto CS mode, the box also refuses --keep-cs.
For an active-high device, or to hold CS across transfers, create the SPI net without CS and drive CS from a gpio net. A net without CS uses manual CS mode.
Net Configuration
SPI nets are configured insaved_nets.json on the box. Example net record:
Output Formats
Examples
Troubleshooting
No Response from Device
- Verify MOSI, MISO, SCLK, and CS wiring
- Check SPI mode matches the device datasheet
- Confirm CS polarity (
--cs-active lowfor most devices) - Try reducing frequency with
--frequency 100k
Garbled Data
- Verify SPI mode (CPOL/CPHA) matches the device
- Check bit order (MSB vs LSB first)
- Ensure word size matches the device protocol
CS Pin Not Working (LabJack T7)
- In
autoCS mode, the T7 firmware asserts and releases CS for each transfer - With
--keep-cs, the driver drives CS with GPIO writes instead - Verify the
cs_pinin the net configuration matches your wiring
Refused Options (LabJack U3)
--cs-active highis refused on a U3. Use a net without CS and agpionet for CS.--keep-csis refused inautoCS mode on a U3. Use the same method.- A transfer of more than 50 bytes is refused. Split it into smaller transfers.
Notes
- Default SPI net can be set with
lager defaults add --spi-net NETNAME - LabJack T7 runs at about 800 kHz for a request of 800 kHz or more. A multi-byte transfer with a request between about 1 kHz and 800 kHz runs at about 1 kHz
- LabJack U3 runs from about 5.4 kHz to 71.4 kHz, and
configprints the rate that the hardware uses - SPI is full-duplex: data is always sent and received simultaneously
- Use
--keep-csfor multi-part transactions that require CS to stay asserted - Configuration set via
configpersists across subsequenttransfer/read/writecommands
See Also
- I2C — I2C bus communication (the other common serial protocol)
- Python SPI API — Automate SPI operations in Python scripts
- Glossary — Definitions of SPI, I2C, and other terms

