Commit Graph

4875 Commits

Author SHA1 Message Date
Gerhard Sittig e5fa47c1c9 serial: dump DMM packets during stream detection
Regular operation of serial DMM drivers optionally can dump packet bytes
after the intialization phase has synchronized to the stream. Failure to
synchronize to the stream left developers without a dump, which complicates
research what went wrong.

Do dump packet content while the serial_stream_detect() routine tries to
synchronize to the stream. Use the spew level since the dump occurs upon
every attempt, which translates to: every received byte until a valid
packet was seen (or the synchronization phase expired).
2018-10-13 15:57:01 +02:00
Gerhard Sittig 75aaf967e3 serial-dmm: print data bytes according to specific meter's packet length
The previous implementation always dumped 23 data bytes for received
packets. This could result in truncated diagnostics information, and/or
access to invalid buffer content.

Rephrase the packet dump routine such that the specific meter's exact
packet length gets dumped, and use the common hex dump support code.
2018-10-13 15:57:01 +02:00
Gerhard Sittig f1d0755b73 uni-t-dmm: use common hex dump helper routine 2018-10-13 15:57:01 +02:00
Gerhard Sittig d8bc7ca3e6 strutil: introduce hex dump routines (allocate a text buffer)
Introduce common support for hex dumps in the string util collection.
There are explicit allocation and release routines for the textual
representation of the data bytes, so that callers are free to chose
whether and how to decorate the dump and where to send the message.
2018-10-13 15:57:01 +02:00
Gerhard Sittig 08f8421a9e input/vcd: add channel list checks for file re-read
Keep (part of) previous results around when the VCD input module gets
reset, and check the header of the next import against previous runs to
avoid issues in applications. This addresses the VCD specific part of
bug #1241, and resolves the remaining part of bug #1306.
2018-10-13 15:17:51 +02:00
Gerhard Sittig 712f981dff device: introduce routines to compare channels and channel lists
Applications are not prepared to handle changes in the channel list
between multiple acquisitions from the same source (device drivers
or input modules). Introduce common helpers to compare channels and
channel lists.
2018-10-13 15:17:51 +02:00
Gerhard Sittig fe71c7e42e device: introduce common sr_channel_free() support code
There was the sr_channel_new() allocation routine, but releasing that
allocation was open-coded in call sites. Add the sr_channel_free()
routine for code re-use and consistency.
2018-10-13 15:06:43 +02:00
Gerhard Sittig 4237ab9e5b input/vcd: Expand the reset() logic
This addresses part of bug #1306. The reset() method of the VCD input
module was incomplete, and did not process new data upon second read.
Improve robustness and add missing reset instructions. Void invalid
pointers and avoid NULL dereferences in cleanup paths.
2018-10-13 15:04:50 +02:00
Gerhard Sittig 76f712a73f korad-kaxxxxp: add yet another KD3005P identification string
Apparently there are devices which identify as "KORADKD3005PV2.0" (no
whitespace, no trailing 0x01). Add another model entry.

