]> sigrok.org Git - libsigrok.git/log
libsigrok.git
6 years agolibsigrok.h: Fix SR_CONF_UNDER_VOLTAGE_CONDITION_THRESHOLD order.
Uwe Hermann [Sat, 3 Mar 2018 18:25:57 +0000 (19:25 +0100)]
libsigrok.h: Fix SR_CONF_UNDER_VOLTAGE_CONDITION_THRESHOLD order.

This has to be the last entry in its "category", otherwise it'll mean an
ABI breakage.

6 years agoarachnid-labs-re-load-pro: Simplify a code chunk.
Uwe Hermann [Sat, 3 Mar 2018 18:24:35 +0000 (19:24 +0100)]
arachnid-labs-re-load-pro: Simplify a code chunk.

6 years agoarachnid-labs-re-load-pro: Add encoding.digits to analog packet
Frank Stettner [Thu, 18 Jan 2018 17:41:26 +0000 (18:41 +0100)]
arachnid-labs-re-load-pro: Add encoding.digits to analog packet

6 years agoarachnid-labs-re-load-pro: Index for channel "I"
Frank Stettner [Fri, 5 Jan 2018 19:07:20 +0000 (20:07 +0100)]
arachnid-labs-re-load-pro: Index for channel "I"

6 years agoarachnid-labs-re-load-pro: Get a response when in acquision mode.
Frank Stettner [Mon, 11 Dec 2017 15:06:16 +0000 (16:06 +0100)]
arachnid-labs-re-load-pro: Get a response when in acquision mode.

6 years agoarachnid-labs-re-load-pro: Make SR_CONF_REGULATION listable
Frank Stettner [Thu, 7 Dec 2017 09:41:32 +0000 (10:41 +0100)]
arachnid-labs-re-load-pro: Make SR_CONF_REGULATION listable

6 years agoarachnid-labs-re-load-pro: Add SR_CONF_UNDER_VOLTAGE_THRESHOLD.
Frank Stettner [Mon, 20 Nov 2017 14:20:58 +0000 (15:20 +0100)]
arachnid-labs-re-load-pro: Add SR_CONF_UNDER_VOLTAGE_THRESHOLD.

6 years agoarachnid-labs-re-load-pro: Setting correct current limit.
Frank Stettner [Mon, 20 Nov 2017 12:48:53 +0000 (13:48 +0100)]
arachnid-labs-re-load-pro: Setting correct current limit.

Use round() instead of just truncate the value.

6 years agoarachnid-labs-re-load-pro: Change serial read in acquisition mode.
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.

6 years agopipistrello-ols: style nit, replace DIY endianess conversion
Gerhard Sittig [Wed, 21 Feb 2018 17:13:36 +0000 (18:13 +0100)]
pipistrello-ols: style nit, replace DIY endianess conversion

6 years agolink-mso19: improve endianess conversion, avoid mem access alignment issue
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.

6 years agouni-t-dmm: style nits, copy loop vs memmove
Gerhard Sittig [Wed, 21 Feb 2018 17:03:11 +0000 (18:03 +0100)]
uni-t-dmm: style nits, copy loop vs memmove

6 years agosaleae-logic-pro: style nits, copy loop vs memcpy
Gerhard Sittig [Wed, 21 Feb 2018 17:01:41 +0000 (18:01 +0100)]
saleae-logic-pro: style nits, copy loop vs memcpy

6 years agopce-322a: style nits, copy loop vs memmove
Gerhard Sittig [Wed, 21 Feb 2018 16:59:33 +0000 (17:59 +0100)]
pce-322a: style nits, copy loop vs memmove

6 years agomic-985xx: style nits, var decl vs assignment, copy loop vs memmove
Gerhard Sittig [Wed, 21 Feb 2018 16:58:41 +0000 (17:58 +0100)]
mic-985xx: style nits, var decl vs assignment, copy loop vs memmove

6 years agokern-scale: style nits, var decl vs assignment, copy loop vs memmove
Gerhard Sittig [Wed, 21 Feb 2018 16:56:50 +0000 (17:56 +0100)]
kern-scale: style nits, var decl vs assignment, copy loop vs memmove

