]> sigrok.org Git - sigrok-cli.git/blame_incremental - doc/sigrok-cli.1
doc: update sigrok-cli(1) for channel assignment to decoder inputs
[sigrok-cli.git] / doc / sigrok-cli.1
... / ...
CommitLineData
1.TH SIGROK\-CLI 1 "April 07, 2023"
2.SH "NAME"
3sigrok\-cli \- Command-line client for the sigrok software
4.SH "SYNOPSIS"
5.B sigrok\-cli [OPTIONS] [COMMAND]
6.SH "DESCRIPTION"
7\fBsigrok\-cli\fP is a cross-platform command line utility for the
8\fBsigrok\fP software.
9.PP
10It cannot display graphical output, but is still sufficient to run through
11the whole process of hardware initialization, acquisition, protocol decoding
12and saving the session.
13.PP
14It is useful for running on remote or embedded systems, netbooks, PDAs,
15and for various other use-cases. It can display samples on standard output or
16save them in various file formats.
17.SH OPTIONS
18.TP
19.B "\-h, \-\-help"
20Show a help text and exit.
21.TP
22.B "\-V, \-\-version"
23Show
24.B sigrok\-cli
25version and the versions of libraries used.
26.TP
27.B "\-L, \-\-list\-supported"
28Show information about supported hardware drivers, input file
29formats, output file formats, and protocol decoders.
30.TP
31.B "\-\-list\-supported\-wiki"
32Show information about supported protocol decoders in MediaWiki syntax.
33This is generally only used by developers to easily update the list of
34supported protocol decoders in the sigrok wiki.
35.TP
36\fB\-d, \-\-driver\fP <drivername>
37Unless doing a global scan, users typically select one of the available
38drivers. This can speedup program start, and can avoid false matches for
39ambiguous configurations. Selecting a driver also allows to pass more
40driver specific options. Use the
41.BR "\-L " ( "\-\-list\-supported" ")"
42option to get a list of available drivers.
43.sp
44Drivers can take options, in the form \fBkey=value\fP
45separated by colons.
46.sp
47Drivers communicating with hardware via a serial port always need the port
48specified as the \fBconn\fP option. For example, to use the
49Openbench Logic Sniffer:
50.sp
51.RB " $ " "sigrok\-cli \-\-driver=ols:conn=/dev/ttyACM0" " [...]"
52.sp
53Some USB devices don't use a unique VendorID/ProductID combination, and thus
54need that specified as well. Notice that colons are used to separate the
55driver name from the \fBconn\fP option, thus colons cannot be used within the
56\fBconn\fP option's argument. To select a specific USB device, use either
57\fBVendorID.ProductID\fP or \fBbus.address\fP:
58.sp
59USB \fBVendorID.ProductID\fP example:
60.sp
61.RB " $ " "sigrok\-cli \-\-driver=uni\-t\-ut61e:conn=1a86.e008" " [...]"
62.sp
63USB \fBbus.address\fP example:
64.sp
65.RB " $ " "sigrok\-cli \-\-driver=uni\-t\-ut61e:conn=4.6" " [...]"
66.TP
67.B "\-D, \-\-dont\-scan"
68Do not automatically scan for device drivers in the absence of a
69.BR "\-d " ( "\-\-driver" )
70specification.
71.TP
72.BR "\-c, \-\-config " <deviceoption>
73A colon-separated list of device options, where each option takes the form
74.BR key=value .
75Multiple occurances of the
76.B \-\-config
77option are supported.
78The first item in the list of options can take the form
79.B channel_group=<name>
80which would override the
81.B \-\-channel\-group
82specification for this list of options. Other option lists in other
83.B \-\-config
84occurances are not affected by this list's channel group name.
85.sp
86For example, to set the samplerate to 1MHz on a device supported by the
87fx2lafw driver, you might specify
88.sp
89.RB " $ " "sigrok\-cli \-d fx2lafw \-\-config samplerate=1m" " [...]"
90.sp
91Samplerate is an option common to most logic analyzers. The argument specifies
92the samplerate in Hz. You can also specify the samplerate in kHz, MHz or GHz.
93The following are all equivalent:
94.sp
95.RB " $ " "sigrok\-cli \-d fx2lafw \-\-config samplerate=1000000" " [...]"
96.sp
97.RB " $ " "sigrok\-cli \-d fx2lafw \-\-config samplerate=1m" " [...]"
98.sp
99.RB " $ " "sigrok\-cli \-d fx2lafw \-\-config \(dqsamplerate=1 MHz\(dq" " [...]"
100.sp
101These examples specify options within a channel group.
102The first two are equivalent.
103.sp
104.RB " $ " "sigrok\-cli \-d demo \-\-channel\-group Logic \-\-config pattern=random [...]"
105.sp
106.RB " $ " "sigrok\-cli \-d demo \-\-config channel_group=Logic:pattern=random [...]"
107.sp
108.RB " $ " "sigrok\-cli \-d demo \-\-config samplerate=1m \-\-config channel_group=Logic:pattern=random [...]"
109.TP
110.BR "\-i, \-\-input\-file " <filename>
111Load input from a file instead of a hardware device. You can specify
112"-" to use stdin as input. If the
113.B \-\-input\-format
114option is not supplied, sigrok\-cli attempts to autodetect the file format of
115the input file.
116.sp
117Example for loading a sigrok session file:
118.sp
119.RB " $ " "sigrok\-cli \-i example.sr" " [...]"
120.sp
121Example for loading a WAV file (autodetection of input format):
122.sp
123.RB " $ " "sigrok\-cli \-i example.wav" " [...]
124.sp
125Example for loading a VCD file from stdin (autodetection of input format):
126.sp
127.RB " $ " "cat example.vcd | sigrok\-cli \-i \-" " [...]
128.TP
129.BR "\-I, \-\-input\-format " <format>
130When loading an input file, assume it's in the specified format. If this
131option is not supplied (in addition to
132.BR \-\-input\-file ),
133sigrok-cli attempts to autodetect the file format of the input file. Use the
134.BR "\-L " ( "\-\-list\-supported" ")"
135option to see a list of available input formats.
136.sp
137The format name may optionally be followed by a colon-separated list of
138options, where each option takes the form
139.BR "key=value" .
140.sp
141Example for loading a binary file with options:
142.sp
143.RB " $ " "sigrok\-cli \-i example.bin"
144.br
145.BR " \-I binary:numchannels=4:samplerate=1mhz" " [...]"
146.TP
147.BR "\-o, \-\-output\-file " <filename>
148Save output to a file instead of writing it to stdout. The default format
149used when saving is the sigrok session file format. This can be changed with
150the
151.B \-\-output\-format
152option.
153.sp
154Example for saving data in the sigrok session format:
155.sp
156.RB " $ " "sigrok\-cli " "[...] " "\-o example.sr"
157.TP
158.BR "\-O, \-\-output\-format " <format>
159Set the output format to use. Use the
160.BR "\-L " ( "\-\-list\-supported" ")"
161option to see a list of available output formats.
162.sp
163The format name may optionally be followed by a colon-separated list of
164options, where each option takes the form
165.BR "key=value" .
166.sp
167For example, the
168.B bits
169or
170.B hex
171formats, 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
172.B "\-O hex:width=128"
173will display 128 bits per line, in hexadecimal:
174.sp
175 0:ffff ffff ffff ffff ffff ffff ffff ffff
176 1:ff00 ff00 ff00 ff00 ff00 ff00 ff00 ff00
177.sp
178The lines always start with the channel number (or name, if defined), followed by a colon. If no format is specified, it defaults to
179.BR bits:width=64 ,
180like this:
181.sp
182 0:11111111 11111111 11111111 11111111 [...]
183 1:11111111 00000000 11111111 00000000 [...]
184.sp
185Example for saving data in the CSV format with options:
186.sp
187.RB " $ " "sigrok\-cli " "[...] " "\-o example.csv \-O csv:dedup:header=false"
188.sp
189Notice that boolean options are \fBtrue\fP when no value gets specified.
190.TP
191.BR "\-C, \-\-channels " <channellist>
192A comma-separated list of channels to be used in the session.
193.sp
194Note that sigrok always names the channels according to how they're shown on
195the enclosure of the hardware. If your logic analyzer numbers the channels 0\-15,
196that's how you must specify them with this option. An oscilloscope's channels
197would generally be referred to as "CH1", "CH2", and so on.
198Use the \fB\-\-show\fP option to see a list of channel names for your device.
199.sp
200The default is to use all the channels available on a device. You can name
201a channel like this:
202.BR "1=CLK" .
203A range of channels can also be given, in the form
204.BR "1\-5" .
205.sp
206Example:
207.sp
208.RB " $ " "sigrok\-cli \-\-driver fx2lafw \-\-samples 100"
209.br
210.B " \-\-channels 1=CLK,2\-4,7"
211.br
212 CLK:11111111 11111111 11111111 11111111 [...]
213 2:11111111 11111111 11111111 11111111 [...]
214 3:11111111 11111111 11111111 11111111 [...]
215 4:11111111 11111111 11111111 11111111 [...]
216 7:11111111 11111111 11111111 11111111 [...]
217.sp
218The comma-separated list is processed from left to right, i.e. items farther
219to the right override previous items. For example
220.B "1=CS,CS=MISO"
221will set the name of channel 1 to
222.BR "MISO" .
223.TP
224.BR "\-g, \-\-channel\-group "<channel\ group>
225Specify the channel group to operate on. Some devices organize channels into
226groups, the settings of which can only be changed as a group. The list of
227channel groups, if any, is displayed with the \fB\-\-show\fP command.
228.sp
229Examples:
230.sp
231.RB " $ " "sigrok\-cli \-g CH1" " [...]"
232.sp
233.RB " $ " "sigrok\-cli \-d demo \-g Logic \-c pattern=graycode" " [...]"
234.sp
235Channel group specifications in
236.B \-\-get
237or
238.B \-\-config
239options take precedence over channel group names in
240.B \-\-channel\-group
241so that a single
242.B sigrok\-cli
243invocation can support the query or manipulation of multiple device options
244which reside in different channel groups.
245.TP
246.BR "\-t, \-\-triggers " <triggerlist>
247A comma-separated list of triggers to use, of the form
248.BR "<channel>=<trigger>" .
249You can use the name or number of the channel, and the trigger itself is a
250series of characters:
251.sp
252.BR "0 or 1" :
253A low or high value on the pin.
254.br
255.BR "r or f" :
256A rising or falling value on the pin. An
257.B r
258effectively corresponds to
259.BR 01 .
260.br
261.BR "e" :
262Any kind of change on a pin (either a rising or a falling edge).
263.sp
264Not every device supports all of these trigger types. Use the \fB\-\-show\fP
265command to see which triggers your device supports.
266.TP
267.BR "\-w, \-\-wait\-trigger"
268Don't output any sample data (even if it's actually received from the
269hardware) before the trigger condition is met. In other words, do not output
270any pre-trigger data. This option is useful if you don't care about the data
271that came before the trigger (but the hardware delivers this data to sigrok
272nonetheless).
273.TP
274.BR "\-P, \-\-protocol\-decoders " <list>
275This option allows the user to specify a comma-separated list of protocol
276decoders to be used in this session. The decoders are specified by their
277ID, as shown in the
278.BR "\-L " ( "\-\-list\-supported" ")"
279output.
280.sp
281Example:
282.sp
283 $
284.B "sigrok\-cli \-i <file.sr> \-P i2c"
285.sp
286Each protocol decoder can optionally be followed by a colon-separated list
287of options, where each option takes the form
288.BR "key=value" .
289.sp
290Example:
291.sp
292 $
293.B "sigrok\-cli \-i <file.sr> "
294.br
295.B " \-P uart:baudrate=115200:parity=odd"
296.sp
297The list of supported options depends entirely on the protocol decoder. Every
298protocol decoder has different options it supports.
299.sp
300Any "options" specified for a protocol decoder which are not actually
301supported options, will be interpreted as being channel name/number assignments.
302.sp
303Example:
304.sp
305 $
306.B "sigrok\-cli \-i <file.sr>"
307.br
308.B " \-P spi:wordsize=9:miso=1:mosi=5:clk=3:cs=0"
309.sp
310In this example,
311.B wordsize
312is an option supported by the
313.B spi
314protocol decoder. Additionally, the user requests sigrok to decode the SPI
315protocol using channel 1 as MISO signal for SPI, channel 5 as MOSI, channel 3
316as CLK, and channel 0 as CS# signal.
317.sp
318The
319.B sigrok\-cli
320application can automatically assign logic channels to decoder inputs
321in their strict channel index order (by means of the
322.B auto_index
323keyword), or can automatically assign logic channels to decoder inputs
324when their names match (case insensitive match,
325.B auto_names
326keyword). Users need to explicitly request this assignment, the default
327behaviour is to not automatically assign any signals.
328.sp
329Example:
330.sp
331 $
332.B "sigrok\-cli \-i <file.sr>"
333.br
334.B " \-P ieee488:assign_channels=auto_names"
335.br
336.sp
337When multiple decoders are specified in the same
338.BR -P
339option, they will be stacked on top of each other in the specified order.
340.sp
341Example:
342.sp
343 $
344.B "sigrok\-cli \-i <file.sr> \-P i2c,eeprom24xx"
345.br
346 $
347.B "sigrok\-cli \-i <file.sr> \-P uart:baudrate=31250,midi"
348.sp
349When multiple
350.BR -P
351options are specified, each of them creates one decoder stack, which
352executes in parallel to other decoder stacks.
353.sp
354Example:
355.sp
356 $
357.B "sigrok\-cli \-i <file.sr> \-P uart:tx=D0:rx=D1 \-P timing:data=D2"
358.sp
359.TP
360.BR "\-A, \-\-protocol\-decoder\-annotations " <annotations>
361By default, all annotation output of all protocol decoders is
362shown. With this option a specific decoder's annotations can be selected for
363display, by specifying the decoder ID:
364.sp
365 $
366.B "sigrok\-cli \-i <file.sr> \-P i2c,i2cfilter,edid \-A i2c"
367.sp
368If a protocol decoder has multiple annotation classes, you can also specify
369which one of them to show by specifying its short description like this:
370.sp
371 $
372.B "sigrok\-cli \-i <file.sr> \-P i2c,i2cfilter,edid"
373.br
374.B " \-A i2c=data\-read"
375.sp
376Select multiple annotation classes by separating them with a colon:
377.sp
378 $
379.B "sigrok\-cli \-i <file.sr> \-P i2c,i2cfilter,edid"
380.br
381.B " \-A i2c=data\-read:data\-write"
382.sp
383Annotation row names will resolve to their respective list of classes.
384Row and class names can be used in combination. When names are ambiguous
385then class names take precedence.
386.sp
387 $
388.B "sigrok\-cli \-i <file.sr> \-P i2c"
389.br
390.B " \-A i2c=addr\-data:warnings"
391.sp
392You can also select multiple protocol decoders, with optionally selected
393annotation classes each, by separating them with commas:
394.sp
395 $
396.B "sigrok\-cli \-i <file.sr> \-P i2c,i2cfilter,edid"
397.br
398.B " \-A i2c=data\-read:data\-write,edid"
399.TP
400.BR "\-M, \-\-protocol\-decoder\-meta " <pdname>
401When given, show protocol decoder meta output instead of annotations.
402The argument is the name of the decoder whose meta output to show.
403.sp
404 $
405.B "sigrok\-cli \-i <file.sr> \-M i2c"
406.sp
407Not every decoder generates meta output.
408.TP
409.BR "\-B, \-\-protocol\-decoder\-binary " <binaryspec>
410When given, decoder "raw" data of various kinds is written to stdout instead
411of annotations (this could be raw binary UART/SPI bytes, or WAV files, PCAP
412files, PNG files, or anything else; this is entirely dependent on the
413decoder and what kinds of binary output make sense for that decoder).
414.sp
415No other information is printed to stdout, so this is
416suitable for piping into other programs or saving to a file.
417.sp
418Protocol decoders that support binary output publish a list of binary
419classes, for example the UART decoder might have "TX" and "RX". To
420select TX for output, the argument to this option would be:
421.sp
422 $
423.B "sigrok\-cli \-i <file.sr> \-B uart=tx"
424.br
425.sp
426If only the protocol decoder is specified, without binary class, all classes
427are written to stdout:
428.sp
429 $
430.B "sigrok\-cli \-i <file.sr> \-B uart"
431.sp
432(this is only useful in rare cases, generally you would specify a certain
433binary class you're interested in)
434.sp
435Not every decoder generates binary output.
436.TP
437.BR "\-\-protocol\-decoder\-samplenum
438When given, decoder annotations will include sample numbers, too.
439This allows consumers to receive machine readable timing information.
440.TP
441.BR "\-\-protocol\-decoder\-ann\-class
442When given, decoder annotations will include annotation class names.
443.TP
444.BR "\-\-protocol\-decoder\-jsontrace
445When given, decoder output uses the Google Trace Event format (JSON).
446Which can be inspected in web browsers or other viewers.
447.TP
448.BR "\-l, \-\-loglevel " <level>
449Set the libsigrok and libsigrokdecode loglevel. At the moment \fBsigrok\-cli\fP
450doesn't support setting the two loglevels independently. The higher the
451number, the more debug output will be printed. Valid loglevels are:
452.sp
453\fB0\fP None
454.br
455\fB1\fP Error
456.br
457\fB2\fP Warnings
458.br
459\fB3\fP Informational
460.br
461\fB4\fP Debug
462.br
463\fB5\fP Spew
464.TP
465.B "\-\-show"
466.br
467Show information about the selected option. For example, to see options for a
468connected fx2lafw device:
469.sp
470 $
471.B "sigrok\-cli \-\-driver fx2lafw \-\-show
472.sp
473In order to properly get device options for your hardware, some drivers might
474need a serial port specified:
475.sp
476 $
477.B "sigrok\-cli \-\-driver ols:conn=/dev/ttyACM0 \-\-show
478.sp
479This also works for protocol decoders, input modules and output modules:
480.sp
481 $
482.B "sigrok\-cli \-\-protocol\-decoders i2c \-\-show
483 $
484.B "sigrok\-cli \-\-input\-format csv \-\-show
485 $
486.B "sigrok\-cli \-\-output\-format bits \-\-show
487.sp
488This also works for input files, including optional input format specifications:
489.sp
490 $
491.B "sigrok\-cli \-\-input\-file <file.sr> \-\-show
492 $
493.B "sigrok\-cli \-\-input\-file <file.vcd> \-\-input\-format vcd \-\-show
494.TP
495.B "\-\-scan"
496Scan for devices that can be detected automatically.
497.sp
498Example:
499.sp
500 $
501.B "sigrok\-cli \-\-scan
502.br
503 The following devices were found:
504.br
505 demo \- Demo device with 12 channels: D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3
506.br
507 fx2lafw:conn=3.26 \- CWAV USBee SX with 8 channels: 0 1 2 3 4 5 6 7
508.sp
509However, not all devices are auto-detectable (e.g. serial port based ones).
510For those you'll have to provide a \fBconn\fP option, see above.
511.sp
512 $
513.B "sigrok\-cli \-\-driver digitek\-dt4000zc:conn=/dev/ttyUSB0 \-\-scan
514.br
515 The following devices were found:
516.br
517 Digitek DT4000ZC with 1 channel: P1
518.TP
519.BR "\-\-time " <ms>
520Sample for
521.B <ms>
522milliseconds, then quit.
523.sp
524You can optionally follow the number by \fBs\fP to specify the time to
525sample in seconds.
526.sp
527For example,
528.B "\-\-time 2s"
529will sample for two seconds.
530.TP
531.BR "\-\-samples " <numsamples>
532Acquire
533.B <numsamples>
534samples, then quit.
535.sp
536You can optionally follow the number by \fBk\fP, \fBm\fP, or \fBg\fP to
537specify the number of samples in kilosamples, megasamples, or gigasamples,
538respectively.
539.sp
540For example,
541.B "\-\-samples 3m"
542will acquire 3000000 samples.
543.TP
544.BR "\-\-frames " <numframes>
545Acquire
546.B <numframes>
547frames, then quit.
548.TP
549.BR "\-\-continuous"
550Sample continuously until stopped. Not all devices support this.
551.TP
552.BR "\-\-get " <variable>
553Get the value of
554.B <variable>
555from the specified device and print it.
556Multiple variable names can be specified and get separated by colon.
557The list of variable names optionally can be preceeded by
558.B "channel_group=<name>"
559which would override the
560.B \-\-channel\-group
561specification.
562Multiple
563.B \-\-get
564occurances are supported in a single
565.B sigrok\-cli
566invocation.
567.sp
568 $
569.B sigrok\-cli \-d demo \-\-get samplerate:averaging \-\-get channel_group=Logic:pattern
570.TP
571.BR "\-\-set"
572Set one or more variables specified with the \fB\-\-config\fP option, without
573doing any acquisition.
574.SH EXAMPLES
575In order to get exactly 100 samples from the connected fx2lafw-supported logic
576analyzer hardware, run the following command:
577.TP
578.B " sigrok\-cli \-\-driver fx2lafw \-\-samples 100"
579.TP
580If you want to sample data for 3 seconds (3000 ms), use:
581.TP
582.B " sigrok\-cli \-\-driver fx2lafw \-\-time 3000"
583.TP
584Alternatively, you can also use:
585.TP
586.B " sigrok\-cli \-\-driver fx2lafw \-\-time 3s"
587.TP
588To capture data from the first 4 channels using the Openbench Logic Sniffer lasting 100ms at 10 MHz starting at the trigger condition
5890:high, 1:rising, 2:low, 3:high, use:
590.TP
591.nf
592\fBsigrok\-cli \-\-driver ols:conn=/dev/ttyACM0 \-\-config samplerate=10m \\\fP
593\fB\-\-output\-format bits \-\-channels 0\-3 \-\-wait\-trigger \\\fP
594\fB\-\-triggers 0=1,1=r,2=0,3=1 \-\-time 100\fP
595.TP
596To turn on internal logging on a Lascar EL-USB series device:
597.TP
598\fBsigrok\-cli \-\-driver lascar\-el\-usb:conn=10c4.0002 \\\fP
599\fB\-\-config datalog=on \-\-set\fP
600.SH "EXIT STATUS"
601.B sigrok\-cli
602exits with 0 on success, 1 on most failures.
603.SH "ENVIRONMENT"
604.TP
605.B SIGROK_FIRMWARE_DIR
606A single path where to search for firmware images, in addition to a
607builtin list of locations.
608.TP
609.B SIGROK_FIRMWARE_PATH
610Multiple path entries where to search for firmware images, in addition
611to builtin locations.
612.TP
613When decoder support was enabled in the application's configuration:
614.TP
615.B SIGROKDECODE_DIR
616A single path where to search for protocol decoders, in addition to
617a builtin list of locations.
618.TP
619.B SIGROKDECODE_PATH
620Multiple path entries where to search for protocol decoders, in addition
621to builtin locations.
622.SH "SEE ALSO"
623\fBpulseview\fP(1)
624.SH "BUGS"
625Please report any bugs via Bugzilla
626.RB "(" http://sigrok.org/bugzilla ")"
627or on the sigrok\-devel mailing list
628.RB "(" sigrok\-devel@lists.souceforge.net ")."
629.SH "LICENSE"
630.B sigrok\-cli
631is covered by the GNU General Public License (GPL). Some portions are
632licensed under the "GPL v2 or later", some under "GPL v3 or later".
633.SH "AUTHORS"
634Please see the individual source code files.
635.PP
636This manual page was written by Uwe Hermann <uwe@hermann\-uwe.de>.
637It is licensed under the terms of the GNU GPL (version 2 or later).