Reported-By: Lars Pötter
2018-10-13 14:27:56 +02:00
Uwe Hermann 11cf492183 zeroplus-logic-cube: Only emit log message upon unexpected number of bytes. 2018-10-06 19:13:39 +02:00
Uwe Hermann 2377246220 Fix various gcc 8 compiler warnings related to ARRAY_SIZE.
Example:

  In file included from src/hardware/kecheng-kc-330b/protocol.h:26,
                   from src/hardware/kecheng-kc-330b/api.c:22:
  src/hardware/kecheng-kc-330b/api.c: In function ‘config_list’:
  src/libsigrok-internal.h:51:34: warning: division ‘sizeof (void *) / sizeof (void)’ does not compute the number of array elements [-Wsizeof-pointer-div]
   #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
                                    ^
  src/libsigrok-internal.h:55:32: note: in expansion of macro ‘ARRAY_SIZE’
   #define ARRAY_AND_SIZE(a) (a), ARRAY_SIZE(a)
                                  ^~~~~~~~~~
  src/libsigrok-internal.h:964:43: note: in expansion of macro ‘ARRAY_AND_SIZE’
    std_opts_config_list(key, data, sdi, cg, ARRAY_AND_SIZE(scanopts), \
                                             ^~~~~~~~~~~~~~
  src/hardware/kecheng-kc-330b/api.c:296:10: note: in expansion of macro ‘STD_CONFIG_LIST’
     return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
            ^~~~~~~~~~~~~~~
2018-10-06 19:13:39 +02:00
Peetz0r af930bcf7b fx2lafw: Add new VID:PID for usb-c-grok 2018-10-03 19:09:29 +02:00
Gerhard Sittig 7d40b5ee62 serial-dmm: introduce support for subdriver specific channel names
Default to the existing "P1" etc naming scheme for analog channels of
serial-dmm subdrivers. Add support for subdriver specific channel names
(which can reference the channel number if they desire). This is useful
for devices with multiple displays, or special purpose devices where
other names than P1 can better reflect the channel's nature.
2018-10-02 19:01:25 +02:00
Gerhard Sittig e91c9f6e25 serial-dmm: only send acquisition data for enabled channels
Respect the user's "channel enabled" status. Do not feed the session bus
when data for disabled channels was received.
2018-10-02 19:01:25 +02:00
Gerhard Sittig 48e2992f86 serial-dmm: count analog DMM channels starting at 1
Commit 556a926d43 introduced support for multiple displays in
subdrivers of serial-dmm, but also changed user visible channel numbers
to start from 0. Restore the previous behaviour, start counting from 1
which users may perceive as more natural (serial-dmm used to start at P1
in the past, scopes start with CH1 as well).
2018-10-02 19:01:25 +02:00
Gerhard Sittig 3ef305b079 brymen-bm86x: avoid NULL deref when usb->devhdl does not exist
There are code paths where dev_close() tries to access a USB handle
which does not exist. This was observed with this command:

  $ sigrok-cli -d brymen-bm86x --scan
2018-10-02 19:01:04 +02:00
Gerhard Sittig bd10287e7c Makefile: cosmetics, alpha-sort src/dmm/ entries 2018-10-02 19:01:04 +02:00
Uwe Hermann 822a9c0eda hantek-6xxx: Hantek 6022BL: Add VID/PID 04b5:602a support.
On Windows, this device can either enumerate as 04b4:602a or 04b5:602a,
depending on which vendor driver is currently being used, so we have to
support both in the hantek-6xxx driver as well.

This fixes bug #1295.
2018-10-02 15:15:27 +02:00
Martin Ling 56bcbbffd0 raw_analog: Set appropriate precision digits for sample format.
This fixes parts of bug #950.
2018-09-20 20:36:00 +02:00
Martin Ling cd1e7fd20d analog output: convert binary to digital digits of precision.
This fixes parts of bug #950.
2018-09-20 20:35:57 +02:00
Martin Ling 5e5fde6e2c Fix read past end of array in sr_analog_si_prefix_friendly.
In the case where the input unit was not in the array, the for loop would
complete, but the following test would then read past the end of the array
since 'i' would already have been incremented to the array size.

Spotted because unitless data was getting SI prefixes with no unit, though
this would not have been deterministically reproducible.

This fixes parts of bug #950.
2018-09-20 20:35:42 +02:00
Uwe Hermann 755793e991 scpi-pps: Add a missing "break" in config_get(). 2018-09-18 23:42:24 +02:00
Uwe Hermann 3bae09ab9f Make sr_packet_{copy,free} API calls public.
This fixes bug #1277.
2018-09-18 23:39:56 +02:00
Martin Ling 3d11872282 scpi-pps: Fix broken channel selection code.
Fixes bug #1279.
2018-09-11 13:08:12 +01:00
Martin Ling 88e4daa9ff scpi-pps: Use software sample and time limits. 2018-09-10 16:33:11 +01:00
Martin Ling 49f7cb2425 scpi-pps: Don't block waiting for a value on capture stop.
The comment says "A requested value is certainly on the way", but the code no
longer works this way. The receive handler requests a value and blocks until
it is received. There is no value pending between receive handler calls, so
this code now only leads to a timeout.
2018-09-10 16:12:58 +01:00
Martin Ling cda70c2c19 Add udev rules for Rigol DP800 series. 2018-09-10 13:51:17 +01:00
Uwe Hermann 04a0e0dc1c output/csv: Disable the dedup option by default.
Having this on by default is surprising to most users, since csv is
not usually associated with having a VCD-like dedup property/feature.
2018-09-05 21:50:02 +02:00
Uwe Hermann f696d27e05 std: Drop unneeded/duplicate log messages.
The sr_session_send() function will already log all of those anyway.
2018-09-05 20:31:48 +02:00
Andrej Valek ee1a7d2f9d hantek-4032l: Fix default threshold value selection (FP workaround).
Take value from generated array of range instead of using a hard-coded value.

Signed-off-by: Andrej Valek <andy@skyrain.eu>
2018-09-04 01:39:06 +02:00
Soeren Apel 653d087e15 std: Fix up non-zero FP value generation 2018-09-04 01:31:56 +02:00
Gerhard Sittig 0da8e0bd2b input: improve robustness, avoid NULL dereference in sr_input_send()
Applications might pass NULL for the buffer, and input modules might
accept it (or just cope). Eliminate a potential NULL dereference in
the emission of diagnostics messages.
2018-09-03 22:22:46 +02:00
Gerhard Sittig b736fa0c7d proto.h: move routine declaration to its respective group 2018-09-03 22:22:40 +02:00
Uwe Hermann 3ad0308c55 sr_resourcepaths_get(): Drop confusing log message.
This is not really needed and can sometimes confuse users.
2018-09-03 22:18:28 +02:00
Uwe Hermann 2efb3cd700 hantek-6xxx: Hantek 6022BE: Add VID/PID 04b5:6022 support.
On Windows, this device can either enumerate as 04b4:6022 or 04b5:6022,
depending on which vendor driver is currently being used, so we have to
support both in the hantek-6xxx driver as well.

This fixes bug #918.
2018-09-03 22:01:32 +02:00
Uwe Hermann 00f0016cc3 Consistently use the _WIN32 #define.
The _WIN32 variant is available pretty much on all compilers, others
might not be. G_OS_WIN32 would probably be an equally well-suited
alternative, but for now we standardize on _WIN32.

  http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system#WindowswithCygwinPOSIX
2018-09-01 21:11:45 +02:00
Uwe Hermann 9be587a148 ipdbg-la: Fix two compiler warnings on Windows.
This is happening because the send() and recv() functions
have different prototypes on POSIX and Windows. Using the casts
is required on Windows and doesn't hurt on POSIX systems.

  [...]/protocol.c: In function 'tcp_send':
  [...]/protocol.c:161:26: warning: pointer targets in passing argument 2 of 'send' differ in signedness [-Wpointer-sign]
    out = send(tcp->socket, buf, len, 0);
                            ^
  In file included from [...]/protocol.c:24:0:
  [...]/include/winsock2.h:997:34: note: expected 'const char *' but argument is of type 'const uint8_t * {aka const unsigned char *}'
     WINSOCK_API_LINKAGE int WSAAPI send(SOCKET s,const char *buf,int len,int flags);
                                    ^
  [...]/protocol.c: In function 'ipdbg_la_tcp_receive':
  [...]/protocol.c:201:32: warning: pointer targets in passing argument 2 of 'recv' differ in signedness [-Wpointer-sign]
      int len = recv(tcp->socket, buf, 1, 0);
                                  ^
  In file included from [...]/protocol.c:24:0:
  [...]/include/winsock2.h:992:34: note: expected 'char *' but argument is of type 'uint8_t * {aka unsigned char *}'
     WINSOCK_API_LINKAGE int WSAAPI recv(SOCKET s,char *buf,int len,int flags);
                                    ^
2018-09-01 21:08:10 +02:00
Uwe Hermann 3bfdadf6df ipdbg-la: Fix data_available() implementation on Windows.
[...]/protocol.c: In function 'data_available':
  [...]/protocol.c:73:38: error: 'bytes_available' undeclared (first use in this function)
    ioctlsocket(tcp->socket, FIONREAD, &bytes_available);
                                        ^
  [...]/protocol.c:73:38: note: each undeclared identifier is reported only once for each function it appears in
  [...]/protocol.c:84:1: warning: no return statement in function returning non-void [-Wreturn-type]
   }
   ^
