]> sigrok.org Git - sigrok-cli.git/log
sigrok-cli.git
20 months agoparsers: use common library code to rename sigrok channels
Gerhard Sittig [Tue, 16 Aug 2022 20:14:23 +0000 (22:14 +0200)]
parsers: use common library code to rename sigrok channels

Drop an open coded g_free() and g_strdup() sequence which accesses
internal details of a sigrok channel. Use the sr_dev_channel_name_set()
library routine instead.

23 months agoparsers: use proper conversion routine for PD option data types
Gerhard Sittig [Sat, 23 Apr 2022 19:31:06 +0000 (21:31 +0200)]
parsers: use proper conversion routine for PD option data types

The generic_arg_to_opt() routine converted text input to protocol
decoder option values, but might have lost significant information.
Use a signed conversion routine for the int32 data, use a long long
routine for uint64 data. This shall unbreak negative values (like
UART packet separators), and improve compatibility with 32bit targets
(like for large sample numbers or high frequency values).

23 months agoinput: emit diagnostics when file import fails fatally
Gerhard Sittig [Sat, 23 Apr 2022 19:28:23 +0000 (21:28 +0200)]
input: emit diagnostics when file import fails fatally

The previous implementation did terminate the file import upon fatal
errors, but did so silently. Add diagnostics to the code paths where
input module's .send() calls or channel selection fail. This raises
awareness when an individual input module would fail and not warn.

23 months agoinput: minor robustness improvement, close fd leak
Gerhard Sittig [Sat, 23 Apr 2022 19:25:35 +0000 (21:25 +0200)]
input: minor robustness improvement, close fd leak

Eliminate redundant CHUNK_SIZE references, just fill the GString buffer
as far as it was allocated no matter how. Call an input related free
routine for options, not the output routine (which happened to work by
coincidence, thus went unnoticed). Close the input file descriptor after
the read loop, the caller has got no reference to it.

23 months agoinput: unbreak automatic format detection when reading from stdin
Gerhard Sittig [Thu, 7 Apr 2022 21:12:34 +0000 (23:12 +0200)]
input: unbreak automatic format detection when reading from stdin

The combination of reading from stdin and automatic file format match
could result in the execution of an input module's .end() callback
before its .receive() ever executed. Which then suffers from an sdi
which is not yet ready, and no data was sent to the sigrok session.
Fix that.

Unfortunately the input module's accumulator is hidden behind the
libsigrok API. That's why applications cannot defer the forwarding
of the first data chunk from the input file. Insert a .receive() call
with a zero length instead before more file content is consumed. All
existing input modules are prepared to handle this call sequence.

2 years agodoc: update uart decoder options example in sigrok-cli(1) manpage
Gerhard Sittig [Tue, 22 Feb 2022 22:06:36 +0000 (23:06 +0100)]
doc: update uart decoder options example in sigrok-cli(1) manpage

Catch up with renamed UART decoder options.

Reported-By: <redacted> via IRC
2 years agoshow: use getter result to determine "current" presence (voltage range)
Gerhard Sittig [Sun, 6 Feb 2022 20:32:28 +0000 (21:32 +0100)]
show: use getter result to determine "current" presence (voltage range)

Improve the condition which presents the "(current)" decoration when
voltage ranges are listed in --show output. Use an explicit boolean
which is derived from the config getter's return code. Avoid "forcing"
a comparison against a zero value, which can be a valid item in the list
of supported voltages.

This is similar to commit 0171a4a7a49f. See more context (-U10) for the
motivation of the change. Was observed with the kingst-la2016 driver.

2 years agosession: optionally send EOF to decoder session
Gerhard Sittig [Sun, 26 Dec 2021 06:52:59 +0000 (07:52 +0100)]
session: optionally send EOF to decoder session

Communicate EOF to the decoder session (when the library supports it).

2 years agoconfigure: check version dependent sigrokdecode features
Gerhard Sittig [Sun, 26 Dec 2021 06:51:14 +0000 (07:51 +0100)]
configure: check version dependent sigrokdecode features

Check for the presence of the srd_session_send_eof() API routine which
depends on the libsigrokdecode library version.

2 years agoshow: Format channel output when no channel is available
Frank Stettner [Sun, 15 Aug 2021 16:30:03 +0000 (18:30 +0200)]
show: Format channel output when no channel is available

2 years agodoc: update IRC reference to Libera.Chat
Gerhard Sittig [Wed, 16 Jun 2021 18:52:19 +0000 (20:52 +0200)]
doc: update IRC reference to Libera.Chat

3 years agoshow: Only use decoder tags if they're available.
Uwe Hermann [Wed, 24 Feb 2021 20:21:37 +0000 (21:21 +0100)]
show: Only use decoder tags if they're available.

This allows us to reduce the libsigrokdecode requirement back to >= 0.5.0,
i.e. we don't strictly need libsigrokdecode >= 0.6.0.

3 years agonsis: Fix for installing 64bit Windows programs into 'Program Files'
xorloser [Thu, 10 Sep 2020 05:36:40 +0000 (15:36 +1000)]
nsis: Fix for installing 64bit Windows programs into 'Program Files'

This fixes bug #1082.

3 years agodoc: update manpage for channel groups in --get/--config options
Gerhard Sittig [Tue, 4 Aug 2020 16:44:17 +0000 (18:44 +0200)]
doc: update manpage for channel groups in --get/--config options