6 years agocenter-3xx: style nits, var decl vs assignment, copy loop vs memmove
Gerhard Sittig [Wed, 21 Feb 2018 16:55:07 +0000 (17:55 +0100)]
center-3xx: style nits, var decl vs assignment, copy loop vs memmove

6 years agosiglent-sds: Drop superfluous log message.
Uwe Hermann [Sat, 3 Mar 2018 17:45:58 +0000 (18:45 +0100)]
siglent-sds: Drop superfluous log message.

This information is already emitted by other layers.

6 years agosiglent-sds: Added trigger position to device config code
marchelh [Sun, 25 Feb 2018 08:28:39 +0000 (09:28 +0100)]
siglent-sds: Added trigger position to device config code

6 years agosiglent-sds: Fixed issue with hard coded vdiv.
marchelh [Sun, 25 Feb 2018 08:20:53 +0000 (09:20 +0100)]
siglent-sds: Fixed issue with hard coded vdiv.

6 years agosiglent-sds: Drop unused variable from siglent_sds_read_header function
marchelh [Sun, 25 Feb 2018 08:20:53 +0000 (09:20 +0100)]
siglent-sds: Drop unused variable from siglent_sds_read_header function

6 years agosiglent-sds: Added averaging function.
marchelh [Sun, 25 Feb 2018 08:14:57 +0000 (09:14 +0100)]
siglent-sds: Added averaging function.

6 years agosiglent-sds: Fixed timebase problem where NS could not be selected
marchelh [Sun, 25 Feb 2018 07:48:22 +0000 (08:48 +0100)]
siglent-sds: Fixed timebase problem where NS could not be selected

This fixes bug #1120.

6 years agotests: Fix incomplete fail message for locale tests.
Frank Stettner [Mon, 19 Feb 2018 14:31:30 +0000 (15:31 +0100)]
tests: Fix incomplete fail message for locale tests.

6 years agohp-3478a: Fix compiler warning.
Frank Stettner [Mon, 19 Feb 2018 12:30:13 +0000 (13:30 +0100)]
hp-3478a: Fix compiler warning.

6 years agoCheck usb_get_port_path() return value
Romain Tartière [Tue, 28 Nov 2017 19:07:29 +0000 (20:07 +0100)]
Check usb_get_port_path() return value

This function can fail. If so, do not ignore the failure.

6 years agoEnsure device is closed before usb_get_port_path()
Romain Tartière [Tue, 28 Nov 2017 18:43:50 +0000 (19:43 +0100)]
Ensure device is closed before usb_get_port_path()

The usb_get_port_path() function opens the passed device on FreeBSD,
which fails if the device has already been open.

This fixes bug #1109.

6 years agobindings/ruby: include config.h before any other header file
Gerhard Sittig [Mon, 19 Feb 2018 15:45:32 +0000 (16:45 +0100)]
bindings/ruby: include config.h before any other header file

6 years agobindings/python: include config.h before any other header file
Gerhard Sittig [Mon, 19 Feb 2018 15:44:09 +0000 (16:44 +0100)]
bindings/python: include config.h before any other header file

6 years agobindings/cxx: include config.h as early as possible
Gerhard Sittig [Mon, 19 Feb 2018 15:42:18 +0000 (16:42 +0100)]
bindings/cxx: include config.h as early as possible

Move the inclusion of <config.h> before any other source code.

6 years agopce-322a: include config.h before any other header file
Gerhard Sittig [Mon, 19 Feb 2018 15:41:06 +0000 (16:41 +0100)]
pce-322a: include config.h before any other header file

6 years agobeaglelogic: Use UINT64_MAX instead of (uint64_t)-1.
Uwe Hermann [Tue, 20 Feb 2018 19:02:30 +0000 (20:02 +0100)]
beaglelogic: Use UINT64_MAX instead of (uint64_t)-1.

6 years agobeaglelogic: Drop unneeded uint64_t cast.
Uwe Hermann [Tue, 20 Feb 2018 19:01:55 +0000 (20:01 +0100)]
beaglelogic: Drop unneeded uint64_t cast.

6 years agolecroy-xstream: Fix potential issue by adding UINT64_C.
Uwe Hermann [Tue, 20 Feb 2018 19:00:10 +0000 (20:00 +0100)]
lecroy-xstream: Fix potential issue by adding UINT64_C.

