SIGROK-CLI(1) | General Commands Manual | SIGROK-CLI(1) |
sigrok-cli - Command-line client for the sigrok software
sigrok-cli [OPTIONS] [COMMAND]
sigrok-cli is a cross-platform command line utility for the sigrok software.
It cannot display graphical output, but is still sufficient to run through the whole process of hardware initialization, acquisition, protocol decoding and saving the session.
It is useful for running on remote or embedded systems, netbooks, PDAs, and for various other use-cases. It can display samples on standard output or save them in various file formats.
Drivers can take options, in the form key=value separated by colons.
Drivers communicating with hardware via a serial port always need the port specified as the conn option. For example, to use the Openbench Logic Sniffer:
$ sigrok-cli --driver=ols:conn=/dev/ttyACM0 [...]
Some USB devices don't use a unique VendorID/ProductID combination, and thus need that specified as well. Notice that colons are used to separate the driver name from the conn option, thus colons cannot be used within the conn option's argument. To select a specific USB device, use either VendorID.ProductID or bus.address:
USB VendorID.ProductID example:
$ sigrok-cli --driver=uni-t-ut61e:conn=1a86.e008 [...]
USB bus.address example:
$ sigrok-cli --driver=uni-t-ut61e:conn=4.6 [...]
For example, to set the samplerate to 1MHz on a device supported by the fx2lafw driver, you might specify
$ sigrok-cli -d fx2lafw --config samplerate=1m [...]
Samplerate is an option common to most logic analyzers. The argument specifies the samplerate in Hz. You can also specify the samplerate in kHz, MHz or GHz. The following are all equivalent:
$ sigrok-cli -d fx2lafw --config samplerate=1000000 [...]
$ sigrok-cli -d fx2lafw --config samplerate=1m [...]
$ sigrok-cli -d fx2lafw --config "samplerate=1 MHz" [...]
These examples specify options within a channel group. The first two are equivalent.
$ sigrok-cli -d demo --channel-group Logic --config pattern=random [...]
$ sigrok-cli -d demo --config channel_group=Logic:pattern=random [...]
$ sigrok-cli -d demo --config samplerate=1m --config channel_group=Logic:pattern=random [...]
Example for loading a sigrok session file:
$ sigrok-cli -i example.sr [...]
Example for loading a WAV file (autodetection of input format):
$ sigrok-cli -i example.wav [...]
Example for loading a VCD file from stdin (autodetection of input format):
$ cat example.vcd | sigrok-cli -i - [...]
The format name may optionally be followed by a colon-separated list of options, where each option takes the form key=value.
Example for loading a binary file with options:
$ sigrok-cli -i example.bin
-I binary:numchannels=4:samplerate=1mhz [...]
Example for saving data in the sigrok session format:
$ sigrok-cli [...] -o example.sr
The format name may optionally be followed by a colon-separated list of options, where each option takes the form key=value.
For example, the bits or hex formats, for an ASCII bit or ASCII hexadecimal display, can take a "width" option, specifying the number of samples (in bits) to display per line. Thus -O hex:width=128 will display 128 bits per line, in hexadecimal:
0:ffff ffff ffff ffff ffff ffff ffff ffff
1:ff00 ff00 ff00 ff00 ff00 ff00 ff00 ff00
The lines always start with the channel number (or name, if defined), followed by a colon. If no format is specified, it defaults to bits:width=64, like this:
0:11111111 11111111 11111111 11111111 [...]
1:11111111 00000000 11111111 00000000 [...]
Example for saving data in the CSV format with options:
$ sigrok-cli [...] -o example.csv -O csv:dedup:header=false
Notice that boolean options are true when no value gets specified.
Note that sigrok always names the channels according to how they're shown on the enclosure of the hardware. If your logic analyzer numbers the channels 0-15, that's how you must specify them with this option. An oscilloscope's channels would generally be referred to as "CH1", "CH2", and so on. Use the --show option to see a list of channel names for your device.
The default is to use all the channels available on a device. You can name a channel like this: 1=CLK. A range of channels can also be given, in the form 1-5.
Example:
$ sigrok-cli --driver fx2lafw --samples 100
--channels 1=CLK,2-4,7
CLK:11111111 11111111 11111111 11111111 [...]
2:11111111 11111111 11111111 11111111 [...]
3:11111111 11111111 11111111 11111111 [...]
4:11111111 11111111 11111111 11111111 [...]
7:11111111 11111111 11111111 11111111 [...]
The comma-separated list is processed from left to right, i.e. items farther to the right override previous items. For example 1=CS,CS=MISO will set the name of channel 1 to MISO.
Examples:
$ sigrok-cli -g CH1 [...]
$ sigrok-cli -d demo -g Logic -c pattern=graycode [...]
Channel group specifications in --get or --config options take precedence over channel group names in --channel-group so that a single sigrok-cli invocation can support the query or manipulation of multiple device options which reside in different channel groups.
0 or 1: A low or high value on the pin.
r or f: A rising or falling value on the pin. An r
effectively corresponds to 01.
e: Any kind of change on a pin (either a rising or a falling
edge).
Not every device supports all of these trigger types. Use the --show command to see which triggers your device supports.
Example:
$ sigrok-cli -i <file.sr> -P i2c
Each protocol decoder can optionally be followed by a colon-separated list of options, where each option takes the form key=value.
Example:
$ sigrok-cli -i <file.sr>
-P uart:baudrate=115200:parity_type=odd
The list of supported options depends entirely on the protocol decoder. Every protocol decoder has different options it supports.
Any "options" specified for a protocol decoder which are not actually supported options, will be interpreted as being channel name/number assignments.
Example:
$ sigrok-cli -i <file.sr>
-P spi:wordsize=9:miso=1:mosi=5:clk=3:cs=0
In this example, wordsize is an option supported by the spi protocol decoder. Additionally, the user tells sigrok to decode the SPI protocol using channel 1 as MISO signal for SPI, channel 5 as MOSI, channel 3 as CLK, and channel 0 as CS# signal.
Notice that the sigrok-cli application does not support "name matching". Instead it's assumed that the traces in the input stream match the order of the decoder's input signals, or that users explicitly specify the input channel to decoder signal mapping.
When multiple decoders are specified in the same -P option, they will be stacked on top of each other in the specified order.
Example:
$ sigrok-cli -i <file.sr> -P i2c,eeprom24xx
$ sigrok-cli -i <file.sr> -P uart:baudrate=31250,midi
When multiple -P options are specified, each of them creates one decoder stack, which executes in parallel to other decoder stacks.
Example:
$ sigrok-cli -i <file.sr> -P uart:tx=D0:rx=D1 -P
timing:data=D2
$ sigrok-cli -i <file.sr> -P i2c,i2cfilter,edid -A i2c
If a protocol decoder has multiple annotation classes, you can also specify which one of them to show by specifying its short description like this:
$ sigrok-cli -i <file.sr> -P i2c,i2cfilter,edid
-A i2c=data-read
Select multiple annotation classes by separating them with a colon:
$ sigrok-cli -i <file.sr> -P i2c,i2cfilter,edid
-A i2c=data-read:data-write
Annotation row names will resolve to their respective list of classes. Row and class names can be used in combination. When names are ambiguous then class names take precedence.
$ sigrok-cli -i <file.sr> -P i2c
-A i2c=addr-data:warnings
You can also select multiple protocol decoders, with optionally selected annotation classes each, by separating them with commas:
$ sigrok-cli -i <file.sr> -P i2c,i2cfilter,edid
-A i2c=data-read:data-write,edid
$ sigrok-cli -i <file.sr> -M i2c
Not every decoder generates meta output.
No other information is printed to stdout, so this is suitable for piping into other programs or saving to a file.
Protocol decoders that support binary output publish a list of binary classes, for example the UART decoder might have "TX" and "RX". To select TX for output, the argument to this option would be:
$ sigrok-cli -i <file.sr> -B uart=tx
If only the protocol decoder is specified, without binary class, all classes are written to stdout:
$ sigrok-cli -i <file.sr> -B uart
(this is only useful in rare cases, generally you would specify a certain binary class you're interested in)
Not every decoder generates binary output.
0 None
1 Error
2 Warnings
3 Informational
4 Debug
5 Spew
$ sigrok-cli --driver fx2lafw --show
In order to properly get device options for your hardware, some drivers might need a serial port specified:
$ sigrok-cli --driver ols:conn=/dev/ttyACM0 --show
This also works for protocol decoders, input modules and output modules:
$ sigrok-cli --protocol-decoders i2c --show
$ sigrok-cli --input-format csv --show
$ sigrok-cli --output-format bits --show
This also works for input files, including optional input format specifications:
$ sigrok-cli --input-file <file.sr> --show
$ sigrok-cli --input-file <file.vcd> --input-format vcd
--show
Example:
$ sigrok-cli --scan
The following devices were found:
demo - Demo device with 12 channels: D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3
fx2lafw:conn=3.26 - CWAV USBee SX with 8 channels: 0 1 2 3 4 5 6 7
However, not all devices are auto-detectable (e.g. serial port based ones). For those you'll have to provide a conn option, see above.
$ sigrok-cli --driver digitek-dt4000zc:conn=/dev/ttyUSB0 --scan
The following devices were found:
Digitek DT4000ZC with 1 channel: P1
You can optionally follow the number by s to specify the time to sample in seconds.
For example, --time 2s will sample for two seconds.
You can optionally follow the number by k, m, or g to specify the number of samples in kilosamples, megasamples, or gigasamples, respectively.
For example, --samples 3m will acquire 3000000 samples.
$ sigrok-cli -d demo --get samplerate:averaging --get
channel_group=Logic:pattern
In order to get exactly 100 samples from the connected fx2lafw-supported logic analyzer hardware, run the following command:
--output-format bits --channels 0-3 --wait-trigger \ --triggers 0=1,1=r,2=0,3=1 --time 100
--config datalog=on --set
sigrok-cli exits with 0 on success, 1 on most failures.
Please report any bugs via Bugzilla (http://sigrok.org/bugzilla) or on the sigrok-devel mailing list (sigrok-devel@lists.souceforge.net).
sigrok-cli is covered by the GNU General Public License (GPL). Some portions are licensed under the "GPL v2 or later", some under "GPL v3 or later".
Please see the individual source code files.
This manual page was written by Uwe Hermann <uwe@hermann-uwe.de>. It is licensed under the terms of the GNU GPL (version 2 or later).
March 28, 2019 |