3 years agoaccept multiple --get requests for multiple channel groups
Gerhard Sittig [Sat, 23 May 2020 13:46:35 +0000 (15:46 +0200)]
accept multiple --get requests for multiple channel groups

Extend the user interface. Accept multiple --get specs which each can query
multiple parameters from a channel group, and optionally can select the
channel group (including the device itself) in their first item. Support
the -g selection for backwards compatibility and/or convenience.

3 years agoaccept multiple --config requests for multiple channel groups
Gerhard Sittig [Sat, 23 May 2020 11:10:14 +0000 (13:10 +0200)]
accept multiple --config requests for multiple channel groups

The previous UI implementation supported the selection of a channel
group, and defaulted to the device's global options. This let users
either manipulate global or a single channel group's parmeters.

Extend the user interface. Accept multiple -c specs. Apply the remaining
key-value pairs to the channel group which optionally can get specified
in the first item of a -c spec. This lets users modify several channel
groups' parameters in a single program invocation, including arbitrary
combinations including the device's global parameters.

This extension is completely backwards compatible. When a -c spec lacks
a 'channel_group=' item, then the -g spec is used, which defaults to the
global parameters.

Either an empty string or the 'global' literal can be used to select the
global parameters. Several -c specs can select the same channel group.
This can be useful when command lines get generated by other programs.

3 years agoparsers: rephrase option key/value parsing some more
Gerhard Sittig [Sat, 23 May 2020 13:14:58 +0000 (15:14 +0200)]
parsers: rephrase option key/value parsing some more

Move the key-value pair separation to a subroutine to avoid redundancy
in other locations. Which simplifies the "optional ID" code path as a
byproduct. Drop comments which repeat the routine's doxygen content.
Keep hash insertion text lines short by moving string allocation to a
separate instruction (which rephrases how empty right hand sides are
handled for key-only specs).

3 years agoparsers: extend options parser, support optional ID in key-value lists
Gerhard Sittig [Sat, 23 May 2020 09:29:23 +0000 (11:29 +0200)]
parsers: extend options parser, support optional ID in key-value lists

The options parser accepts a colon separated list of key-value pairs, and
a special case where the first item is not a pair but a single word which
is an identifier. This lets users select a device driver, or input/output
format, or decoder.

Extend the options parser to also support an optional identifier as the
first item in a list of key-value pairs. Check the first item's keyword
for a caller specified literal. This change remains backwards compatible
(does not affect behaviour) when users don't pass the special keyword.

3 years agomain: terminate with error when -B was specified but -P is missing
Gerhard Sittig [Wed, 4 Jul 2018 17:55:58 +0000 (19:55 +0200)]
main: terminate with error when -B was specified but -P is missing

This fixes bug #1180.

3 years agoparsers: warn about unknown input/output module option keys
Gerhard Sittig [Fri, 29 May 2020 08:07:05 +0000 (10:07 +0200)]
parsers: warn about unknown input/output module option keys

Misspelled option names fail silently, the setting won't take effect and
the user won't notice.

  $ echo "1, 0" | sigrok-cli -I csv:header=no:column_format=t,l -i -

Check whether specified input/output module options are supported, emit
warnings when they are not. It's a design choice to raise awareness yet
make mismatches non-fatal. This can be useful for generated command lines
or during a period of migration after UI changes.

The implementation is prepared for optional call site specific captions in
diagnostics messages. Callers can either have messages generated by common
code, or handle the list of unavailable words themselves, or have common
code emit warnings and in addition take extra actions. It's also trivial
to make mismatches fatal should the need arise.

This resolves the sigrok-cli part of bug #1549. Also addresses brace style
nits in bypassing.

3 years agodevice: rename channel group lookup routine
Gerhard Sittig [Sat, 23 May 2020 10:48:18 +0000 (12:48 +0200)]
device: rename channel group lookup routine

The select_channel_group() name was misleading, the routine did not
actively select a channel group, instead returned the lookup result
and left the activity to the caller. Rename the routine to improve
readability of call sites.

Address minor style nits in the routine body while we are here.

3 years agodecode: shuffle order of JSON trace fields for readability
Gerhard Sittig [Sat, 25 Jul 2020 11:07:20 +0000 (13:07 +0200)]
decode: shuffle order of JSON trace fields for readability

Use a similar order of JSON trace fields as other modes of annotation
output do. This increases readability for humans by moving timestamps
and decoder IDs to the left, and keeping the annotation text at the
right hand side with nothing else following it, and at a constant text
position (somewhat, depending on how timing numbers align, and how
several annotation rows interleave).

3 years agodecode: concentrate JSON formatting in a single location
Gerhard Sittig [Sat, 25 Jul 2020 10:05:02 +0000 (12:05 +0200)]
decode: concentrate JSON formatting in a single location

It's incredible how a single arbitrary choice of not supporting trailing
commas complicates generator code which immediately writes its output,
instead of accumulating pieces and separating but not terminating them
before transmitting the result.

Concentrate all text to open and close the file and array items, as well
as to separate the array item fields, in the jsontrace_open_close()
routine. This makes calling code more verbose, but heavily simplifies
the sequence and allows to shuffle items without unnecessary manual
adjustment of formatting details. Added complexity to make some of the
closing calls optional also helps.