6 years agoUse UINT64_C instead of "ULL" number suffix.
Uwe Hermann [Tue, 20 Feb 2018 18:59:16 +0000 (19:59 +0100)]
Use UINT64_C instead of "ULL" number suffix.

Avoid hardcoding a "ULL" number suffix, use the more portable and more
correct UINT64_C.

6 years agoRandom whitespace/cosmetic fixes.
Uwe Hermann [Tue, 20 Feb 2018 18:34:55 +0000 (19:34 +0100)]
Random whitespace/cosmetic fixes.

6 years agosiglent-sds: Fix two memory leaks.
Uwe Hermann [Sun, 18 Feb 2018 22:36:17 +0000 (23:36 +0100)]
siglent-sds: Fix two memory leaks.

6 years agosiglent-sds: Drop incorrect glib includes.
Uwe Hermann [Sun, 18 Feb 2018 22:29:14 +0000 (23:29 +0100)]
siglent-sds: Drop incorrect glib includes.

6 years agohp-3478a: Shorten some functions.
Uwe Hermann [Sun, 18 Feb 2018 22:14:51 +0000 (23:14 +0100)]
hp-3478a: Shorten some functions.

6 years agohp-3478a: Drop superfluous log message prefixes.
Uwe Hermann [Sun, 18 Feb 2018 22:12:46 +0000 (23:12 +0100)]
hp-3478a: Drop superfluous log message prefixes.

6 years agohp-3478a: Initial HP 3478A diver
Frank Stettner [Mon, 2 Oct 2017 10:50:04 +0000 (12:50 +0200)]
hp-3478a: Initial HP 3478A diver

6 years agohp-3478a: Initial driver skeleton.
Frank Stettner [Sun, 17 Sep 2017 13:04:06 +0000 (15:04 +0200)]
hp-3478a: Initial driver skeleton.

6 years agooutput/analog: Fix a compiler warning on Mac OS X.
Uwe Hermann [Sun, 18 Feb 2018 20:23:28 +0000 (21:23 +0100)]
output/analog: Fix a compiler warning on Mac OS X.

Apparently PRIu64 and G_GUINT64_FORMAT differ on some systems for
unknown reasons. Use G_GUINT64_FORMAT to get rid of the warning
for now.

6 years agoFix two compiler warnings on MinGW/MSYS2.
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);
    ^

6 years agosiglent-sds: Fix multiple compiler warnings.
Uwe Hermann [Sun, 18 Feb 2018 16:40:59 +0000 (17:40 +0100)]
siglent-sds: Fix multiple compiler warnings.

6 years agosiglent-sds: Remove unused variable.
Uwe Hermann [Sun, 18 Feb 2018 16:14:08 +0000 (17:14 +0100)]
siglent-sds: Remove unused variable.

6 years agodmm: Remove unnecessary casts
Frank Stettner [Wed, 14 Feb 2018 20:04:09 +0000 (21:04 +0100)]
dmm: Remove unnecessary casts

6 years agometex14: Add missing modes and set correct digits value.
Frank Stettner [Wed, 14 Feb 2018 11:49:04 +0000 (12:49 +0100)]
metex14: Add missing modes and set correct digits value.

6 years agoserial-dmm, metex14: add support for multiple channels per DMM
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.

6 years agoserial-dmm: style nit (init vs assign, memmove(3))
Gerhard Sittig [Wed, 7 Feb 2018 21:34:35 +0000 (22:34 +0100)]
serial-dmm: style nit (init vs assign, memmove(3))

Move the initial assignment to the 'offset' variable to the very spot
where it gets evaluated and subsequently manipulated.

Replace a DIY copy loop with the corresponding memmove(3) call.

6 years agosiglent-sds: Bring driver up-to-date with current code conventions.
Uwe Hermann [Sat, 17 Feb 2018 18:08:07 +0000 (19:08 +0100)]
siglent-sds: Bring driver up-to-date with current code conventions.

Use ARRAY_AND_SIZE where possible, use std.c helpers where possible,
make scanopts/drvopts/devopts consistent with other drivers.

