scpi: comment on indefinite length block data (unsupported here) It's fine that the current SCPI implementation in libsigrok exclusively supports definite length block response data. It is what most supported devices or all of them are speaking. But the implementation of the indefinite length case assumed that the block is empty when the response starts with #0, and returned successful although receive data was not taken at all. Rephrase the test condition for successful reception. Return an error code in the unsupported case. Emit an error message to remain aware. Let users report when that communication pattern is seen in the field. Add comments with references to the specs, in case the feature will receive support later.
scpi: style nits in sr_scpi_scan(), prefer common helper Improve readability and simplify maintenance of the sr_scpi_scan() routine. Move initial assignment and subsequent update of variables in closer proximity, don't hide assignments in declaration blocks. Use common helper code where available. Split complex conditions into individual terms which are easier to review and reason about. Don't mix calls and value checks and flow control in the same statement.
scpi: readability nits in vector getters, style nit in malloc call Improve readability of SCPI uint8 and float vector get routines. Move assignment and use of variables closer together to simplify review. Allocate the glib array based on the text split result's length. Move data processing to the "straight" path and handle failed conversion as an exceptional condition in an error path. Eliminate a redundant data type reference in a malloc call.
scpi: document callers' responsibility to free getters' allocated memory Some of the SCPI getter routines allocate memory for response data which callers need to free after use. Document this responsibility in more places, and rephrase existing locations for consistency. See a word-diff for the essence of the commit. It's assumed that the separate paragraph in the function description is better perceived than something that's hidden in the parameter or return value discussion. Also reference the corresponding free routine by name for callers' convenience (data types will differ among routines). Some free routines can be called unconditionally, others require NULL checks at the caller's. Reported-By: Ralf <redacted>
scpi: make sure to either return valid SCPI response data or NULL Assign NULL early in those SCPI get routines which return allocated memory to their callers. So that the return value is either a valid pointer to memory or NULL regardless of the routine's exit code. This simplifies call sites and increases robustness.
scpi: accept numbers like 4.0000E3 as integer value MSO5000 returns memory depth value in that format, e.g. sr: [04:21.491949] scpi_vxi: Successfully sent SCPI command: 'ACQ:MDEP?'. sr: [04:21.501463] scpi: Got response: '4.0000E+03', length 10. [ gsi: drop redundant assignment and parens, amend diag message ]
scpi: Raise severity when IDN response lacks the serial number field. Raise the diagnostics message's severity from debug to warn when the '*IDN?' response lacks the serial number field. Although it has only been seen for some GWInstek DMMs, it violates the SCPI spec, and more or other activity is required in a future implementation. This change amends commit 47e7a6395e21.
hameg-hmo: Avoid getting stuck upon SCPI timeouts. Correctly set the length of the buffer used to hold the SCPI response from the device containing the binary acquisition data. If a timeout occurs, truncate the buffer and send the partial response from the device instead of getting stuck on timeouts! Thanks to Stefan BrĂ¼ns for reviewing the first version of this patch and spotting out a serious problem with it. This fixes bug #1323.
serial: introduce more general "have serial comm" feature flag Introduce the HAVE_SERIAL_COMM identifier, which gets derived from, but need not be identical to the HAVE_LIBSERIALPORT condition. Derive the NEED_SERIAL automake condition from the general availability of serial communication not the specific libserialport library. Adjust source code references. Stick with HAVE_LIBSERIALPORT where the specific library is meant, but switch to HAVE_SERIAL_COMM where the availability of serial communication in general is meant.
scpi: introduce string un-quote helper routine The SCPI protocol may communicate strings in quoted form, enclosed by a matching pair of single or double quote characters, and occurances of this very quote character within the string get doubled (escaped). Add a common routine to undo the quotes.
scpi-pps: Reimplemention of switching channel groups (PSU channels) Acquisition won't work correctly in a multi-threaded environment, when config_set() and config_get() are called with a channel group. The channel switching itself has moved to scpi/scpi.c, to be able to handle switching in a thread safe way.
scpi: Synchronize read, write and write+read operations. This ensures that SCPI read/write/write+read operations are thread safe. F.e.: If a write operation expects a return value (in other words: a read operation), it is not allowed to be interrupted by another write operation. To simplify things, the SCPI helper functions are moved from scpi/helpers.c to scpi/scpi.c and also are renamed to fit the naming scheme. libgpib in particular will abort the program execution in case of concurrent operations.