When this DIY code is considered unmaintainable, the alternative is to
introduce another dependency on a JSON library.

3 years agodecode: add support for Google Trace Event output (JSON)
Gerhard Sittig [Sat, 25 Jul 2020 07:28:40 +0000 (09:28 +0200)]
decode: add support for Google Trace Event output (JSON)

Introduce the --protocol-decoder-jsontrace command line option, which
outputs protocol decoder annotations in the Google Trace Event format.
Resulting files can be viewed by means of the chrome://tracing URL in
the Chrome browser (optionally zipped).

Example use:
  $ sigrok-cli -i $F -P uart -A uart=rx-data --protocol-decoder-jsontrace

The initial implementation was
Submitted-By: Dave Craig <redacted>
This commit introduces generic prepare and close support, should other
output formats need to flush previously accumulated data, or defer the
creation of a header and make sure to add a footer around the sequence
of annotations.

3 years agodecode: start collecting internal state (samplerate)
Gerhard Sittig [Sat, 25 Jul 2020 07:25:51 +0000 (09:25 +0200)]
decode: start collecting internal state (samplerate)

Introduce variables which hold the internal state during decoder
operation so far. Start by adding a "samplerate used by protocol
decoders". This is motivated by the pending Google Trace Event
feature addition.

3 years agoshow: do print floating point results even if value is zero
Gerhard Sittig [Sat, 23 May 2020 14:14:48 +0000 (16:14 +0200)]
show: do print floating point results even if value is zero

The availability of a configuration value with floating point data type
was determined by checking its value for being zero. Which prevents the
display of valid data. See the 'offset' in this example:

  $ sigrok-cli -d demo -g Analog --show

Track the current value's availability in a boolean variable. Do print
values even if they are zero.

3 years agoshow: mark currently selected samplerate item in samplerates lists
Gerhard Sittig [Sun, 10 May 2020 17:40:38 +0000 (19:40 +0200)]
show: mark currently selected samplerate item in samplerates lists

Get the current value as well as the list for SR_CONF_SAMPLERATE keys,
and add the "(current)" marker to a list item when a match was found.

  $ sigrok-cli -d fx2lafw --show

4 years agodecode: add sanity check when mapping channels
Wolfram Sang [Tue, 7 Apr 2020 22:31:32 +0000 (00:31 +0200)]
decode: add sanity check when mapping channels

We need to check for a valid channel_target pointer to handle the case
when a user missed to provide a channel name.

This fixes bug #1515.

Signed-off-by: Wolfram Sang <redacted>
4 years agoscan: Show serial number if available
Andreas Sandberg [Fri, 6 Mar 2020 16:34:45 +0000 (16:34 +0000)]
scan: Show serial number if available

Signed-off-by: Andreas Sandberg <redacted>
4 years agonsis: Ship Python stdlib *.pyd files.
Uwe Hermann [Wed, 22 Jan 2020 21:54:06 +0000 (22:54 +0100)]
nsis: Ship Python stdlib *.pyd files.

This fixes bug #1409.

4 years agoSet stdout to binary mode on Windows as needed
Devan Lai [Fri, 11 Oct 2019 03:16:01 +0000 (20:16 -0700)]
Set stdout to binary mode on Windows as needed

On Windows, stdout defaults to text mode, which attempts to perform
newline conversion such that if it sees a bare line feed (hex 0A),
it will insert a carriage return (hex 0D) before the line feed.

For textual output like normal annotation display or ASCII art, this is
desirable, but for binary output, this is likely to garble the output.

On Windows when using stdout as the output file destination or when
using the -B/--protocol-decoder-binary option, change the mode of stdout
to _O_BINARY to disable this newline conversion to ensure that the
binary output is faithfully delivered to stdout without modifications.

On all other platforms, setup_binary_stdout() is a no-op.

This fixes the original issue in bug #1427.

Further follow-up work might be needed to fix the reverse behavior that is
introduced by this change - now textual output sent to stdout on Windows
will only have Unix style line endings, rather than being converted to
Windows style line endings.

4 years ago--list-serial: Reduce indentation level.
Uwe Hermann [Thu, 20 Jun 2019 16:15:44 +0000 (18:15 +0200)]
--list-serial: Reduce indentation level.

This makes some cases of --list-serial output look a bit nicer.

4 years agoshow: support array of floats, unbreaks LCR output frequency listing
Gerhard Sittig [Wed, 1 May 2019 18:59:12 +0000 (20:59 +0200)]
show: support array of floats, unbreaks LCR output frequency listing

4 years agodoc: discuss "colons in conn= specs" in the manpage
Gerhard Sittig [Wed, 1 May 2019 18:41:25 +0000 (20:41 +0200)]
doc: discuss "colons in conn= specs" in the manpage

This should be obvious, but it seems it's not. Extend the paragraph
which introduces conn= specs for USB devices. Mention that colons are
not available within conn= specs because they are used to separate -d
fields from each other (driver name, and options like 'conn').

4 years ago--list-serial: Also mention HID/BT/BLE as possible "ports".
Uwe Hermann [Tue, 4 Jun 2019 17:12:46 +0000 (19:12 +0200)]
--list-serial: Also mention HID/BT/BLE as possible "ports".

4 years agoshow: print list of available serial ports
Gerhard Sittig [Thu, 16 Mar 2017 11:16:58 +0000 (12:16 +0100)]
show: print list of available serial ports

