decode: Optionally print annotation class with PD annotations Introduce the "--protocol-decoder-ann-class" command line option (no short form available), which emits annotation class names with textual output from protocol decoder annotations, regardless of a log level value. Based on commit 08e9378bf68a by Gerhard Sittig <redacted>
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Support multiple protocol decoder stacks Requires libsigrokdecode changes to actually work. This allows multiple -P options to be specified, each of which is registered as a full stack with libsigrokdecode. At this point, there's no way to specify annotations per instance, the annotations are simply global per decoder (as before) rather than per instance. This fixes parts of bug #868. Signed-off-by: Karl Palsson <redacted>