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