Introduce the --list-serial command line option, which prints the list
of serial ports detected by the sigrok serial.c abstraction.

The code was taken from Carl-Fredrik Sundström's <redacted>
message to the mailing list, with minor style fixes applied, and the
option renamed to explicitly mention its "list" nature, not suggesting
it would be a parameter to setup.

4 years agosession: print error message when output file creation fails
Gerhard Sittig [Tue, 16 Apr 2019 18:52:45 +0000 (20:52 +0200)]
session: print error message when output file creation fails

Failure to create an output file from within the sigrok-cli component
previously went unnoticed. Emit an error message to make users aware.

This addresses the sigrok-cli side of bug #1372.

4 years agodoc: update manpage, --show also works with --input-file
Gerhard Sittig [Sat, 20 Apr 2019 10:05:47 +0000 (12:05 +0200)]
doc: update manpage, --show also works with --input-file

4 years agoshow: add support for -i <fn> --show, provide details on input stream
Gerhard Sittig [Fri, 12 Apr 2019 16:50:49 +0000 (18:50 +0200)]
show: add support for -i <fn> --show, provide details on input stream

The combination of an input file spec and --show was not handled before,
and fell through to the case of showing device driver details. Do gather
input stream properties when --show was specified in combination with an
input file, and print those details to stdout.

This implementation does not assume a specific file format, instead the
datafeed callback got modified to watch the packets but not process them
(neither decode nor send data to an output module).

This approach, and the order of option combination checks in main(),
make this implementation work with input files as well as pipes, as well
as with any supported input module or session file, including automatic
format detection.

4 years agosession: make group of 'static' vars more visible
Gerhard Sittig [Fri, 12 Apr 2019 16:41:49 +0000 (18:41 +0200)]
session: make group of 'static' vars more visible

Put the collection of 'static' variables in datafeed_in() to the top of
the declaration block, to raise awareness during maintenance. These are
"semi global" variables with reduced visibility but extended lifetime.

Update a comment while I'm here. Explain what the early "header packet"
check does instead of what it doesn't.

4 years agodoc: weaken and extend the description of the -d option
Gerhard Sittig [Thu, 11 Apr 2019 18:34:34 +0000 (20:34 +0200)]
doc: weaken and extend the description of the -d option

The software implementation supports automatic driver scans, while the
manpage claimed that -d was mandatory. Change the description, suggest
to specify -d for various reasons, but "allow" for the absence of the -d
option as well.

4 years agoadd --dont-scan (-D) command line option
Gerhard Sittig [Thu, 11 Apr 2019 18:12:44 +0000 (20:12 +0200)]
add --dont-scan (-D) command line option

Introduce the -D or --dont-scan command line option. This avoids
automatic driver scans, and exclusively uses what -d specifies.

Some device drivers use non-standard protocol features since their
supported devices don't support the corresponding standard mechanisms.
Which can confuse conforming devices. In these situations it can be
desirable to not scan automatically for available devices, instead do
nothing until callers will specify the -d option.

This change is motivated by but does not resolve bugs #1155 and #1373.

4 years agodoc: update manpage, mention -A and annotation rows
Gerhard Sittig [Fri, 19 Apr 2019 15:02:22 +0000 (17:02 +0200)]
doc: update manpage, mention -A and annotation rows

Extend the manpage section which documents the -A option to select
annotation output. Mention that rows are supported in addition to
classes.

Rephrase the paragraph about multiple decoder specs in a single -A
option. Each of them can select multiple annotation classes, while the
previous documentation strongly suggested that only one class would be
available. [ best viewed with 'git diff -U10' ]

4 years agodecode: accept annotation rows for -A specs
Gerhard Sittig [Fri, 19 Apr 2019 14:50:39 +0000 (16:50 +0200)]
decode: accept annotation rows for -A specs

Extend the logic which parses -A annotation selection specs. Lookup
annotation classes first for backwards compatibility. Then lookup rows
when classes don't match.

Users can mix classes and rows in -A specs as they like. This is a
convenience feature, to eliminate the tedium of spelling out many
classes when a row is to be shown. Which is useful to only see the
"summary", the uppermost protocol layer within a protocol decoder, while
the individual bits on lower layers of that same protocol decoder are
not of interest. It's more accessible to specify

  -A ir_rc5=fields
  -A ac97=slots-out
  -A i2c=addr-data

instead of

  -A ir_rc5=startbit1:startbit2:togglebit-0:togglebit-1:address:command
  -A ac97=slot-out-tag:slot-out-cmd-addr:slot-out-cmd-data:slot-out-03:slot-out-04:slot-out-05:slot-out-06:slot-out-07:slot-out-08:slot-out-09:slot-out-10:slot-out-11:slot-out-io-ctrl
  -A i2c=start:repeat-start:stop:ack:nack:address-read:address-write:data-read:data-write

As an additional benefit row specs remain stable across decoder updates
which introduce new annotation classes on existing rows.

4 years agodecode: rephrase logic which looks up -A specs
Gerhard Sittig [Fri, 19 Apr 2019 14:38:11 +0000 (16:38 +0200)]
decode: rephrase logic which looks up -A specs

The previous logic scanned for specific annotation classes listed in -A,
broke the loop when nothing was found, otherwise registered the matching
annotation for display later on.