6 years agosiglent-sds: Drop obsolete SR_ST_ACTIVE checks.
Uwe Hermann [Sat, 17 Feb 2018 16:47:28 +0000 (17:47 +0100)]
siglent-sds: Drop obsolete SR_ST_ACTIVE checks.

These are now done in the wrapper functions.

6 years agosiglent-sds: Random cosmetics, drop unused stuff.
Uwe Hermann [Sat, 17 Feb 2018 16:18:32 +0000 (17:18 +0100)]
siglent-sds: Random cosmetics, drop unused stuff.

6 years agosiglent-sds: Use PRIu64 for uint64_t variables.
Uwe Hermann [Sat, 17 Feb 2018 15:01:58 +0000 (16:01 +0100)]
siglent-sds: Use PRIu64 for uint64_t variables.

This fixes various compiler warnings on some systems.

6 years agosiglent-sds: Fix SR_CONF_TRIGGER_SLOPE config_set() code.
Uwe Hermann [Fri, 16 Feb 2018 23:44:55 +0000 (00:44 +0100)]
siglent-sds: Fix SR_CONF_TRIGGER_SLOPE config_set() code.

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",
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

6 years agoudev: Add entries for Siglent USBTMC devices.
Uwe Hermann [Fri, 16 Feb 2018 22:40:15 +0000 (23:40 +0100)]
udev: Add entries for Siglent USBTMC devices.

6 years agosiglent-sds: Add 100s timebase (seen on e.g. SDS1202X-E).
Uwe Hermann [Fri, 16 Feb 2018 23:00:31 +0000 (00:00 +0100)]
siglent-sds: Add 100s timebase (seen on e.g. SDS1202X-E).

6 years agosiglent-sds: Add SDS1052DL+ model.
Uwe Hermann [Fri, 16 Feb 2018 22:24:33 +0000 (23:24 +0100)]
siglent-sds: Add SDS1052DL+ model.

6 years agosiglent-sds: Various cosmetics and coding-style fixes.
Uwe Hermann [Fri, 16 Feb 2018 19:33:44 +0000 (20:33 +0100)]
siglent-sds: Various cosmetics and coding-style fixes.

Also, drop some unneeded comments and log messages.

6 years agohantek-4032l: Minor cosmetics.
Uwe Hermann [Thu, 15 Feb 2018 21:45:35 +0000 (22:45 +0100)]
hantek-4032l: Minor cosmetics.

6 years agostd.c: Add missing <sys/time.h> #include and _XOPEN_SOURCE.
Uwe Hermann [Tue, 13 Feb 2018 20:54:46 +0000 (21:54 +0100)]
std.c: Add missing <sys/time.h> #include and _XOPEN_SOURCE.

This is required for gettimeofday() to be available (at least on
FreeBSD), causes compiler warnings otherwise.

6 years agosiglent-sds: Replace non-portable strcasestr() with g_strstr_len().
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().

6 years agosiglent-sds: Drop currently unused <rpc/rpc.h> #include.
Uwe Hermann [Tue, 13 Feb 2018 20:52:25 +0000 (21:52 +0100)]
siglent-sds: Drop currently unused <rpc/rpc.h> #include.

This causes some compile errors on platforms where RPC is not available, e.g.

  siglent-sds/api.c:25:21: fatal error: rpc/rpc.h: No such file or directory

Surrounding the #include (and later code) with "#if HAVE_RPC" should avoid
these compile errors, but since it's not used at all for now, drop it.

6 years agoREADME.devices: add Siglent SDS to the firmware and conn= sections
Gerhard Sittig [Sun, 11 Feb 2018 14:49:11 +0000 (15:49 +0100)]
README.devices: add Siglent SDS to the firmware and conn= sections

6 years agousbtmc: only reset Siglent (and Atten) devices in open
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.

6 years agousbtmc: add the Siglent VID and reset USB devices in open
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.

6 years agosiglent-sds: initial driver implementation for Siglent SDS
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:

  $ git diff --word-diff=color -w -b <branch>:<dir> <branch>:<dir>

  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. ]

6 years agosiglent-sds: Initial driver skeleton.
mhooijboer [Sun, 11 Feb 2018 14:18:57 +0000 (15:18 +0100)]
siglent-sds: Initial driver skeleton.

