]> sigrok.org Git - sigrok-cli.git/blame - doc/sigrok-cli.1
doc: discuss protocol decoder stacks in the manpage
[sigrok-cli.git] / doc / sigrok-cli.1
CommitLineData
7c765fcb 1.TH SIGROK\-CLI 1 "September 13, 2017"
43e5747a 2.SH "NAME"
53155b2f 3sigrok\-cli \- Command-line client for the sigrok software
43e5747a 4.SH "SYNOPSIS"
53155b2f 5.B sigrok\-cli [OPTIONS] [COMMAND]
43e5747a 6.SH "DESCRIPTION"
10d98b47
UH
7\fBsigrok\-cli\fP is a cross-platform command line utility for the
8\fBsigrok\fP software.
43e5747a 9.PP
10d98b47
UH
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.
43e5747a
UH
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.
53155b2f 17.SH OPTIONS
43e5747a 18.TP
43e5747a
UH
19.B "\-h, \-\-help"
20Show a help text and exit.
21.TP
7949dca0
UH
22.B "\-V, \-\-version"
23Show
24.B sigrok-cli
6293db8a
UH
25version and the versions of libraries used.
26.TP
27.B "\-L, \-\-list-supported"
28Show information about supported hardware drivers, input file
7949dca0
UH
29formats, output file formats, and protocol decoders.
30.TP
b5ac81ad
BV
31\fB\-d, \-\-driver\fP <drivername>
32A driver must always be selected (unless doing a global scan). Use the
c1865eb5
UH
33.BR "\-L " ( "\-\-list-supported" ")"
34option to get a list of available drivers.
53155b2f 35.sp
10d98b47
UH
36Drivers can take options, in the form \fBkey=value\fP
37separated by colons.
38.sp
39Drivers communicating with hardware via a serial port always need the port
40specified as the \fBconn\fP option. For example, to use the
41Openbench Logic Sniffer:
53155b2f
BV
42.sp
43.RB " $ " "sigrok\-cli \-\-driver=ols:conn=/dev/ttyACM0"
44.sp
10d98b47
UH
45Some USB devices don't use a unique VendorID/ProductID combination, and thus
46need that specified as well. This also uses the \fBconn\fP option, using
47either \fBVendorID.ProductID\fP or \fBbus.address\fP:
53155b2f 48.sp
bf836932 49.RB " $ " "sigrok\-cli \-\-driver=uni-t-ut61e:conn=1a86.e008"
43e5747a 50.TP
b5ac81ad 51.BR "\-c, \-\-config " <device>
53155b2f 52A colon-separated list of device options, where each option takes the form
1b4b6a7c 53.BR key=value .
10d98b47
UH
54For example, to set the samplerate to 1MHz on a device supported by the
55fx2lafw driver, you might specify
1b4b6a7c 56.sp
b5ac81ad 57.RB " $ " "sigrok\-cli \-\-driver=fx2lafw \-\-config samplerate=1m"
1b4b6a7c 58.sp
53155b2f
BV
59Samplerate is an option common to most logic analyzers. The argument specifies
60the samplerate in Hz. You can also specify the samplerate in kHz, MHz or GHz.
1b4b6a7c
UH
61The following are all equivalent:
62.sp
b5ac81ad 63.RB " $ " "sigrok\-cli \-\-driver fx2lafw \-\-config samplerate=1000000"
1b4b6a7c 64.sp
b5ac81ad 65.RB " $ " "sigrok\-cli \-\-driver fx2lafw \-\-config samplerate=1m"
1b4b6a7c 66.sp
b5ac81ad 67.RB " $ " "sigrok\-cli \-\-driver fx2lafw \-\-config \(dqsamplerate=1 MHz\(dq"
1b4b6a7c 68.TP
43e5747a 69.BR "\-i, \-\-input\-file " <filename>
7949dca0 70Load input from a file instead of a hardware device. If the
43e5747a
UH
71.B \-\-input\-format
72option is not supplied, sigrok-cli attempts to autodetect the file format of
73the input file.
74.TP
75.BR "\-I, \-\-input\-format " <format>
76When loading an input file, assume it's in the specified format. If this
77option is not supplied (in addition to
78.BR \-\-input\-file ),
943d0c08 79sigrok-cli attempts to autodetect the file format of the input file. Use the
c1865eb5 80.BR "\-L " ( "\-\-list-supported" ")"
10d98b47
UH
81option to see a list of available input formats.
82.sp
83The format name may optionally be followed by a colon-separated list of
84options, where each option takes the form
943d0c08 85.BR "key=value" .
43e5747a
UH
86.TP
87.BR "\-o, \-\-output\-file " <filename>
88Save output to a file instead of writing it to stdout. The default format
89used when saving is the sigrok session file format. This can be changed with
90the
76ae913d 91.B \-\-output\-format
7949dca0
UH
92option.
93.TP
94.BR "\-O, \-\-output\-format " <formatname>
95Set the output format to use. Use the
c1865eb5 96.BR "\-L " ( "\-\-list-supported" ")"
10d98b47
UH
97option to see a list of available output formats.
98.sp
99The format name may optionally be followed by a colon-separated list of
100options, where each option takes the form
7949dca0
UH
101.BR "key=value" .
102.sp
c1865eb5 103For example, the
7949dca0
UH
104.B bits
105or
106.B hex
107formats, 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
108.B hex:width=128
109will display 128 bits per line, in hexadecimal:
110.sp
10d98b47
UH
111 0:ffff ffff ffff ffff ffff ffff ffff ffff
112 1:ff00 ff00 ff00 ff00 ff00 ff00 ff00 ff00
7949dca0 113.sp
029d73fe 114The lines always start with the channel number (or name, if defined), followed by a colon. If no format is specified, it defaults to
7949dca0
UH
115.BR bits:width=64 ,
116like this:
117.sp
10d98b47
UH
118 0:11111111 11111111 11111111 11111111 [...]
119 1:11111111 00000000 11111111 00000000 [...]
43e5747a 120.TP
3dfbfbc8 121.BR "\-C, \-\-channels " <channellist>
029d73fe 122A comma-separated list of channels to be used in the session.
43e5747a 123.sp
029d73fe
UH
124Note that sigrok always names the channels according to how they're shown on
125the enclosure of the hardware. If your logic analyzer numbers the channels 0-15,
126that's how you must specify them with this option. An oscilloscope's channels
10d98b47 127would generally be referred to as "CH1", "CH2", and so on.
029d73fe 128Use the \fB\-\-show\fP option to see a list of channel names for your device.
53155b2f 129.sp
029d73fe
UH
130The default is to use all the channels available on a device. You can name
131a channel like this:
43e5747a 132.BR "1=CLK" .
029d73fe 133A range of channels can also be given, in the form
43e5747a
UH
134.BR "1\-5" .
135.sp
136Example:
137.sp
10d98b47
UH
138.RB " $ " "sigrok\-cli \-\-driver fx2lafw \-\-samples 100"
139.br
3dfbfbc8 140.B " \-\-channels 1=CLK,2\-4,7"
43e5747a
UH
141.br
142 CLK:11111111 11111111 11111111 11111111 [...]
143 2:11111111 11111111 11111111 11111111 [...]
144 3:11111111 11111111 11111111 11111111 [...]
145 4:11111111 11111111 11111111 11111111 [...]
146 7:11111111 11111111 11111111 11111111 [...]
147.sp
148The comma-separated list is processed from left to right, i.e. items farther
149to the right override previous items. For example
bf836932 150.B "1=CS,CS=MISO"
029d73fe 151will set the name of channel 1 to
43e5747a 152.BR "MISO" .
43e5747a 153.TP
ca50f4b3
UH
154.BR "\-g, \-\-channel\-group "<channel\ group>
155Specify the channel group to operate on.
31f9318a 156
ca50f4b3
UH
157Some devices organize channels into groups, the settings of which can
158only be changed as a group. The list of channel groups, if any, is displayed
bf836932 159with the \fB\-\-show\fP command.
31f9318a 160.TP
43e5747a
UH
161.BR "\-t, \-\-triggers " <triggerlist>
162A comma-separated list of triggers to use, of the form
029d73fe
UH
163.BR "<channel>=<trigger>" .
164You can use the name or number of the channel, and the trigger itself is a
43e5747a
UH
165series of characters:
166.sp
167.BR "0 or 1" :
168A low or high value on the pin.
169.br
170.BR "r or f" :
171A rising or falling value on the pin. An
172.B r
173effectively corresponds to
174.BR 01 .
175.br
f99038b4 176.BR "e" :
85f2ddbb 177Any kind of change on a pin (either a rising or a falling edge).
43e5747a 178.sp
10d98b47
UH
179Not every device supports all of these trigger types. Use the \fB\-\-show\fP
180command to see which triggers your device supports.
43e5747a
UH
181.TP
182.BR "\-w, \-\-wait-trigger"
10d98b47
UH
183Don't output any sample data (even if it's actually received from the
184hardware) before the trigger condition is met. In other words, do not output
185any pre-trigger data. This option is useful if you don't care about the data
186that came before the trigger (but the hardware delivers this data to sigrok
187nonetheless).
43e5747a 188.TP
b5ac81ad 189.BR "\-P, \-\-protocol\-decoders " <list>
85f2ddbb
UH
190This option allows the user to specify a comma-separated list of protocol
191decoders to be used in this session. The decoders are specified by their
192ID, as shown in the
c1865eb5 193.BR "\-L " ( "\-\-list-supported" ")"
85f2ddbb
UH
194output.
195.sp
196Example:
197.sp
198 $
b5ac81ad 199.B "sigrok\-cli \-i <file.sr> \-P i2c"
85f2ddbb
UH
200.sp
201Each protocol decoder can optionally be followed by a colon-separated list
202of options, where each option takes the form
203.BR "key=value" .
204.sp
205Example:
206.sp
207 $
8791df07
UH
208.B "sigrok\-cli \-i <file.sr> "
209.br
210.B " \-P uart:baudrate=115200:parity_type=odd"
85f2ddbb
UH
211.sp
212The list of supported options depends entirely on the protocol decoder. Every
213protocol decoder has different options it supports.
214.sp
215Any "options" specified for a protocol decoder which are not actually
029d73fe 216supported options, will be interpreted as being channel name/number assignments.
85f2ddbb
UH
217.sp
218Example:
219.sp
220 $
221.B "sigrok\-cli \-i <file.sr>"
222.br
bf836932 223.B " \-P spi:wordsize=9:miso=1:mosi=5:clk=3:cs=0"
85f2ddbb
UH
224.sp
225In this example,
226.B wordsize
227is an option supported by the
228.B spi
229protocol decoder. Additionally, the user tells sigrok to decode the SPI
029d73fe 230protocol using channel 1 as MISO signal for SPI, channel 5 as MOSI, channel 3
bf836932 231as CLK, and channel 0 as CS# signal.
e4b7762f
GS
232.br
233.sp
234When multiple decoders are specified in the same
235.BR -P
236option, they will be stacked on top of each other in the specified order.
237.sp
238Example:
239.sp
240 $
241.B "sigrok\-cli \-i <file.sr> \-P i2c,eeprom24xx"
242.br
243 $
244.B "sigrok\-cli \-i <file.sr> \-P uart:baudrate=31250,midi"
245.sp
246When multiple
247.BR -P
248options are specified, each of them creates one decoder stack, which
249executes in parallel to other decoder stacks.
250.sp
251Example:
252.sp
253 $
254.B "sigrok\-cli \-i <file.sr> \-P uart:tx=D0:rx=D1 \-P timing:data=D2"
255.sp
85f2ddbb 256.TP
b6bd032d 257.BR "\-A, \-\-protocol\-decoder\-annotations " <annotations>
7fb87027
BV
258By default, only the stack's topmost protocol decoder's annotation output is
259shown. With this option another decoder's annotation can be selected for
1a0be0e3 260display, by specifying its ID:
7fb87027
BV
261.sp
262 $
b5ac81ad 263.B "sigrok\-cli \-i <file.sr> \-P i2c,i2cfilter,edid -A i2c"
7fb87027 264.sp
790b0261
BV
265If a protocol decoder has multiple annotations, you can also specify
266which one of them to show by specifying its short description like this:
7fb87027
BV
267.sp
268 $
b5ac81ad 269.B "sigrok\-cli \-i <file.sr> \-P i2c,i2cfilter,edid"
7fb87027 270.br
790b0261
BV
271.B " \-A i2c=data-read"
272.sp
273Select multiple annotations by separating them with a colon:
274.sp
275 $
276.B "sigrok\-cli \-i <file.sr> \-P i2c,i2cfilter,edid"
277.br
278.B " \-A i2c=data-read:data-write"
7fb87027
BV
279.sp
280You can also select multiple protocol decoders, with an optional selected
790b0261 281annotation each, by separating them with commas:
7fb87027
BV
282.sp
283 $
b5ac81ad 284.B "sigrok\-cli \-i <file.sr> \-P i2c,i2cfilter,edid"
7fb87027 285.br
790b0261 286.B " \-A i2c=data-read:data-write,edid"
7fb87027 287.TP
b0f1c540
BV
288.BR "\-M, \-\-protocol\-decoder\-meta " <pdname>
289When given, show protocol decoder meta output instead of annotations.
290The argument is the name of the decoder whose meta output to show.
291.sp
292 $
293.B "sigrok\-cli \-i <file.sr> \-M i2c"
294.sp
295Not every decoder generates meta output.
296.TP
297.BR "\-B, \-\-protocol\-decoder\-binary " <binaryspec>
298When given, decoder "raw" data of various kinds is written to stdout instead
299of annotations (this could be raw binary UART/SPI bytes, or WAV files, PCAP
300files, PNG files, or anything else; this is entirely dependent on the
301decoder and what kinds of binary output make sense for that decoder).
302.sp
303No other information is printed to stdout, so this is
304suitable for piping into other programs or saving to a file.
305.sp
306Protocol decoders that support binary output publish a list of binary
307classes, for example the UART decoder might have "TX" and "RX". To
308select TX for output, the argument to this option would be:
309.sp
310 $
311.B "sigrok\-cli \-i <file.sr> \-B uart=tx"
312.br
313.sp
314If only the protocol decoder is specified, without binary class, all classes
315are written to stdout:
316.sp
317 $
318.B "sigrok\-cli \-i <file.sr> \-B uart"
319.sp
320(this is only useful in rare cases, generally you would specify a certain
321binary class you're interested in)
322.sp
323Not every decoder generates binary output.
324.TP
8aafb57c
GS
325.BR "\-\-protocol\-decoder\-samplenum
326When given, decoder annotations will include sample numbers, too.
327This allows consumers to receive machine readable timing information.
328.TP
53155b2f 329.BR "\-l, \-\-loglevel " <level>
10d98b47
UH
330Set the libsigrok and libsigrokdecode loglevel. At the moment \fBsigrok-cli\fP
331doesn't support setting the two loglevels independently. The higher the
53155b2f
BV
332number, the more debug output will be printed. Valid loglevels are:
333.sp
334\fB0\fP None
335.br
336\fB1\fP Error
337.br
338\fB2\fP Warnings
339.br
340\fB3\fP Informational
341.br
342\fB4\fP Debug
343.br
344\fB5\fP Spew
345.TP
346.B "\-\-show"
347.br
10d98b47
UH
348Show information about the selected option. For example, to see options for a
349connected fx2lafw device:
53155b2f
BV
350.sp
351 $
352.B "sigrok\-cli \-\-driver fx2lafw \-\-show
353.sp
10d98b47
UH
354In order to properly get device options for your hardware, some drivers might
355need a serial port specified:
53155b2f
BV
356.sp
357 $
358.B "sigrok\-cli \-\-driver ols:conn=/dev/ttyACM0 \-\-show
359.sp
a8b4041a 360This also works for protocol decoders, input modules and output modules:
53155b2f
BV
361.sp
362 $
ad6520c4
BV
363.B "sigrok\-cli \-\-protocol\-decoders i2c \-\-show
364 $
a8b4041a
BV
365.B "sigrok\-cli \-\-input\-format csv \-\-show
366 $
ad6520c4 367.B "sigrok\-cli \-\-output\-format bits \-\-show
53155b2f 368.TP
b5ac81ad
BV
369.B "\-\-scan"
370Scan for devices that can be detected automatically.
10d98b47
UH
371.sp
372Example:
373.sp
374 $
b5ac81ad 375.B "sigrok\-cli \-\-scan
10d98b47
UH
376.br
377 The following devices were found:
378.br
bf836932 379 demo - Demo device with 12 channels: D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3
10d98b47 380.br
bf836932 381 fx2lafw:conn=3.26 - CWAV USBee SX with 8 channels: 0 1 2 3 4 5 6 7
10d98b47
UH
382.sp
383However, not all devices are auto-detectable (e.g. serial port based ones).
384For those you'll have to provide a \fBconn\fP option, see above.
385.sp
386 $
b5ac81ad 387.B "sigrok\-cli \-\-driver digitek-dt4000zc:conn=/dev/ttyUSB0 \-\-scan
10d98b47
UH
388.br
389 The following devices were found:
390.br
029d73fe 391 Digitek DT4000ZC with 1 channel: P1
53155b2f 392.TP
43e5747a
UH
393.BR "\-\-time " <ms>
394Sample for
395.B <ms>
10d98b47
UH
396milliseconds, then quit.
397.sp
bf836932
UH
398You can optionally follow the number by \fBs\fP to specify the time to
399sample in seconds.
10d98b47
UH
400.sp
401For example,
43e5747a
UH
402.B "\-\-time 2s"
403will sample for two seconds.
404.TP
405.BR "\-\-samples " <numsamples>
406Acquire
407.B <numsamples>
408samples, then quit.
10d98b47
UH
409.sp
410You can optionally follow the number by \fBk\fP, \fBm\fP, or \fBg\fP to
411specify the number of samples in kilosamples, megasamples, or gigasamples,
412respectively.
413.sp
414For example,
415.B "\-\-samples 3m"
416will acquire 3000000 samples.
43e5747a 417.TP
66d5560b
UH
418.BR "\-\-frames " <numframes>
419Acquire
420.B <numframes>
421frames, then quit.
422.TP
43e5747a
UH
423.BR "\-\-continuous"
424Sample continuously until stopped. Not all devices support this.
2d73284e 425.TP
62a64762
BV
426.BR "\-\-get " <variable>
427Get the value of
428.B <variable>
429from the specified device and print it.
430.TP
2d73284e 431.BR "\-\-set"
b8656921
UH
432Set one or more variables specified with the \fB\-\-config\fP option, without
433doing any acquisition.
53155b2f 434.SH EXAMPLES
b8656921
UH
435In order to get exactly 100 samples from the connected fx2lafw-supported logic
436analyzer hardware, run the following command:
43e5747a 437.TP
53155b2f 438.B " sigrok\-cli \-\-driver fx2lafw \-\-samples 100"
43e5747a 439.TP
2d73284e 440If you want to sample data for 3 seconds (3000 ms), use:
43e5747a 441.TP
53155b2f 442.B " sigrok\-cli \-\-driver fx2lafw \-\-time 3000"
43e5747a
UH
443.TP
444Alternatively, you can also use:
445.TP
53155b2f 446.B " sigrok\-cli \-\-driver fx2lafw \-\-time 3s"
43e5747a 447.TP
029d73fe 448To capture data from the first 4 channels using the Openbench Logic Sniffer lasting 100ms at 10 MHz starting at the trigger condition
53155b2f 4490:high, 1:rising, 2:low, 3:high, use:
43e5747a 450.TP
53155b2f 451.nf
b5ac81ad 452\fBsigrok\-cli \-\-driver ols:conn=/dev/ttyACM0 \-\-config samplerate=10m \\\fP
3dfbfbc8 453\fB\-\-output\-format bits \-\-channels 0\-3 \-\-wait\-trigger \\\fP
b5ac81ad 454\fB\-\-triggers 0=1,1=r,2=0,3=1 \-\-time 100\fP
2d73284e
BV
455.TP
456To turn on internal logging on a Lascar EL-USB series device:
457.TP
458\fBsigrok\-cli \-\-driver lascar\-el\-usb:conn=10c4.0002 \\\fP
b8656921 459\fB\-\-config datalog=on \-\-set\fP
43e5747a
UH
460.SH "EXIT STATUS"
461.B sigrok\-cli
462exits with 0 on success, 1 on most failures.
463.SH "SEE ALSO"
b5ac81ad 464\fBpulseview\fP(1)
43e5747a 465.SH "BUGS"
10d98b47
UH
466Please report any bugs via Bugzilla
467.RB "(" http://sigrok.org/bugzilla ")"
468or on the sigrok\-devel mailing list
43e5747a
UH
469.RB "(" sigrok\-devel@lists.souceforge.net ")."
470.SH "LICENSE"
471.B sigrok\-cli
472is covered by the GNU General Public License (GPL). Some portions are
473licensed under the "GPL v2 or later", some under "GPL v3 or later".
474.SH "AUTHORS"
475Please see the individual source code files.
476.PP
477This manual page was written by Uwe Hermann <uwe@hermann\-uwe.de>.
478It is licensed under the terms of the GNU GPL (version 2 or later).