Rephrase the logic such that classes get registered when found, and then
advance to the next spec. Only mismatch will "fall through" to the error
path and terminate the setup routine with a fatal error.

This prepares for an optional lookup of annotation rows when class
lookup fails, before a fatal error is returned.

5 years agodecode: nits, whitespace and line length fix
Gerhard Sittig [Fri, 19 Apr 2019 13:03:14 +0000 (15:03 +0200)]
decode: nits, whitespace and line length fix

Address nits in the setup_pd_annotations() routine. Fixup an occurance
of too deep an indentation level (introduced in 790b026162332). Rephrase
a long line while we are here, to cut its length and for consistency
with other "visible annotations" manipulations in other locations.

5 years agodecode: improve readability, use intermediate variables
Gerhard Sittig [Fri, 19 Apr 2019 12:55:52 +0000 (14:55 +0200)]
decode: improve readability, use intermediate variables

Replace repeated complex keyval[] references with open coded indices by
respectively named variables. Also use 'ann_id' for an often referenced
annotation ID text string, for consistency with decoder ID.

5 years agodecode: fix memory leaks in annotation setup error paths
Gerhard Sittig [Fri, 19 Apr 2019 12:50:18 +0000 (14:50 +0200)]
decode: fix memory leaks in annotation setup error paths

5 years agoAdd --list-supported-wiki option.
Uwe Hermann [Fri, 29 Mar 2019 15:01:06 +0000 (16:01 +0100)]
Add --list-supported-wiki option.

This is meant for developers only, to easily update the list of
supported protocol decoders in the sigrok wiki.

5 years agoREADME: Bump libsigrokdecode requirement to >= 0.6.0.
Uwe Hermann [Fri, 15 Mar 2019 13:34:53 +0000 (14:34 +0100)]
README: Bump libsigrokdecode requirement to >= 0.6.0.

We now depend on the decoder tags feature introduced in the
libsigrokdecode 0.6.x series.

5 years agoDecoder --show output: List decoder tags.
Uwe Hermann [Fri, 15 Mar 2019 13:34:19 +0000 (14:34 +0100)]
Decoder --show output: List decoder tags.

5 years agoFix listing of some configuration options.
Guido Trentalancia [Tue, 29 Jan 2019 23:52:41 +0000 (00:52 +0100)]
Fix listing of some configuration options.

The listing of the following configuration options is currently
broken in sigrok-cli (invalid values are displayed):

 - "timebase" in yokogawa-dlm, rohde-schwarz-hameg, hantek-dso,
   lecroy-xstream, siglent-sds and rigol-ds drivers;
 - "vdiv" in hantek-6xxx, yokogawa-dlm, rohde-schwarz-hameg, hantek-dso,
   lecroy-xstream, hung-chang-dso-2100, siglent-sds and rigol-ds drivers;
 - "spl_meas_range" in pce-322a and cem-dt-885x drivers.

Fixes bug #1331.

Signed-off-by: Guido Trentalancia <redacted>
5 years agodecode: stricter check for integer decoder options
Gerhard Sittig [Sat, 1 Dec 2018 11:26:34 +0000 (12:26 +0100)]
decode: stricter check for integer decoder options

Tighten the check for integer type decoder options. Insist that the
conversion must have consumed all of the input text. Early reject specs
like "1m" or "8.0", but also unusual specs like "1 ". This shall avoid
later confusion when "seemingly accepted" specs won't take effect during
operation.

5 years agodecode: add support for float option data type
Gerhard Sittig [Sat, 1 Dec 2018 11:23:54 +0000 (12:23 +0100)]
decode: add support for float option data type

Accept decoder options where the value is a floating point number. This
fixes bug #1247 (the "unsupported type" issue reported for sigrok-cli).

5 years agomanpage: Clarify annotation classes in -A description.
Uwe Hermann [Wed, 21 Nov 2018 21:34:09 +0000 (22:34 +0100)]
manpage: Clarify annotation classes in -A description.

5 years agomanpage: Fix -A description wrt default annotations shown.
Uwe Hermann [Wed, 21 Nov 2018 21:32:15 +0000 (22:32 +0100)]
manpage: Fix -A description wrt default annotations shown.

5 years agomain: synchronize --get output for MQ with --show output
Gerhard Sittig [Sun, 4 Nov 2018 00:38:42 +0000 (01:38 +0100)]
main: synchronize --get output for MQ with --show output

The --show output used to print human readable text for measured
quantities, --get printed raw numbers for quantity and flags. Adjust
main.c:get_option() to follow the show.c:show_dev_detail() model for
consistency and usability.

5 years agodoc: minor update to -O and -g options in the manpage
Gerhard Sittig [Tue, 23 Oct 2018 17:13:24 +0000 (19:13 +0200)]
doc: minor update to -O and -g options in the manpage

Demonstrate output format options by means of "-O csv:..." which as a
byproduct also demonstrates booleans. Add an example how to combine -g
and -c, configuring an option of a channel group.

5 years agomanpage: Various updates and improvements.
Uwe Hermann [Wed, 8 Aug 2018 15:16:36 +0000 (17:16 +0200)]
manpage: Various updates and improvements.

5 years agodoc: mention lack of decoder signal name matching in manpage
Gerhard Sittig [Wed, 10 Oct 2018 08:13:51 +0000 (10:13 +0200)]
doc: mention lack of decoder signal name matching in manpage