6 years agoREADME.devices: discuss conn= and USB/TCP/VXI in addition to RS232
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).

6 years agokorad-kaxxxxp: Simplify korad_kaxxxxp_receive_data() event loop function.
Frank Stettner [Mon, 8 Jan 2018 12:31:41 +0000 (13:31 +0100)]
korad-kaxxxxp: Simplify korad_kaxxxxp_receive_data() event loop function.

6 years agokorad-kaxxxxp: Use locale independent sr_snprintf_ascii() function
Frank Stettner [Sun, 7 Jan 2018 17:06:03 +0000 (18:06 +0100)]
korad-kaxxxxp: Use locale independent sr_snprintf_ascii() function

6 years agokorad-kaxxxxp: Synchronize read and write operations.
Frank Stettner [Sat, 6 Jan 2018 20:27:42 +0000 (21:27 +0100)]
korad-kaxxxxp: Synchronize read and write operations.

6 years agokorad-kaxxxxp: Add two channels "V" and "I", remove channel "CH1"
Frank Stettner [Fri, 5 Jan 2018 20:09:47 +0000 (21:09 +0100)]
korad-kaxxxxp: Add two channels "V" and "I", remove channel "CH1"

6 years agotests: Tests for the locale independent sr_vsnprintf_ascii() function.
Frank Stettner [Fri, 26 Jan 2018 12:56:19 +0000 (13:56 +0100)]
tests: Tests for the locale independent sr_vsnprintf_ascii() function.

6 years agostrutil: Locale independent snprintf() and vsnprintf() functions
Frank Stettner [Fri, 26 Jan 2018 12:53:45 +0000 (13:53 +0100)]
strutil: Locale independent snprintf() and vsnprintf() functions

6 years agohameg-hmo: fix potential NULL dereference
Gerhard Sittig [Sat, 10 Feb 2018 11:20:05 +0000 (12:20 +0100)]
hameg-hmo: fix potential NULL dereference

Check for successful allocation before accessing struct members. Return
with an error from device initialization when allocation fails.

This was reported by clang's scan-build.

6 years agohameg-hmo: fix potential memory leak
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).

This was reported by clang's scan-build.

6 years agooutput/srzip: fix potential "use after free"
Gerhard Sittig [Sat, 10 Feb 2018 09:18:20 +0000 (10:18 +0100)]
output/srzip: fix potential "use after free"

The compiler marks a potential use after free, which the current
implementation won't trigger. The error only occurs when a sigrok
channel is neither logic nor analog.

Address the issue nevertheless, to silence the compiler warning, and to
protect against possible programming errors when a future implementation
should support more channel types.

This was reported by clang's scan-build.

6 years agosession: fix another potential memory leak
Gerhard Sittig [Sat, 10 Feb 2018 09:12:51 +0000 (10:12 +0100)]
session: fix another potential memory leak

This was reported by clang's scan-build.

6 years agooutput/wav: fixup coding style nits, adjust data types
Gerhard Sittig [Sun, 23 Oct 2016 10:12:33 +0000 (12:12 +0200)]
output/wav: fixup coding style nits, adjust data types

Fixup unbalanced braces for more complex if statements, to better
reflect the project's official coding style.

Adjust data types in the float_to_le() routine. A float value gets
copied to a buffer of bytes (uint8_t). Don't use 'char' on the other
side of assignments, to not assume a specific width for char, and to
avoid potential signedness issues. Copy from bytes to bytes instead.

6 years agooutput/wav: change default for scale factor from 0.0 to 1.0
Gerhard Sittig [Sun, 23 Oct 2016 09:55:07 +0000 (11:55 +0200)]
output/wav: change default for scale factor from 0.0 to 1.0

The WAV output module supports an optional 'scale' factor, in its
absence the samples will pass unmodified. The builtin help text is
unexpected, and reads:

  $ sigrok-cli -O wav --show
  ...
  Options:
    scale: Scale values by factor (default 0.0)

Setup a default scale factor of 1.0, which results in identical
behaviour and better reflects what is happening.