2018-09-01 21:07:09 +02:00
Uwe Hermann 24fbd9f814 ipdbg-la: Fix a build issue on Windows.
[...]/protocol.c:41:23: fatal error: sys/ioctl.h: No such file or directory
2018-09-01 21:06:57 +02:00
Gerhard Sittig 4be5746d1d fx2lafw: silence error message in query for channel group's device options
The fx2lafw(4) driver supports mere logic analyzers as well as mixed
signal devices, but does not support channel group specific device
options. Avoid an error message when channel group device options get
queried, the condition is perfectly legal and non-fatal.

How to reproduce:
  $ pulseview -d fx2lafw
  $ sigrok-cli -d fx2lafw -g Logic --show

This fixes bug #1267.
2018-08-30 22:11:25 +02:00
Gerhard Sittig 1372bdcdb5 saleae and other FX2: show firmware name when loading fails
The "firmware load failed" message would be even more helpful if users
could learn which firmware file failed to load. Add those filenames to
various FX2-based drivers.

This addresses bug #1262.
2018-08-30 22:05:56 +02:00
Uwe Hermann ee425a466a Add a new sr_log_callback_get() API call. 2018-08-30 19:11:30 +02:00
Uwe Hermann 8bc8e9094c ipdbg-la: scan(): Use g_strdup_printf(). 2018-08-30 02:02:51 +02:00
Uwe Hermann 4d33f5e112 ipdbg-la: Make some functions static. 2018-08-30 01:56:35 +02:00
Uwe Hermann ac3625bef9 ipdbg-la: Avoid CamelCaps and ALLCAPS variable names. 2018-08-30 01:35:48 +02:00
Uwe Hermann 703fb45490 ipdbg-la: Drop some unneeded casts. 2018-08-30 01:22:10 +02:00
Uwe Hermann 4465837b7d ipdbg-la: data_available(): Return gboolean. 2018-08-30 01:22:10 +02:00
Uwe Hermann 3831eaf9f4 ipdbg-la: Use std_init() and std_dev_list(). 2018-08-30 01:22:02 +02:00
Uwe Hermann 4838c6ca5a ipdbg-la: Consistently use g_strerror(). 2018-08-30 00:53:18 +02:00
Uwe Hermann fac36d0a77 ipdbg-la: Drop unneeded g_malloc0() checks for small allocations. 2018-08-30 00:52:19 +02:00