Users may assume that sigrok-cli automatically matches input trace names
to decoder signals like pulseview does, and not be able to learn that
this is not the case. Explicitly state that limitation in the manpage.

5 years agodoc: discuss protocol decoder stacks in the manpage
Gerhard Sittig [Wed, 10 Oct 2018 07:36:13 +0000 (09:36 +0200)]
doc: discuss protocol decoder stacks in the manpage

The previous version mentioned comma-separated lists of decoders, which
is correct but also was easy to miss. Add a discussion and examples on
stacking decoders as well as creating multiple decoder stacks.

5 years agoFix invalid frame limit error reporting
Guido Trentalancia [Sun, 21 Oct 2018 22:15:35 +0000 (00:15 +0200)]
Fix invalid frame limit error reporting

This patch fixes a bug in the sigrok command-line interface error reporting
when an invalid frame limit is selected for the Hameg/Rohde&Schwarz HMO
mixed-signal oscilloscope driver (hameg-hmo).

Signed-off-by: Guido Trentalancia <redacted>
5 years agoinput: make read from stdin work with the presence of -I specs
Gerhard Sittig [Tue, 15 May 2018 19:18:08 +0000 (21:18 +0200)]
input: make read from stdin work with the presence of -I specs

The previous implementation supported reading from stdin, but only when
-I was not specified (i.e. with auto detectable input formats). Accept
stdin also when -I was specified, i.e. with the full set of supported
input formats (given they can get streamed).

5 years agomain.c: Minor cosmetic fix.
Uwe Hermann [Wed, 16 May 2018 20:09:00 +0000 (22:09 +0200)]
main.c: Minor cosmetic fix.

5 years agoMinor fix that makes Clang Static Analyzer stop complaining
Aleksander Alekseev [Wed, 2 May 2018 12:30:41 +0000 (15:30 +0300)]
Minor fix that makes Clang Static Analyzer stop complaining

5 years agoBugfix in order to make sr_session_stop() actually work.
Uwe Hermann [Wed, 25 Apr 2018 05:53:42 +0000 (07:53 +0200)]
Bugfix in order to make sr_session_stop() actually work.

The sr_session_stop() calls were previously invoked with the session
pointer being NULL, which didn't actually stop the session. This could
lead to samples still being processed and (e.g.) passed to libsigrokdecode
for decoding, even though the session should have been stopped.

Fix this by passing the session pointer along in the
sr_session_datafeed_callback_add() function, so that the callbacks
can make use of it.

6 years agosession: Don't run nop transform unless explicitly requested.
Uwe Hermann [Thu, 19 Apr 2018 19:44:43 +0000 (21:44 +0200)]
session: Don't run nop transform unless explicitly requested.

6 years agooptions: --help output cosmetics.
Uwe Hermann [Thu, 19 Apr 2018 06:16:00 +0000 (08:16 +0200)]
options: --help output cosmetics.

6 years agoinput.c: Rename BUFSIZE to CHUNK_SIZE.
Uwe Hermann [Thu, 19 Apr 2018 06:25:42 +0000 (08:25 +0200)]
input.c: Rename BUFSIZE to CHUNK_SIZE.

6 years agoinput: Increase chunk size from 16KB to 4MB.
Uwe Hermann [Mon, 16 Apr 2018 22:23:19 +0000 (00:23 +0200)]
input: Increase chunk size from 16KB to 4MB.

This not only slightly speeds up loading files, but more importantly leads
to larger chunks being passed to input modules (and later potentially output
modules), some of which can have a large performance penalty for small chunks.

In the specific case of e.g. binary input and an .sr output file this change
can lead to a speedup of 220x or more (due to larger chunks for srzip).

6 years agosigrok-cli.h: Drop unused functions and #defines.
Uwe Hermann [Mon, 16 Apr 2018 22:23:00 +0000 (00:23 +0200)]
sigrok-cli.h: Drop unused functions and #defines.

6 years agoAdd a .desktop file and an icon.
Uwe Hermann [Sat, 7 Apr 2018 17:27:45 +0000 (19:27 +0200)]
Add a .desktop file and an icon.

6 years agomanpage: Don't list specific output formats, mention -L.
Uwe Hermann [Mon, 26 Mar 2018 07:02:56 +0000 (09:02 +0200)]
manpage: Don't list specific output formats, mention -L.

The list is going to be outdated eventually (e.g. "gnuplot" no longer
exists), it's better to just mention that -L can be used to get a list.

6 years agoForce backup analog traces only if needed
Vincent Palatin [Tue, 24 Oct 2017 12:00:29 +0000 (14:00 +0200)]
Force backup analog traces only if needed

With the current conditions, when using the 'srzip' output module with
device generating SR_DF_ANALOG packets, they are processed both by
'srzip' and the backup 'analog' module (as 'out' is always null for
srzip which does its own file operation).
For a moderately fast continuous analog capture (e.g. 2.4MSamples/s),
the overhead of the 'analog' module is important (e.g. 80% of the whole
processing of my workstation) while we are not using its output,
so disable it when the user actually selected an output format/file
but the module doesn't generate text output.

Also remove the second part of the condition as 'opt_output_format'
never seems to be null or at least not in the case where the user has
omitted output parameters.