6 years agooutput/vcd: assume packed input data image, unbreak 2nd+ channel
Gerhard Sittig [Sun, 4 Feb 2018 22:17:39 +0000 (23:17 +0100)]
output/vcd: assume packed input data image, unbreak 2nd+ channel

The previous implementation only emitted data for the first enabled
channels, and "saw no changes" after emission of the initial value for
channels on positions that followed a disabled channel.

Assume that the received data from the session bus communicates the bits
of enabled channels in a packed representation. Skip the mapping of
output bit indices to sigrok channel numbers.

This fixes the remaining part of bug #519.

Tested by inspecting in gtkwave the result of command:
  $ sigrok-cli -d demo -C D1,D3,D6 -c samplerate=2M --samples 2500 -O vcd -o trace.vcd

When we find that all input sources (device drivers, and input modules)
provide a dense bit field, all of the mapping logic can get removed
here. This commit just quickly disables the logic.

6 years agooutput/vcd: assign adjacent names to enabled channels
Gerhard Sittig [Sun, 4 Feb 2018 22:05:59 +0000 (23:05 +0100)]
output/vcd: assign adjacent names to enabled channels

Identifiers for channels in the VCD header section could be "sparse"
when sigrok channels were disabled. Make sure to not assign names to
disabled channels. This will e.g. assign !, ", and # to channels D1, D3,
and D6, when D0, D2, D4-D5, and D7 are disabled.

This addresses part of bug #519.

6 years agoseveral DMMs: set DC flag for diode mode
Gerhard Sittig [Sun, 4 Feb 2018 21:26:23 +0000 (22:26 +0100)]
several DMMs: set DC flag for diode mode

Few DMM drivers already did it. This commit adjusts the remaining DMM
drivers, to set the "DC" flag for measurements in diode mode.

This fixes bug #144.

Although I don't have the hardware to test, the nature of the change and
the arrangement of driver code suggests it's good. When a meter already
communicated the "DC" status, the change does nothing and won't harm.
The change ensures "DC" is flagged for those meters which previously
didn't, which is desirable.

6 years agostrutil: accept trailing whitespace after number text
Gerhard Sittig [Sun, 4 Feb 2018 19:17:08 +0000 (20:17 +0100)]
strutil: accept trailing whitespace after number text

Some SCPI based drivers fail to convert response data, because strutil
conversion helpers sr_atol() and sr_atof() don't like trailing spaces
after the number's text that successfully got converted.

It's yet to get determined whether all call sites of the conversion
routines like their eating adjacent whitespace. But given that the
conversion routine explicitly checks for end of the string after the
number, no call site should expect or even depend on trailing text to
keep its whitespace.

See bug #788 for a discussion and example data.

6 years agostrutil: support tera/peta/exa suffixes in symbolic size specs
Gerhard Sittig [Sun, 4 Feb 2018 18:50:25 +0000 (19:50 +0100)]
strutil: support tera/peta/exa suffixes in symbolic size specs

Synchronize sr_parse_sizestring() with sr_si_string_u64() capabilities.
Add support for the T/P/E suffixes. Since this conversion helper deals
with integer values exclusively, there is no issue with case insensitive
matches. The value cannot be pico. Neither is there an ambiguity with
the 10e6 notation.

This addresses bug #763.

Fix a style nit while we are here. Put braces around both arms of a
complex conditional.

6 years agobeaglelogic: silence compiler warning
Gerhard Sittig [Sun, 4 Feb 2018 15:18:03 +0000 (16:18 +0100)]
beaglelogic: silence compiler warning

Explicitly assign NULL to param to avoid the "may be used uninitialized"
warning reported in bug #1094. Behaviour remains unchanged. All references
to the variable were under "if (!conn)", and the assigning arm of the
branch checked for "if (!param)" after assignment. So the error could
not happen, but compilers may not have noticed depending on the width of
their scope during compilation.

Move the initialization of 'conn' closer to the conditional assignment,
such that all paths are seen in one spot during maintenance.

This fixes bug #1094.

6 years agousb: re-use existing values, don't re-determine bus and device address
Gerhard Sittig [Mon, 29 Jan 2018 19:36:50 +0000 (20:36 +0100)]
usb: re-use existing values, don't re-determine bus and device address

Avoid repeated libusb bus number and device address retrieval operations,
instead use variables where the information previously got stored to.

