Syntax
Arguments
| Argument | Description |
|---|---|
NETNAME | SPI net name (optional if default is set via lager defaults add --spi-net) |
Options
| Option | Description |
|---|---|
--box BOX | Lagerbox name or IP address |
Subcommands
config
Configure SPI bus parameters. Settings persist across subsequent commands.
| Option | Description |
|---|---|
--box BOX | Lagerbox name or IP address |
--mode 0|1|2|3 | SPI mode (clock polarity and phase) |
--frequency FREQ | Clock frequency (e.g., 1M, 500k, 5M) |
--bit-order msb|lsb | Bit order: MSB first or LSB first |
--word-size 8|16|32 | Word size in bits |
--cs-active low|high | Chip select active polarity |
--cs-mode auto|manual | CS assertion mode: auto (hardware) or manual (user-managed GPIO) |
| Mode | CPOL | CPHA | Description |
|---|---|---|---|
| 0 | 0 | 0 | Clock idle low, data sampled on rising edge |
| 1 | 0 | 1 | Clock idle low, data sampled on falling edge |
| 2 | 1 | 0 | Clock idle high, data sampled on falling edge |
| 3 | 1 | 1 | Clock idle high, data sampled on rising edge |
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.
| Argument | Description |
|---|---|
NUM_WORDS | Number of words to transfer |
| Option | Description | Default |
|---|---|---|
--box BOX | Lagerbox name or IP address | |
--data DATA | Hex data to transmit (e.g., 0x9f01) | |
--data-file PATH | File containing data to transmit | |
--fill VALUE | Fill value for padding | 0xFF |
--mode 0|1|2|3 | SPI mode override | |
--frequency FREQ | Clock frequency override | |
--bit-order msb|lsb | Bit order override | |
--word-size 8|16|32 | Word size override | |
--cs-active low|high | CS polarity override | |
--keep-cs | Keep CS asserted after transfer | false |
--format FORMAT | Output format: hex, bytes, json | hex |
read
Read data from an SPI slave device. Sends fill bytes while clocking in the response.
| Argument | Description |
|---|---|
NUM_WORDS | Number of words to read |
| Option | Description | Default |
|---|---|---|
--box BOX | Lagerbox name or IP address | |
--fill VALUE | Fill byte sent while reading | 0xFF |
--mode 0|1|2|3 | SPI mode override | |
--frequency FREQ | Clock frequency override | |
--bit-order msb|lsb | Bit order override | |
--word-size 8|16|32 | Word size override | |
--cs-active low|high | CS polarity override | |
--keep-cs | Keep CS asserted after transfer | false |
--format FORMAT | Output format: hex, bytes, json | hex |
write
Write data to an SPI slave device. Performs a full-duplex transfer and displays the received response.
| Argument | Description |
|---|---|
DATA | Hex data to write (e.g., 0x9f01020304) |
| Option | Description | Default |
|---|---|---|
--box BOX | Lagerbox name or IP address | |
--mode 0|1|2|3 | SPI mode override | |
--frequency FREQ | Clock frequency override | |
--bit-order msb|lsb | Bit order override | |
--word-size 8|16|32 | Word size override | |
--cs-active low|high | CS polarity override | |
--keep-cs | Keep CS asserted after transfer | false |
--format FORMAT | Output format: hex, bytes, json | hex |
Hex Data Formats
Data arguments accept multiple hex formats. Parsing behavior depends on word size: 8-bit word size (default):| Format | Example | Parsed As |
|---|---|---|
| Prefixed continuous | 0x9f01 | [0x9f, 0x01] |
| Unprefixed continuous | 9f01 | [0x9f, 0x01] |
| Space-separated | 9f 01 02 | [0x9f, 0x01, 0x02] |
| Comma-separated | 9f,01,02 | [0x9f, 0x01, 0x02] |
| Format | Example | Parsed As |
|---|---|---|
| Continuous | 0x1234 | [0x1234] |
| Space-separated | 0x1234 0x5678 | [0x1234, 0x5678] |
Fill Value Format
The--fill option accepts hex or decimal values:
| Format | Example | Value |
|---|---|---|
| Hex prefixed | 0xff | 255 |
| Hex unprefixed | ff | 255 |
| Decimal | 255 | 255 |
Frequency Format
Clock frequencies accept numeric values with optional suffixes:| Format | Example | Value |
|---|---|---|
| Plain Hz | 1000000 | 1 MHz |
| kHz suffix | 500k | 500 kHz |
| MHz suffix | 5M | 5 MHz |
| Hz suffix | 1000000hz | 1 MHz |
Supported Hardware
| Adapter | Pins | CS Control | Notes |
|---|---|---|---|
| LabJack T7 | Configurable FIO pins (e.g., FIO0-FIO3) | Manual GPIO | ~450 kHz max (throttle=0); CS managed via GPIO writes |
| Aardvark USB | Fixed MOSI/MISO/SCK/SS | Hardware or manual | Up to 8 MHz |
| FT232H | Configurable | MPSSE-based | FTDI MPSSE SPI |
Net Configuration
SPI nets are configured insaved_nets.json on the box. Example net record:
Output Formats
| Format | Description |
|---|---|
hex | Space-separated hex values (e.g., 9f 01 02) |
bytes | Raw byte values |
json | JSON object with data array and metadata |
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)
- LabJack T7 uses manual GPIO-based CS control
- The driver automatically asserts/deasserts CS via GPIO writes
- Verify the
cs_pinin the net configuration matches your wiring
Notes
- Default SPI net can be set with
lager defaults add --spi-net NETNAME - LabJack T7 operates at ~450 kHz regardless of requested frequency due to hardware limitations
- 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