Tested with a device generating analog packets both with '-o test.sr'
and no output option.

6 years agoUpdate manpage references from -V to -L
yahvuu [Wed, 13 Sep 2017 17:45:50 +0000 (19:45 +0200)]
Update manpage references from -V to -L

Since bug #604, the supported drivers, decoders and input/output formats
are listed by -L|--list-supported.

Update the references in the manpage to -L, accordingly.

6 years agodecode: Always print colon after protocol decoder ID
Gerhard Sittig [Sun, 9 Jul 2017 12:09:31 +0000 (14:09 +0200)]
decode: Always print colon after protocol decoder ID

Remove the "bug compatibility" support. It's assumed that the omission
of the colon after the protocol decoder ID in log level 3 was less of a
design choice, but instead a byproduct of the redundancy in a previous
implementation (multiple code paths that got out of sync).

6 years agodoc: add --protocol-decoder-samplenum option to the manpage
Gerhard Sittig [Mon, 31 Jul 2017 17:32:05 +0000 (19:32 +0200)]
doc: add --protocol-decoder-samplenum option to the manpage

6 years agodecode: Optionally print sample numbers with protocol decoder annotations
Gerhard Sittig [Sun, 9 Jul 2017 11:56:45 +0000 (13:56 +0200)]
decode: Optionally print sample numbers with protocol decoder annotations

Introduce the "--protocol-decoder-samplenum" command line option (no
short form available), which emits sample numbers with textual output
from protocol decoder annotations, regardless of a log level value.

This shall increase usability of sigrok-cli output with external
postprocessors, as the option exclusively adds sample numbers to the
output but does not affect the presence or layout of any other line.

This commit prepends "text" and "meta" annotations with sample number
information. It does not change "binary" output.

6 years agodecode: Rework logic for text output of protocol decoder annotations
Gerhard Sittig [Sun, 9 Jul 2017 11:44:39 +0000 (13:44 +0200)]
decode: Rework logic for text output of protocol decoder annotations

Fold the previous three code paths which formatted text output for
annotations into one code path, which inspects the flags that were
determined before the actual output, and then always formats the fields
in identical ways regardless of why a field is shown.

Remove the assert checks that were introduced in a previous commit. The
logic for the field selection was proven to be identical to the previous
behaviour.

6 years agodecode: Prepare to rework text output for protocol decoder annotations
Gerhard Sittig [Sun, 9 Jul 2017 11:10:31 +0000 (13:10 +0200)]
decode: Prepare to rework text output for protocol decoder annotations

When the current implementation receives a protocol decoder annotation,
one out of several code paths prints one of several different variations
of text layout. The current implementation exclusively checks the active
log level to determine the layout variant.

Prepare to rework that text layout logic. Separate the determination of
which fields to display from the logic which does emit those fields in a
specific format.

This commit does not yet adjust the print statements. It is supposed to
verify that the "which fields to display?" logic results in identical
behaviour to the previous implementation.

6 years agodecode: Nit, avoid 'class' identifier for local variable
Gerhard Sittig [Sun, 9 Jul 2017 08:50:42 +0000 (10:50 +0200)]
decode: Nit, avoid 'class' identifier for local variable

6 years agosession: Adjust scan for non-demo device
Gerhard Sittig [Sat, 17 Jun 2017 16:19:34 +0000 (18:19 +0200)]
session: Adjust scan for non-demo device

The "demo?" condition is a property of the driver not a device instance.
Adjust the check accordingly, by not passing the 'sdi' when retrieving
the list of options. Rename the involved variable to reflect its purpose.
Adjust an error message text.

This fixes bug #848.

6 years agoHACKING: Prefer git pull requests over mailing list patches.
Uwe Hermann [Tue, 13 Jun 2017 15:08:21 +0000 (17:08 +0200)]
HACKING: Prefer git pull requests over mailing list patches.

Also, drop the reference to gitorious.org (no longer available).

6 years agoconfigure.ac: Bump package version to 0.8.0.
Uwe Hermann [Tue, 13 Jun 2017 20:52:53 +0000 (22:52 +0200)]
configure.ac: Bump package version to 0.8.0.

0.8.0 will be the next major release. Bump now, so that
there is no confusion of tarball 0.7.0 and 0.8.0-git snapshots.

6 years agoNEWS: Update for upcoming 0.7.0 release.
Uwe Hermann [Thu, 8 Jun 2017 18:28:02 +0000 (20:28 +0200)]
NEWS: Update for upcoming 0.7.0 release.

6 years agoFix various clang warnings. sigrok-cli-unreleased
Uwe Hermann [Thu, 8 Jun 2017 21:16:18 +0000 (23:16 +0200)]
Fix various clang warnings.

../show.c:668:30: warning: variable 'q' is uninitialized when used here [-Wuninitialized]
                                        s = sr_period_string(p, q);
                                                                ^
../show.c:324:30: note: initialize the variable 'q' to silence this warning
        const uint64_t *uint64, p, q, low, high;
                                    ^
                                     = 0
../show.c:668:27: warning: variable 'p' is uninitialized when used here [-Wuninitialized]
                                        s = sr_period_string(p, q);
                                                             ^
../show.c:324:27: note: initialize the variable 'p' to silence this warning
        const uint64_t *uint64, p, q, low, high;
                                 ^
                                  = 0
