James Churchill [Sun, 18 Feb 2018 06:54:01 +0000 (16:54 +1000)]
modbus: Return explicit SR_ERR values as required by modbus.c
The Modbus RTU implementation was inappropriately returning lengths
from the serial functions when the calling functions expect only an
sr_error_code value.
Gerhard Sittig [Sun, 4 Mar 2018 18:12:29 +0000 (19:12 +0100)]
output/csv: fix out-of-bounds array access in process_analog()
Make sure to not exceed the ctx->analog_samples[] array bounds. Don't
use the (huge) channel's index in the device's(!) channel list, instead
use the zero-based and dense index into the array of analog samples in
the accumulation buffer, before writing to the external file.
Gerhard Sittig [Sun, 4 Mar 2018 17:19:38 +0000 (18:19 +0100)]
output/csv: use longer names for iteration variables
The process_analog() logic is rather complex, dealing with the total
list of channels in the device (which can be of different types), and a
number of submitted samples for a specified list of channels. Replace
the rather short variable names for i, j, c (and num_channels) with
something longer that hopefully increases readability of the complex
loop bodies.
Note that this change merely renames identifiers, and does not change
behaviour.
Gerhard Sittig [Sun, 4 Mar 2018 16:51:29 +0000 (17:51 +0100)]
output/csv: reduce indentation in process_analog()
Instead of nesting indentation levels upon equality of a value, skip
iterations upon inequality. This reduces indentation, and might improve
readability.
[ Indentation changes, see 'diff -w -b' for the essence. ]
Frank Stettner [Sat, 11 Nov 2017 17:29:19 +0000 (18:29 +0100)]
arachnid-labs-re-load-pro: Change serial read in acquisition mode.
Use serial_readline in acquisition mode, otherwise data from the
Re:load Pro could get lost.
Use reloadpro_receive_data() for all commands when in acquisition
mode. When not using a single point of receiving data, data could get
lost.
Gerhard Sittig [Wed, 21 Feb 2018 17:04:29 +0000 (18:04 +0100)]
link-mso19: improve endianess conversion, avoid mem access alignment issue
Prefer sigrok's endianess conversion helper over the inet htons()
routine which is harder to read (is "network order" little or big?).
Writing the conversion results in units of bytes also avoids misaligned
memory access. The header length is odd, each payload item got written
as an uint16_t item to an odd address.
Uwe Hermann [Sun, 18 Feb 2018 20:13:56 +0000 (21:13 +0100)]
Fix two compiler warnings on MinGW/MSYS2.
The config.h file must always be included as first file.
src/output/csv.c: In function 'gen_header':
src/output/csv.c:64:20: warning: format '%u' expects argument of type 'unsigned int', but argument 3 has type 'uint64_t {aka long long unsigned int}' [-Wformat=]
#define LOG_PREFIX "output/csv"
^
./src/libsigrok-internal.h:753:42: note: in expansion of macro 'LOG_PREFIX'
#define sr_info(...) sr_log(SR_LOG_INFO, LOG_PREFIX ": " __VA_ARGS__)
^
src/output/csv.c:244:3: note: in expansion of macro 'sr_info'
sr_info("Set sample period to %" PRIu64 " %s",
^
src/output/csv.c: In function 'dump_saved_values':
src/output/csv.c:462:34: warning: format '%u' expects argument of type 'unsigned int', but argument 3 has type 'uint64_t {aka long long unsigned int}' [-Wformat=]
g_string_append_printf(*out, "%" PRIu64 "%s",
^
In file included from src/hardware/ftdi-la/protocol.c:21:0:
src/hardware/ftdi-la/protocol.c: In function 'send_samples':
src/hardware/ftdi-la/protocol.h:28:20: warning: format '%u' expects argument of type 'unsigned int', but argument 3 has type 'uint64_t {aka long long unsigned int}' [-Wformat=]
#define LOG_PREFIX "ftdi-la"
^
./src/libsigrok-internal.h:751:42: note: in expansion of macro 'LOG_PREFIX'
#define sr_spew(...) sr_log(SR_LOG_SPEW, LOG_PREFIX ": " __VA_ARGS__)
^
src/hardware/ftdi-la/protocol.c:29:2: note: in expansion of macro 'sr_spew'
sr_spew("Sending %" PRIu64 " samples.", samples_to_send);
^
Gerhard Sittig [Wed, 7 Feb 2018 21:09:14 +0000 (22:09 +0100)]
serial-dmm, metex14: add support for multiple channels per DMM
Optionally create multiple analog channels in serial-dmm's scan()
routine. Allow the meters' parse routines to fill in more than one
analog value from the inspection of a single packet.
Use "large" (4 times 14 bytes) packets for the Metex M-3860M and the
PeakTech 4390A meters, and have those large packets parsed by wrapping
the routines for regular 14-byte Metex packets, and sending four values
to the session bus after reception of one large packet.
Thanks to Frank Stettner <redacted> for testing and
fixing the initial implementation of this extension.
Also use "r" and "f" as trigger slope values for now, since that's
what most other drivers do currently.
This also fixes two scan-build issues:
api.c:559:3: warning: Value stored to 'tmp_str' is never read
tmp_str = g_variant_get_string(data, NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
api.c:561:9: warning: Use of memory after it is freed
ret = siglent_sds_config_set(sdi, "%s:TRSL %s",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Uwe Hermann [Tue, 13 Feb 2018 21:37:01 +0000 (22:37 +0100)]
siglent-sds: Replace non-portable strcasestr() with g_strstr_len().
The strcasestr() function is non-portable (e.g. not available on
MinGW, possibly elsewhere). Replace it with g_strstr_len() for the time
being. While the latter is not case-insensitive it appears that
that property doesn't matter here ("." should not be relevant anyway,
and e.g. an SDS1202X-E does indeed report "Mpts" as such).
Should it become necessary to have this code be case-insensitive,
we'll have to find a more portable solution than strcasestr().
Gerhard Sittig [Sun, 11 Feb 2018 15:16:17 +0000 (16:16 +0100)]
usbtmc: only reset Siglent (and Atten) devices in open
Make the USB reset for USB TMC devices conditional. Check a whitelist,
which in this implementation exclusively contains the Siglent VID.
The whitelist's comment may need adjustment. The VID probably not only
applies to SDS devices, but could be used for SDG and others as well.
And lsusb output suggests the VID is used by Atten, too.
Gerhard Sittig [Sun, 11 Feb 2018 15:30:34 +0000 (16:30 +0100)]
usbtmc: add the Siglent VID and reset USB devices in open
Add the Siglent's VID to a list of blacklisted USB TMC devices.
Unconditionally reset USB devices in the open routine.
This was taken from marchel's development for Siglent SDS. Though the
reset should probably be conditional, and only get applied to devices
which are known to need it.
The comment may need adjustment, maybe individual PID entries are
required. The VID probably not only applies to SDS devices, but could
be used for SDG and other gear as well. And lsusb output suggests the
VID is used by Atten, too.
mhooijboer [Sun, 11 Feb 2018 17:11:58 +0000 (18:11 +0100)]
siglent-sds: initial driver implementation for Siglent SDS
Implement a first version of the driver for the Siglent SDS1000 and
SDS2000 oscilloscopes.
[ gsi: This commit corresponds to git 0228126017e6 of marchelh's tree,
I adjusted the source to closer match the project's coding style. The
conversion was verified by this command:
Changes include: Whitespace adjustment, dead code removal, separation
of variable declaration and assignment, alpha-sorted includes. Line
length was not addressed and not every location got adjusted, to keep
the diff minimal and to reduce effort during review of this version. ]
Gerhard Sittig [Sun, 11 Feb 2018 14:43:38 +0000 (15:43 +0100)]
README.devices: discuss conn= and USB/TCP/VXI in addition to RS232
The conn= specification is not strictly related to RS232 communication.
Provide examples for other USB specs (as they are used for some DMM and
LCR drivers), as well as TCP and VXI (which are often found with MSO
drivers).
Gerhard Sittig [Sat, 10 Feb 2018 09:26:23 +0000 (10:26 +0100)]
hameg-hmo: fix potential memory leak
Make sure to release the allocated "pod enabled" memory, too, when SCPI
communication during channel setup fails. Defer the return with an error
(instead of duplicating the free() invocation).