6 years agolog: flush log lines, to cope with non-terminal output (pipes)
Gerhard Sittig [Mon, 29 Jan 2018 19:10:36 +0000 (20:10 +0100)]
log: flush log lines, to cope with non-terminal output (pipes)

Although log messages are terminated by a line feed, output still might
get buffered when the program does not talk to a terminal (that it is
aware of). Add an fflush(3) call to the printf(3) sequence such that log
output will immediately show up when writing to pipes or sockets, too.

6 years agobackend: fixup resource leak in sr_init() error code path
Gerhard Sittig [Sun, 26 Mar 2017 13:46:37 +0000 (15:46 +0200)]
backend: fixup resource leak in sr_init() error code path

Early sr_init() steps can just 'return' fine. After allocation of the
'context' memory, make all error paths 'goto done' before returning,
to undo the memory allocation.

6 years agoREADME.devices: the PRINT button must get pressed for Metrix MX56C
Gerhard Sittig [Sun, 28 Jan 2018 18:28:06 +0000 (19:28 +0100)]
README.devices: the PRINT button must get pressed for Metrix MX56C

6 years agosrzip: don't access non-existing option
Gerhard Sittig [Sun, 28 Jan 2018 17:58:19 +0000 (18:58 +0100)]
srzip: don't access non-existing option

The srzip output module dropped support for the "filename" option in
commit 37875f750614 on 2015-07-30, but still used to assign to slot
options[0] which clobbers the array's sentinel. Remove those accesses
to the non-existing option.

6 years agohantek-4032l: Fix a compiler warning.
Uwe Hermann [Fri, 9 Feb 2018 20:26:38 +0000 (21:26 +0100)]
hantek-4032l: Fix a compiler warning.

  api.c: In function 'config_set':
  api.c:352:5: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'uint64_t' [-Wformat=]
       sr_err("invalid sample range 2k...64M: %ld",
       ^

6 years agobeaglelogic: Fix a compiler warning.
Uwe Hermann [Fri, 9 Feb 2018 20:25:18 +0000 (21:25 +0100)]
beaglelogic: Fix a compiler warning.

 beaglelogic_tcp.c: In function 'beaglelogic_tcp_send_cmd':
 beaglelogic_tcp.c:114:3: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' [-Wformat=]
     sr_dbg("Only sent %d/%lu bytes of command: '%s'.", out,
     ^

6 years agoyokogawa-dlm: fix several compiler warnings (assignment, memory)
Gerhard Sittig [Fri, 9 Feb 2018 18:32:12 +0000 (19:32 +0100)]
yokogawa-dlm: fix several compiler warnings (assignment, memory)

Check pointers' validity before dereferencing them. Release partially
allocated memory in an error path. Remove an assignment which never took
effect.

This was reported by clang's scan-build.

6 years agotondaj-sl-814: fix a potential memory leak
Gerhard Sittig [Fri, 9 Feb 2018 18:30:45 +0000 (19:30 +0100)]
tondaj-sl-814: fix a potential memory leak

Release an allocated device instance in an error path.

This was reported by clang's scan-build.

6 years agosysclk-lwla: silence potential NULL dereference compiler warning
Gerhard Sittig [Fri, 9 Feb 2018 18:30:00 +0000 (19:30 +0100)]
sysclk-lwla: silence potential NULL dereference compiler warning

Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.

6 years agoscpi-pps: silence potential NULL dereference compiler warning
Gerhard Sittig [Fri, 9 Feb 2018 18:29:08 +0000 (19:29 +0100)]
scpi-pps: silence potential NULL dereference compiler warning

Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.

6 years agosaleae-logic-pro: silence "assigned, not used" compiler warning
Gerhard Sittig [Fri, 9 Feb 2018 18:27:52 +0000 (19:27 +0100)]
saleae-logic-pro: silence "assigned, not used" compiler warning

Remove an assignment that never took effect.

This was reported by clang's scan-build.

6 years agorigol-ds: silence potential NULL dereference compiler warning
Gerhard Sittig [Fri, 9 Feb 2018 18:26:42 +0000 (19:26 +0100)]
rigol-ds: silence potential NULL dereference compiler warning

Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.