../show.c:458:58: warning: variable 'high' is uninitialized when used here [-Wuninitialized]
                                printf("    Maximum number of samples: %"PRIu64"\n", high);
                                                                                     ^~~~
../show.c:324:41:   CC       input.o
note: initialize the variable 'high' to silence this warning
        const uint64_t *uint64, p, q, low, high;
                                               ^
                                                = 0
../show.c:589:33: warning: variable 'low' is uninitialized when used here [-Wuninitialized]
                                printf("%"PRIu64"-%"PRIu64, low, high);
                                                            ^~~
../show.c:324:35: note: initialize the variable 'low' to silence this warning
        const uint64_t *uint64, p, q, low, high;
                                         ^
                                          = 0

6 years agoHACKING: Update URL to Linux kernel coding style.
Uwe Hermann [Tue, 6 Jun 2017 12:45:37 +0000 (14:45 +0200)]
HACKING: Update URL to Linux kernel coding style.

6 years agoREADME: Drop trailing whitespace.
Uwe Hermann [Tue, 6 Jun 2017 12:05:12 +0000 (14:05 +0200)]
README: Drop trailing whitespace.

6 years agoFix build when using --without-libsigrokdecode.
Uwe Hermann [Tue, 6 Jun 2017 09:15:45 +0000 (11:15 +0200)]
Fix build when using --without-libsigrokdecode.

6 years agoInstaller: Whitespace consistency fixes.
Uwe Hermann [Mon, 5 Jun 2017 15:43:32 +0000 (17:43 +0200)]
Installer: Whitespace consistency fixes.

6 years agoInstaller: Add "sigrok-cli" to uninstaller/Zadig links.
Soeren Apel [Mon, 5 Jun 2017 15:16:30 +0000 (17:16 +0200)]
Installer: Add "sigrok-cli" to uninstaller/Zadig links.

Windows 10 merges all links of the same vendor ("sigrok" here) into one
section in the Start menu. If PulseView and sigrok-cli are installed,
there will be two "Uninstall" links and the user will not know which one
uninstalls which program.

6 years agoInstaller: Place set of example .sr files in separate section
Soeren Apel [Mon, 5 Jun 2017 15:13:21 +0000 (17:13 +0200)]
Installer: Place set of example .sr files in separate section

6 years ago--list-supported: Show detailed library/feature info.
Uwe Hermann [Sat, 3 Jun 2017 15:17:04 +0000 (17:17 +0200)]
--list-supported: Show detailed library/feature info.

6 years agoList supported devices, modules, decoders via --list-supported.
Uwe Hermann [Sat, 3 Jun 2017 15:03:44 +0000 (17:03 +0200)]
List supported devices, modules, decoders via --list-supported.

Move this data from -V to -L|--list-supported for usability reasons.

This fixes bug #604.

6 years agoBump requirements to libsigrok/libsigrokdecode 0.5.0.
Uwe Hermann [Wed, 31 May 2017 21:09:57 +0000 (23:09 +0200)]
Bump requirements to libsigrok/libsigrokdecode 0.5.0.

We use various new API calls from the upcoming 0.5.0 releases and are
not compatible with the respective 0.4.x anymore.

6 years agoshow: Also print the possible decoder input/output IDs.
Uwe Hermann [Wed, 31 May 2017 21:00:39 +0000 (23:00 +0200)]
show: Also print the possible decoder input/output IDs.

6 years agooptions: expand builtin help, discuss samples/time/continuous constraint
Gerhard Sittig [Tue, 23 May 2017 17:41:41 +0000 (19:41 +0200)]
options: expand builtin help, discuss samples/time/continuous constraint

It might be surprising when the sigrok-cli(1) program does nothing (yet
spends user noticable time) before quitting while it spews the --help
text to the screen. Expand the builtin help text, explicitly mention
that either of --samples or --frames or --time or --continuous are
essentially required for data acquisition.

7 years agoUpdate sr_period_string usage
Soeren Apel [Sat, 25 Feb 2017 21:56:36 +0000 (22:56 +0100)]
Update sr_period_string usage

7 years agoconfigure summary: Show linker flags.
Uwe Hermann [Sun, 5 Mar 2017 16:08:54 +0000 (17:08 +0100)]
configure summary: Show linker flags.

7 years agoShow annotations based on decoder ID
Karl Palsson [Tue, 29 Nov 2016 16:21:30 +0000 (16:21 +0000)]
Show annotations based on decoder ID

Originally, decoder ID was equal to decoder instance ID, so it didn't
matter what you were comparing with. However, with distinct decoder
instances, this assumption fails. Because instance IDs can't be known
in advance, and because it would make the CLI arguments even more
complex, we simply let the -A option continue to be per decoder, not per
instance. This maintains compatibility with prior behaviour, but
doesn't allow the full flexibility possible with the library.

Behaviour preserved:
Single PD, no -A flag => all annotations from PD
Single PD, -A pdid => all annotations from PD
Single PD, -A pdid=annX => annX from PD

Behaviour now added:
Duplicate PDs, no -A flag => all annotations from all PDs
Duplicate PDs, -A pdid => all annotations from all PDs of type pdid
Duplicate PDs, -A pdid=annX => all annX from all PDs of type pdid

This fixes parts of bug #868.

Signed-off-by: Karl Palsson <redacted>