Commit Graph

1476 Commits

Author SHA1 Message Date
Uwe Hermann d9251a2c9f Remove some unneeded double-spaces.
(also perform some other minor whitespace fixes while at it)
2016-08-29 21:51:27 +02:00
Uwe Hermann 2ecc745ccb device.c: Whitespace/cosmetics and typo fixes. 2016-08-29 21:51:27 +02:00
Uwe Hermann 8dc423b033 analog.c: Whitespace/cosmetics and typo fixes. 2016-08-29 21:51:27 +02:00
Uwe Hermann 7dcaddd3f0 Have remaining drivers default to digits=2 for analog values.
The default so far was 0, which meant there would be no significant
digits at all, yielding results that looked strange/wrong to the user.

Long-term all remaining drivers should be fixed to use the actual,
correct digits and spec_digits values according to the device's
capabilities and/or datasheet/manual. Until that is done, a default
of digits=2 is used as a temporary workaround.

This fixes the remaining parts of bug #815.
2016-08-29 00:25:19 +02:00
Uwe Hermann 869c837511 Document if or why sometimes digits/spec_digits is 0. 2016-08-29 00:25:19 +02:00
Aurelien Jacobs a005472fa2 appa-55ii: properly set encoding digits also for log memory reception 2016-08-29 00:25:19 +02:00
Aurelien Jacobs 962172e495 analog: improve output readability by using SI prefix 2016-08-29 00:25:19 +02:00
Aurelien Jacobs 6c1c13cdcd gwinstek-gds-800: properly set encoding digits 2016-08-29 00:25:18 +02:00
Aurelien Jacobs 417412c8f8 hantek-dso: properly set encoding digits 2016-08-29 00:25:18 +02:00
Aurelien Jacobs 1e1fdbc994 hantek-6xxx: properly set encoding digits 2016-08-29 00:25:18 +02:00
Aurelien Jacobs 545101338a hung-chang-dso-2100: properly set encoding digits 2016-08-29 00:25:18 +02:00
Aurelien Jacobs ad4c0275c2 baylibre-acme: properly set encoding digits 2016-08-24 02:39:40 +02:00
Aurelien Jacobs d043b29d5c tondaj-sl-814: properly set encoding digits 2016-08-24 01:01:23 +02:00
Aurelien Jacobs 53b4ea3921 kecheng-kc-330b: properly set encoding digits 2016-08-24 01:01:23 +02:00
Aurelien Jacobs dcb6fcbb7b colead-slm: properly set encoding digits 2016-08-24 01:01:23 +02:00
Aurelien Jacobs 8c50007222 cem-dt-885x: properly set encoding digits 2016-08-24 01:01:23 +02:00
Aurelien Jacobs f4bd8a1718 gmc-mh-1x-2x: properly set encoding digits 2016-08-24 01:01:23 +02:00
Aurelien Jacobs b66a0b5bdd mic-985xx: fix encoding digits 2016-08-23 12:58:06 +02:00
Aurelien Jacobs 1db537c3eb uni-t-ut32x: properly set encoding digits 2016-08-23 12:58:06 +02:00
Aurelien Jacobs fa2b19226d lascar-el-usb: properly set encoding digits 2016-08-23 12:58:05 +02:00
Aurelien Jacobs 0a2ffa3ebf center-3xx: properly set encoding digits 2016-08-23 12:58:05 +02:00
Aurelien Jacobs 0b8205504b kern-scale: properly set encoding digits 2016-08-23 12:58:05 +02:00
Aurelien Jacobs 3be044aa90 demo: properly set encoding digits 2016-08-23 12:58:05 +02:00
Aurelien Jacobs bcaadb366f motech-lps-30x: properly set encoding digits 2016-08-23 12:58:05 +02:00
Aurelien Jacobs 1af428d018 manson-hcs-3xxx: properly set encoding digits 2016-08-23 12:58:05 +02:00
Aurelien Jacobs 841c15a5fa korad-kaxxxxp: properly set encoding digits 2016-08-23 12:58:05 +02:00
Aurelien Jacobs fad810b502 atten-pps3xxx: properly set encoding digits 2016-08-23 12:58:05 +02:00
Aurelien Jacobs 24b6882ffa deree-de5000: properly set encoding digits 2016-08-23 12:58:05 +02:00
Aurelien Jacobs b8f07f4221 rigol-ds: properly set encoding digits 2016-08-23 12:58:05 +02:00
Aurelien Jacobs 6ed709fecd scpi-pps: properly set encoding digits 2016-08-23 12:58:05 +02:00
Aurelien Jacobs 4301f1726a maynuo-m97: properly set encoding digits 2016-08-23 12:58:04 +02:00
Aurelien Jacobs a66d44bee1 vc870: properly set encoding digits 2016-08-23 12:58:04 +02:00
Aurelien Jacobs 4f414d4cbe ut71x: properly set encoding digits 2016-08-23 12:58:04 +02:00
Aurelien Jacobs 47166326ef ut372: properly set encoding digits 2016-08-23 12:58:04 +02:00
Aurelien Jacobs 96a06b4203 rs9lcd: properly set encoding digits 2016-08-23 12:58:04 +02:00
Aurelien Jacobs e677490e58 metex14: properly set encoding digits
This closes bug #815.
2016-08-23 12:58:04 +02:00
Aurelien Jacobs 8882e7e6cf m2110: properly set encoding digits 2016-08-23 12:58:04 +02:00
Aurelien Jacobs aad6d8d206 fs9922: properly set encoding digits 2016-08-23 12:58:04 +02:00
Aurelien Jacobs 70e28e7802 fs9721: properly set encoding digits 2016-08-23 12:36:19 +02:00
Aurelien Jacobs 8cbf5627ba es519xx: properly set encoding digits 2016-08-23 12:36:19 +02:00
Aurelien Jacobs 427015d7c1 dtm0660: properly set encoding digits 2016-08-23 12:36:19 +02:00
Aurelien Jacobs 25198a7e89 brymen-bm25x: properly set encoding digits 2016-08-23 12:36:19 +02:00
Aurelien Jacobs 1baf30f5f7 brymen-bm86x: properly set encoding digits 2016-08-23 12:36:19 +02:00
Aurelien Jacobs 5fe1b5cc14 brymen-bm86x: remove redundant initilialization 2016-08-23 12:36:19 +02:00
Aurelien Jacobs 7b78449e40 appa-55ii: properly set encoding digits 2016-08-23 12:36:19 +02:00
Erik Montnemery 817b7441a1 hantek-6xxx: Ignore requests to set Hantek 6022BE coupling.
Here's a patch to "Ignore requests to set coupling for the Hantek 6022BE",
this clears the LIBUSB errors for me.

Also in the patch:

 - There is a crash because config_list() can be called with sdi == NULL.

   This can be reproduced by doing:
     "sigrok-cli.exe --driver hantek-6xxx --show"

 - There seems to be a very unsafe loop in config_set() when setting COUPLING;
   the coupling vector is assumed to be zero terminated, but is not declared
   as such.

   Note: The same issue is present also for other hardware, at least for
   hantek-dso/api.c. The patch is only for hantek-6xxx though.
2016-08-21 18:54:15 +02:00
Sebastian Zagrodzki 7f46b27ef2 hantek-6xxx: sdi might be NULL - don't assign devc until !sdi is checked. 2016-08-21 18:54:09 +02:00
Mike Meyer 0d8a3063e3 hantek-6xxx: Fix the device scan to not scan the NULL entry. 2016-08-21 18:53:55 +02:00
Aurelien Jacobs bf85ea2110 drivers: don't try to access the sr_driver_list section with no driver compiled.
This closes bug #820.
2016-08-15 01:45:50 +02:00
Benjamin Larsson 5eb4ba29d0 hantek-6xxx: only show DC coupling for the Hantek device 2016-08-15 01:16:54 +02:00
Uwe Hermann af7f88242e hantek-6xxx: Fix some issues by using power-of-two data sizes.
There were issues when using non-power-of-two data sizes with e.g.
the Hantek 6022BE device. For example, on Windows the acquisition would
simply hang and never complete:

  hantek-6xxx: receive_transfer(): status LIBUSB_TRANSFER_ERROR received 0 bytes

The issue was reported by Erik Montnemery on the mailing list, the
original patch was posted by "mmark" here (thanks!):

  http://www.eevblog.com/forum/testgear/sainsmart-dds120-usb-oscilloscope-(buudai-bm102)/msg911729/#msg911729

The issue has been verified by me on Windows and Linux, and also that
this change does indeed fix it (tested Hantek 6022BE and Sainsmart DDS120).

Neither PulseView nor sigrok-cli hang anymore on Windows, and on Linux
the log messages suggest improvements as well:

  -hantek-6xxx: data_amount 712
  +hantek-6xxx: data_amount: 200 (rounded to power of 2: 512)

  -hantek-6xxx: receive_transfer(): calculated samplerate == 2327ks/s
  -hantek-6xxx: receive_transfer(): status LIBUSB_TRANSFER_OVERFLOW received 512 bytes.
  +hantek-6xxx: receive_transfer(): calculated samplerate == 1969ks/s
  +hantek-6xxx: receive_transfer(): status LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED received 512 bytes.

This fixes bug #821.
2016-08-15 00:58:10 +02:00
Uwe Hermann 236303160c Fix a segfault with input/output modules.
Some functions in std.c were using

  const char *prefix = sdi->driver->name;

but were called from input/output modules as well (which don't have
a "driver" field).

As a temporary workaround, use "unknown" as prefix in such cases until
a more permanent solution is implemented.

This fixes bug #813.
2016-07-17 19:39:04 +02:00
Aurelien Jacobs ced4827405 ensure the only entry point of libdrivers doesn't have visibility=hidden
This fixes the following build issue on OSX:
Undefined symbols for architecture x86_64:
  "_sr_drivers_init", referenced from:
      _sr_init in backend.o

This closes bug #802.
2016-07-12 23:57:00 +02:00
Thomas 2f4b0f6a82 Add VID/PID for the CWAV USBee ZX.
The hardware is identical to the SX.

This fixes bug #764.
2016-07-12 23:50:52 +02:00
Uwe Hermann 0cce2383bd fx2lafw: Set sr_analog_encoding.digits to 2 for now. 2016-07-03 23:38:29 +02:00
Uwe Hermann 2ab0679a34 fx2lafw: Fix analog scaling.
Thanks to Patrick Remy <patrick.remy2000@gmail.com> for the fix.
2016-07-03 23:03:52 +02:00
Uwe Hermann e8b5205bf3 session.c: Drop unneeded check.
The dev_acquisition_stop() callback is not optional and always present.
2016-07-03 16:41:16 +02:00
Uwe Hermann 0e5a287759 uni-t-dmm: Drop unused UNI_T_UT_D04_NEW #define. 2016-07-03 16:40:44 +02:00
Aurelien Jacobs 43185ed3dc agilent-dmm: add support for U128x 2016-06-26 20:32:56 +02:00
Aurelien Jacobs 9ae544b6ce agilent-dmm: add support for Keysight branded meters 2016-06-26 20:32:56 +02:00
Aurelien Jacobs 0fe18626bd agilent-dmm: add support for AC/DC flags in current mode 2016-06-26 20:32:56 +02:00
Aurelien Jacobs 96ed86253b agilent-dmm: fix handling of AC/DC flags in volts mode 2016-06-26 20:32:56 +02:00
Aurelien Jacobs 4435966e43 agilent-dmm: output correct number of digits in analog packets 2016-06-26 20:32:56 +02:00
Aurelien Jacobs 873c0d117f agilent-dmm: split DIOD recv_conf into model specific functions
This reduce overall number of lines and facilitate computation
of significant digits.
2016-06-26 20:32:56 +02:00
Aurelien Jacobs 40df76aacb agilent-dmm: replace divider by exponent to ease computing of significant digits 2016-06-26 20:32:56 +02:00
Aurelien Jacobs 28c95cc6c4 analog: add support for negative number of digits
When a meter display 105.2 kΩ, libsigrok will return 105200 Ω
but it is really valuable to know that the last 2 digits are not
significant, so encoding.digits should be set to -2.
This would allow a sigrok client to display 105200 as 105.2 k
instead of 105.200 k.
2016-06-26 20:32:56 +02:00
Soeren Apel 4d6d660b83 Logging: Filter out unwanted newlines
055804e89e changed the outgoing
SCPI message termination by always adding a newline. This results
in the following log output:

sr: [00:00.003102] scpi: Opening VXI device vxi/192.168.178.43.
sr: [00:00.005648] scpi_vxi: Successfully sent SCPI command: '*IDN?
'.
sr: [00:00.005931] scpi: Got response: 'YOKOGAWA,710130,91HC30402,F3.73', length 31.

This patch restores the previous unterminated SCPI message logging:

sr: [00:00.005462] scpi: Opening VXI device vxi/192.168.178.43.
sr: [00:00.007515] scpi_vxi: Successfully sent SCPI command: '*IDN?'.
sr: [00:00.007860] scpi: Got response: 'YOKOGAWA,710130,91HC30402,F3.73', length 31.

As it's located in the general logging mechanism, we deal with any
additional (and unwanted) newlines this way.
2016-06-26 18:57:24 +02:00
Aurelien Jacobs e264ebded8 rigol-ds: properly report which channel is enabled. 2016-06-26 18:57:24 +02:00
Aurelien Jacobs 9ea62f2e0a rigol-ds: add support for getting/setting trigger level. 2016-06-25 18:19:47 +02:00
Aurelien Jacobs 934cf6cf50 rigol-ds: add PROBE_FACTOR support. 2016-06-25 17:24:45 +02:00
Aurelien Jacobs 8719638f5a rigol-ds: split out vertical config reading in its own function for re-use. 2016-06-25 17:23:17 +02:00
Aurelien Jacobs 5d8b3913d4 group all drivers into a single object
This single object also contains the sr_drivers_init function, that will
always be referenced. That ensures that the drivers object files won't
be optimized out during static linking due to the fact that they are
not referenced directly.

This addresses (parts of) bug #802.
2016-06-18 15:40:32 +02:00
Uwe Hermann d1d3d2e0c4 output/analog: Drop unused fancyprint() and si_printf().
These functions were only used in the SR_DF_ANALOG_OLD case,
whereas the SR_DF_ANALOG case already used functions and lists
from src/analog.c.

This closes bug #636.
2016-06-17 15:13:12 +02:00
Uwe Hermann 24f4a9d50b session: Drop SR_DF_ANALOG_OLD support completely.
This closes bug #728.
2016-06-17 15:13:12 +02:00
Uwe Hermann 0f574e133c transform/scale: Drop support for SR_DF_ANALOG_OLD. 2016-06-17 15:13:12 +02:00
Uwe Hermann 09e269ce21 transform/invert: Drop support for SR_DF_ANALOG_OLD. 2016-06-17 15:13:12 +02:00
Uwe Hermann 23bdb1c997 output/analog: Drop support for SR_DF_ANALOG_OLD. 2016-06-17 15:13:12 +02:00
Uwe Hermann 5379fea5ef output/csv: Drop support for SR_DF_ANALOG_OLD. 2016-06-17 15:13:12 +02:00
Uwe Hermann c163438617 output/wav: Drop support for SR_DF_ANALOG_OLD. 2016-06-17 15:13:12 +02:00
Uwe Hermann 6cdb1da6c9 session_driver.c: Convert to SR_DF_ANALOG. 2016-06-17 15:13:12 +02:00
Uwe Hermann 8c67724084 libsigrok-internal.h: Convert to SR_DF_ANALOG. 2016-06-17 15:13:11 +02:00
Uwe Hermann 44040ea65e yokogawa-dlm: Convert to SR_DF_ANALOG. 2016-06-17 15:13:11 +02:00
Uwe Hermann 16544b3856 uni-t-ut32x: Convert to SR_DF_ANALOG. 2016-06-17 15:13:11 +02:00
Uwe Hermann dff60e3ccc uni-t-dmm: Convert to SR_DF_ANALOG. 2016-06-17 15:13:11 +02:00
Uwe Hermann f8467403e6 testo: Convert to SR_DF_ANALOG. 2016-06-17 15:13:11 +02:00
Uwe Hermann c8d9a71e43 teleinfo: Convert to SR_DF_ANALOG. 2016-06-17 15:13:11 +02:00
Uwe Hermann ffa2b6f96c serial-dmm: Convert to SR_DF_ANALOG. 2016-06-17 15:13:11 +02:00
Uwe Hermann 0de290a53e scpi-pps: Convert to SR_DF_ANALOG. 2016-06-17 15:13:11 +02:00
Uwe Hermann 94885d200d maynuo-m97: Convert to SR_DF_ANALOG. 2016-06-17 15:13:11 +02:00
Uwe Hermann ddfe99d92f motech-lps-30x: Convert to SR_DF_ANALOG. 2016-06-17 15:13:11 +02:00
Uwe Hermann 5ba417591c lascar-el-usb: Convert to SR_DF_ANALOG. 2016-06-17 15:13:11 +02:00
Uwe Hermann 2c9111820a kecheng-kc-330b: Convert to SR_DF_ANALOG. 2016-06-17 15:13:10 +02:00
Uwe Hermann 99f8fa2519 hung-chang-dso-2100: Convert to SR_DF_ANALOG. 2016-06-17 15:13:10 +02:00
Uwe Hermann ae7d8a58de hantek-dso: Convert to SR_DF_ANALOG. 2016-06-17 15:13:10 +02:00
Uwe Hermann 6cfb9729b0 gwinstek-gds-800: Convert to SR_DF_ANALOG. 2016-06-17 15:13:10 +02:00
Uwe Hermann f074822500 gmc-mh-1x-2x: Convert to SR_DF_ANALOG. 2016-06-17 15:13:10 +02:00
Uwe Hermann a6ad49b39f fx2lafw: Convert to SR_DF_ANALOG. 2016-06-16 15:05:04 +02:00
Uwe Hermann a8372c3ed9 colead-slm: Convert to SR_DF_ANALOG. 2016-06-16 15:05:04 +02:00
Uwe Hermann 4b770103e9 demo: Convert to SR_DF_ANALOG. 2016-06-16 15:05:04 +02:00
Uwe Hermann 7f9932e8db cem-dt-885x: Convert to SR_DF_ANALOG. 2016-06-16 15:05:04 +02:00
Uwe Hermann 3f5cf2a06a fluke-dmm: Convert to SR_DF_ANALOG. 2016-06-16 15:05:03 +02:00
Uwe Hermann 1653c4309a brymen-dmm: Convert to SR_DF_ANALOG. 2016-06-16 15:05:03 +02:00
Uwe Hermann a46f869b64 brymen-bm86x: Convert to SR_DF_ANALOG. 2016-06-16 15:05:03 +02:00
Uwe Hermann 633531416b baylibre-acme: Convert to SR_DF_ANALOG. 2016-06-16 15:05:03 +02:00
Uwe Hermann 55bee166eb norma-dmm: Convert to SR_DF_ANALOG. 2016-06-16 15:05:02 +02:00
Uwe Hermann 67eb7c6bdf atten-pps3xxx: Convert to SR_DF_ANALOG. 2016-06-16 15:05:02 +02:00
Uwe Hermann 0417ada03e appa-55ii: Convert to SR_DF_ANALOG. 2016-06-16 15:05:02 +02:00
Uwe Hermann 16aef67634 agilent-dmm: Convert to SR_DF_ANALOG. 2016-06-16 15:05:02 +02:00
Uwe Hermann d4f59ce86d center-3xx: Convert to SR_DF_ANALOG. 2016-06-16 15:05:02 +02:00
Uwe Hermann 563ba4a5c2 kern-scale: Convert to SR_DF_ANALOG. 2016-06-16 15:05:01 +02:00
Uwe Hermann 246399f788 rigol-ds: Convert to SR_DF_ANALOG. 2016-06-16 15:05:01 +02:00
Uwe Hermann 2e71534118 korad-kaxxxxp: Convert to SR_DF_ANALOG. 2016-06-16 15:05:01 +02:00
Uwe Hermann 2938c9d1d3 hantek-6xxx: Convert to SR_DF_ANALOG. 2016-06-16 15:05:01 +02:00
Uwe Hermann 2463ec77fe manson-hcs-3xxx: Convert to SR_DF_ANALOG. 2016-06-16 15:05:01 +02:00
Uwe Hermann c68ade3cc7 tondaj-sl-814: Convert to SR_DF_ANALOG. 2016-06-16 15:05:01 +02:00
Uwe Hermann b02bb45f4c dmm: Convert to SR_DF_ANALOG. 2016-06-16 15:05:00 +02:00
Uwe Hermann 7ffcf58736 lcr: Convert to SR_DF_ANALOG. 2016-06-16 15:05:00 +02:00
Uwe Hermann c6d527478a scale: Convert to SR_DF_ANALOG. 2016-06-15 19:33:48 +02:00
Uwe Hermann 0f33aaef54 input/wav: Convert to SR_DF_ANALOG. 2016-06-15 19:33:48 +02:00
Yasushi SHOJI 716d6dfcac zeroplus: Fix config_list() wrt drvopts/devopts.
When config_list() gets NULL as sdi, it must return driver opts.
Some drivers, including zeroplus, don't check sdi and return both
driver opts and device opts.
2016-06-11 17:09:34 +02:00
Uwe Hermann 3ba944cf41 sw_limits: Log when the sample/time limit is reached. 2016-06-01 15:25:15 +02:00
Lars-Peter Clausen 4b1a9d5d86 Remove unnecessary std_serial_dev_acquisition_stop() wrappers
Now that std_serial_dev_acquisition_stop() has the same signature as
the sr_dev_driver dev_acquisition_stop() callback it is possible to remove
the wrapper functions and use std_serial_dev_acquisition_stop() directly
has the callback function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-31 15:54:53 +02:00
Lars-Peter Clausen 1b38775baa std_serial_dev_acquisition_stop(): Remove dev_close_fn parameter
All callers of std_serial_dev_acquisition_stop() currently pass the same
callback for the dev_close_fn parameter as the dev_close callback of their
sr_dev_driver struct. Remove the dev_close_fn parameter and invoke the
drivers dev_close() callback directly. This simplifies the API and ensures
consistent behaviour between different drivers.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-31 15:54:52 +02:00
Lars-Peter Clausen 15f96409dc std_serial_dev_acquisition_stop(): Remove serial parameter
All callers of std_serial_dev_acquisition_stop() currently pass sdi->conn
for the serial parameter. And the other std_serial helper functions already
require that the conn field of the sr_driver_inst passed to the functions
points to the sr_serial_dev_inst associated with the device.

Modify std_serial_dev_acquisition_stop() to follow the same pattern and
remove the serial parameter. This simplifies the API and ensures consistent
behaviour between different drivers.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-31 15:54:52 +02:00
Lars-Peter Clausen bee2b0168c Use driver name as the log prefix in standard functions
Some of the standard helper functions take a log prefix parameter that is
used when printing messages. This log prefix is almost always identical to
the name field in the driver's sr_dev_driver struct. The only exception are
drivers which register multiple sr_dev_driver structs.

Instead of passing the log prefix as a parameter simply use the driver's
name. This simplifies the API, gives consistent behaviour between different
drivers and also makes it easier to identify where the message originates
when a driver registers sr_dev_driver structs.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-31 15:54:52 +02:00
Lars-Peter Clausen 7d786a962d pce-322a: Pass driver dev_close callback std_serial_dev_acquisition_stop()
All drivers with the exception of pce-322a pass their dev_close callback to
std_serial_dev_acquisition_stop(). The pce-322a passes std_serial_dev_close()
which is also called from its dev_close() callback and replicates the other
functionality of its dev_close() callback directly in
std_serial_dev_acquisition_stop().

Refactor this to pass the dev_close callback function directly to
std_serial_dev_acquisition_stop(). This makes sure that the driver is
consistent with other drivers and also removes duplicated code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-31 15:54:52 +02:00
Lars-Peter Clausen 580b94e4d7 sw_limits: Add documentation
Add documentation for the software limits module.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-31 15:54:52 +02:00
Lars-Peter Clausen 3c41387928 gmc-mh-1x-2x: Use software limits helpers
Use the new software limit helper functions rather than open-coding their
functionality.

This also fixes the issue that driver the does not reset all the limit
statistics in acquisition_start().

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-31 15:54:52 +02:00
Lars-Peter Clausen 6aacf011de fluke-dmm: Use software limits helpers
Use the new software limit helper functions rather than open-coding their
functionality.

This also fixes the issue that the driver does not reset the limit
statistics in acquisition_start(). It also makes the time limit work, which
previously was only a stub implementation.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-31 15:54:52 +02:00
Lars-Peter Clausen 014c7f93d4 arachnid-labs-re-load-pro: Use software limit helpers
Use the new software limit helper functions rather than open-coding their
functionality.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-31 15:54:52 +02:00
Lars-Peter Clausen 5b6829eafe agilent-dmm: Use software limits helpers
Use the new software limit helper functions rather than open-coding their
functionality.

This also fixes the issue that the driver does not reset the limit
statistics in acquisition_start(). It also makes the time limit work, which
previously was only a stub implementation.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-31 15:54:46 +02:00
Lars-Peter Clausen eabfed20f7 norma-dmm: Remove unused version field from state struct
The version field in the norma-dmm driver state struct is initialized, but
never read and the same information is also already available in the
sr_dev_inst struct version field. So remove it to simplify the code.

This allows to get rid of the custom dev_close() callback and just use the
standard std_serial_dev_close() instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-28 12:52:05 +02:00
Uwe Hermann cd0de200b1 Fix a few "variable set but not used" compiler warnings.
../src/hardware/appa-55ii/api.c: In function ‘scan’:
../src/hardware/appa-55ii/api.c:47:22: warning: variable ‘drvc’ set but not used [-Wunused-but-set-variable]
  struct drv_context *drvc;
                      ^
../src/hardware/arachnid-labs-re-load-pro/api.c: In function ‘scan’:
../src/hardware/arachnid-labs-re-load-pro/api.c:62:22: warning: variable ‘drvc’ set but not used [-Wunused-but-set-variable]
  struct drv_context *drvc;
                      ^
../src/hardware/atten-pps3xxx/api.c: In function ‘scan’:
../src/hardware/atten-pps3xxx/api.c:81:22: warning: variable ‘drvc’ set but not used [-Wunused-but-set-variable]
  struct drv_context *drvc;
                      ^
../src/hardware/brymen-dmm/api.c: In function ‘scan’:
../src/hardware/brymen-dmm/api.c:89:22: warning: variable ‘drvc’ set but not used [-Wunused-but-set-variable]
  struct drv_context *drvc;
                      ^
../src/hardware/cem-dt-885x/api.c: In function ‘scan’:
../src/hardware/cem-dt-885x/api.c:74:22: warning: variable ‘drvc’ set but not used [-Wunused-but-set-variable]
  struct drv_context *drvc;
                      ^
../src/hardware/conrad-digi-35-cpu/api.c: In function ‘scan’:
../src/hardware/conrad-digi-35-cpu/api.c:45:22: warning: variable ‘drvc’ set but not used [-Wunused-but-set-variable]
  struct drv_context *drvc;
                      ^
../src/hardware/demo/demo.c: In function ‘scan’:
../src/hardware/demo/demo.c:255:22: warning: variable ‘drvc’ set but not used [-Wunused-but-set-variable]
  struct drv_context *drvc;
                      ^
../src/hardware/fluke-dmm/api.c: In function ‘fluke_scan’:
../src/hardware/fluke-dmm/api.c:64:22: warning: variable ‘drvc’ set but not used [-Wunused-but-set-variable]
  struct drv_context *drvc;
                      ^
../src/hardware/gmc-mh-1x-2x/api.c: In function ‘scan_1x_2x_rs232’:
../src/hardware/gmc-mh-1x-2x/api.c:147:22: warning: variable ‘drvc’ set but not used [-Wunused-but-set-variable]
  struct drv_context *drvc;
                      ^
../src/hardware/gmc-mh-1x-2x/api.c: In function ‘scan_2x_bd232’:
../src/hardware/gmc-mh-1x-2x/api.c:234:22: warning: variable ‘drvc’ set but not used [-Wunused-but-set-variable]
  struct drv_context *drvc;
                      ^
../src/hardware/ikalogic-scanaplus/api.c: In function ‘scan’:
../src/hardware/ikalogic-scanaplus/api.c:69:22: warning: variable ‘drvc’ set but not used [-Wunused-but-set-variable]
  struct drv_context *drvc;
                      ^
../src/hardware/tondaj-sl-814/api.c: In function ‘scan’:
../src/hardware/tondaj-sl-814/api.c:44:22: warning: variable ‘drvc’ set but not used [-Wunused-but-set-variable]
  struct drv_context *drvc;
                      ^
2016-05-27 15:11:28 +02:00
Uwe Hermann 39fcfdc9da std_scan_complete(): Catch some errors to avoid segfaults.
Check some variables for NULL before dereference to avoid segfaults due
to buggy drivers (and show error messages so these issues are noticed early).
2016-05-27 14:45:26 +02:00
Lars-Peter Clausen 43376f3324 Simplify single device list handling
Some driver scan() functions only ever return a single device. For those it
is possible to slightly simplify the handling of the device list by
creating it on demand when the function returns.

Some drivers also have the following expression:
	devices = g_slist_append(devices, sdi);
	...
	if (!devices)
		...

This check will never evaluate to false so it is dropped as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-27 14:44:24 +02:00
Lars-Peter Clausen 15a5bfe481 Add helper function for scan completion
A common task during device scan is to add the newly discovered devices to
the instance list of the driver. Currently this is done by each driver on
its own. This patch introduces a new helper function std_scan_complete()
which takes care of this. The function should be called at the end of a
driver's scan() callback before returning the device list.

Doing this with a helper function provides guaranteed consistent behaviour
among drivers and hopefully paves the way to moving more standard
functionality directly into the sigrok core.

Another common task that every driver has to do for each device instance is
to initialize the device's driver field. So this is done in the new helper
function as well.

All drivers that can make use of the new helper are updated.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-27 14:44:24 +02:00
Lars-Peter Clausen 566007e15e Don't reset instance list in scan() callback
Some drivers set the device instance list to NULL in their scan() callback.
This means the driver loses all references to any devices contained in that
list and their resources will be leaked. Drivers can't free the devices at
this point either since an application might still use a device on the
list. So the existing devices on the instance list need to remain
unmodified during the scan() callback, even if that means that there will
be duplicates on the instance list. Only an explicit invocation of
sr_dev_clear() by the application is allowed to free the devices on the
instance list and reset the list.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-27 14:43:34 +02:00
Uwe Hermann 176d18cab1 testo: Minor indentation fixes. 2016-05-26 17:47:28 +02:00
Lars-Peter Clausen f53ff64369 link-mso19: mso_receive_data: Simplify device instance lookup
The link-mso19 driver currently iterates the device instance list of the
driver to get the device instance for which the callback is called.

But the device instance is actually passed to the callback as the cb_data
parameter, so just use that instead and remove the lookup loop.

Besides that the current lookup loop does not even compile either.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-23 18:25:24 +02:00
Lars-Peter Clausen e5ff8e9e0a link-mso19: Use default dev_clear() handler
The link-mso19 open-codes the std_dev_clear() function and uses it as its
custom dev_clear() callback. The std_dev_clear() function is automatically
called if no custom dev_clear() callback is specified, so just drop custom
implementation and use the default.

This also fixes a memory leak where the link-mso19 driver did not properly
free its driver state struct in the dev_clear() callback.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-23 18:24:58 +02:00
Lars-Peter Clausen f1e93a951e link-mso19: Drop unnecessary NULL check
sdi is allocated using g_malloc0() which can never fail, in addition to
that sdi is already dereferenced before the check, which makes the check
useless. So remove it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-23 18:24:23 +02:00
Alexandru Gagniuc e76a357536 scpi-pps: Add profile for HP 6633A supply
Oldie but goodie. Some of the HP 6632B options are renamed for
clarity, as they are common among the A and B variants.
2016-05-19 08:16:51 -07:00
Alexandru Gagniuc c2af709b01 scpi-pps: Add shadow driver for HPIB supplies (ID? instead of *IDN?)
HP instruments predating the 488.2 and SCPI standards do not
necessarily have a SCPI-compliant command set. The HP6630A series of
supplies is one such example.

While scpi-pps is flexible enough to accomodate almost any command
syntax given the right profile, it still assumes that "*IDN?" is the
correct question to ask the instrument. Since older HP gear instead
responds to "ID?", this assumption is no longer true.

Thus sr_scpi_get_hw_id() is not appropriate for these instruments, and
the shadow driver added here only replaces that function call, while
reusing the rest of the existing logic. The extra noise is necessary
in order to propagate this through the .scan member of the driver.
2016-05-19 08:16:46 -07:00
Marcus Comstedt cb193a2093 saleae-logic16: Consolidate the samplerate limits into a single bitrate cap 2016-05-18 23:12:49 +02:00
Marcus Comstedt 41dab43ef9 saleae-logic16: Add 20MHz and 50MHz to samplerate preset list (bug #799) 2016-05-18 23:12:38 +02:00
George Hopkins 5a2c71ccd7 pce-322a: Initial driver implementation. 2016-05-18 18:28:08 +02:00
Lars-Peter Clausen 634d72997a ftdi-la: Use the standard connection_id field for the device address
Use the standard connection_id field from the struct sr_dev_inst for
storing the device address rather than using the custom address field in
the driver state struct. This makes things more consistent with the
framework.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-18 18:15:33 +02:00
Lars-Peter Clausen 07a917521a ftdi-la: Cleanup ftdi_context handling
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-18 17:42:52 +02:00
Uwe Hermann 0350e2e030 lascar-el-usb: Add a missing SR_PRIV. 2016-05-18 01:41:55 +02:00
Lars-Peter Clausen dd5c48a6d5 Put driver pointers into special section
The sigrok core needs a list of all available drivers. Currently this list
is manually maintained by updating a global list whenever a driver is added
or removed.

Introduce a new special section that contains the list of all drivers. The
SR_REGISTER_DEV_DRIVER() and SR_REGISTER_DEV_DRIVER_LIST() macro is used to
add drivers to this new list. This is done by placing the pointers to the
driver into a special section. Since nothing else is in this section it is
known that it is simply a list of driver pointers and the core can iterate
over it as if it was an array.

The advantage of this approach is that the code necessary to add a driver
to the list is completely contained to the driver source and it is no
longer necessary to maintain a global list. If a driver is built it will
automatically appear in the list, if it is not built in won't. This means
that the list is always correct, whereas the previous approach used ifdefs
in the global driver list file which could get out-of-sync with the actual
condition when the driver was built.

Any sr_dev_driver structs that are no longer used outside the driver module
are marked as static.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-18 01:41:55 +02:00
Lars-Peter Clausen e32862ebcc Drop unnecessary struct sr_dev_driver forward declarations
Most drivers have a forward declaration to their sr_dev_driver struct at
the beginning of the driver file. This is due to historic reasons and often
no longer required. So remove all the unnecessary forward declarations.

Some drivers still require the forward declaration, but only reference the
driver struct from within the driver scan() callback. Since the driver
struct is passed to the scan callback replace the references to the global
variable with the local parameter. In some cases this requires adding the
parameter to some of the helper functions that are called from the scan()
callback.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-17 23:38:05 +02:00
Uwe Hermann 4d399734b4 config_list: Don't check for sdi->priv != NULL.
If sdi is != NULL, the backend ensures that sdi->priv is also != NULL.
Almost all drivers were relying on this already.
2016-05-17 01:12:56 +02:00
Uwe Hermann 709468baf7 config_get(): Don't check for sdi->priv != NULL.
If sdi is != NULL, the backend ensures that sdi->priv is also != NULL.
Almost all drivers were relying on this already.
2016-05-17 01:12:56 +02:00
Uwe Hermann b0baddef56 config_set(): Don't check for sdi->priv != NULL.
Instead, have the backend check that sdi->priv is not NULL (which
many drivers have been assuming already anyway).
2016-05-17 01:12:56 +02:00
Stefan Brüns e5b7eef797 hameg-hmo: add one missing g_free 2016-05-16 23:35:10 +02:00
Stefan Brüns b05ab7d272 hameg-hmo: Add comment clarifying coupling options
50 Ohm termination is only available on the higher end scopes.
2016-05-16 23:35:10 +02:00
Stefan Brüns 401b83a154 hameg-hmo: use SR_DF_ANALOG, use definite length blocks for retrieval
Using binary formats is about 3 times faster than ASCii format. This
addresses bug #791.
2016-05-16 23:35:10 +02:00
Stefan Brüns 448e81b1e5 hameg-hmo: Query probe unit (Volt, Ampere) from scope 2016-05-16 23:35:10 +02:00
Stefan Brüns 2d7da5df82 scpi: introduce some more requests 2016-05-16 23:35:10 +02:00
Stefan Brüns ff01b0ea2f scpi: Add support for arbitray/definite length block data retrieval
Binary block data is specified in IEEE 488.2. First character is '#',
followed by a single ascii digit denoting the the number of digits needed
for the length specification. Length is given in bytes.

This allows drivers to replace retrieval of comma separated ASCII values
with binary formats. See bug #791.
2016-05-16 23:35:10 +02:00
Stefan Brüns b951fae32c scpi_vxi: Fix incomplete reads (bug #790) 2016-05-16 23:35:10 +02:00
Stefan Brüns a53acd7d46 hameg-hmo: simplify code by using new sr_rational_parse/_eq API functions 2016-05-16 23:35:10 +02:00
Stefan Brüns 17d5a11c69 analog: Implement division for sr_rational 2016-05-16 23:35:10 +02:00
Stefan Brüns ee1b6054d6 analog: Implement multiplication for sr_rational 2016-05-16 23:35:10 +02:00
Stefan Brüns bdba362695 analog: Add equality check for sr_rational 2016-05-16 23:35:10 +02:00
Stefan Brüns 5ec172d7e9 strutil: add method to get an sr_rational from a string
The method accepts strings with numbers in scientific or normal notation,
e.g. -1.25 or 3.37e-6. The numeric range is limited by the sr_rational
range, i.e +-9.2e18, resolution is ~19 digits.
2016-05-16 23:35:10 +02:00
Stefan Brüns 510aa8281f hameg-hmo: Add PATTern and BUS1/BUS2 trigger sources 2016-05-16 23:35:10 +02:00
Uwe Hermann 9803346fe2 fx2lafw/dslogic: Various cosmetics and whitespace fixes. 2016-05-16 18:18:59 +02:00
Diego Asanza a04b28ce2c dslogic: Fix sampling for high samplerates.
This patch fixes sampling at 100MHz, 200MHz and 400MHz.

Signed-off-by: Diego Asanza <f.asanza@gmail.com>
2016-05-16 18:18:59 +02:00
Diego Asanza a9a9bfaa6a dslogic: Add support for long captures at high samplerates.
To capture more than 16MSamples the hardware run length encoding option
must be enabled, or captured data present errors.

RLE encoding/decoding is done in hardware. Data streamed to the USB interface
is not encoded.

This commit enables RLE encoding for captures longer than 16MSamples.

Signed-off-by: Diego Asanza <f.asanza@gmail.com>
2016-05-16 18:18:59 +02:00
Diego Asanza d9a58763d6 dslogic: Add support for external clock edge selection.
This commit expands support for acquisition using an external clock,
now allowing the user to select the clock edge.

Signed-off-by: Diego Asanza <f.asanza@gmail.com>
2016-05-16 18:18:59 +02:00
Diego Asanza 41dc254778 dslogic: Implement continuous mode
For low sampling speeds (up to 25MHz) DSLogic offers a streaming mode where
samples are sent directly to the USB interface, like a fx2lafw device.

For high sampling speeds (up to 400MHz) only buffer mode is supported.

This commit allows the user to set which mode should be used. The configuration
is done by using SR_CONF_CONTINUOUS.

Signed-off-by: Diego Asanza <f.asanza@gmail.com>
2016-05-16 18:18:58 +02:00
Diego Asanza 20d8ae41f4 Change type of SR_CONF_CONTINUOUS from SR_T_UINT64 to SR_T_BOOL
SR_CONF_CONTINUOUS is used to check if a device supports continuous sampling
or not. As such, the type boolean is better suited.

Signed-off-by: Diego Asanza <f.asanza@gmail.com>
2016-05-16 18:18:58 +02:00
Diego Asanza ea3a77c756 dslogic: Implement acquisition with external clock.
DSLogic hardware provides an external clock input.
This commit adds support for this capability.

Signed-off-by: Diego Asanza <f.asanza@gmail.com>
2016-05-16 18:18:58 +02:00
Diego Asanza 3fc3fbe46e dslogic: Add support for voltage threshold
The DSLogic provides two FPGA images: one for 3.3V and the other for 5V logic.
The DSLogic Pro allows to set an arbitrary voltage threshold via USB command.

This commit adds support for the DSLogic to load the FPGA image according to
an user-selectable voltage threshold.

For the DSLogic Pro, one of two fixed voltage thresholds are set, depending on
the user-selected value.

Tested with DSLogic and DSLogic Pro.

Signed-off-by: Diego Asanza <f.asanza@gmail.com>
Tested-by: Andrew Bradford <andrew@bradfordembedded.com>
2016-05-16 18:18:58 +02:00
Diego Asanza 4237fbcaac dslogic: Implement trigger functionality
This commit implements DSLogic trigger functionality.

The following triggers are working:

 - trigger on rising edge
 - trigger on falling edge
 - trigger on any edge
 - trigger on logic one
 - trigger on logic zero

Pre-trigger capture ratio is also working.

Signed-off-by: Diego Asanza <f.asanza@gmail.com>
Tested-by: Andrew Bradford <andrew@bradfordembedded.com>
2016-05-16 17:57:07 +02:00
Lars-Peter Clausen f18e0db3b8 demo: Handle the case when zero analog or logic channels were requested
The demo device has support for specifying the number of analog and logic
channels it should have. Currently this does not work correctly if one of
them is set to zero. Being able to set the number of channels to zero for
one of the channel types is quite useful for corner case testing though.

Make the following modifications to handle it correctly:

1) If the channel count is zero no channel group for that channel type
should be created since a channel group needs at least one channel.

2) Drop the check if logic_unitsize is less or equal to zero in
prepare_data() since this condition will always be true if the number of
logic channels is zero and it is not possible to create a demo device with
only analog channels.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-14 01:06:20 +02:00
Lars-Peter Clausen 7e2f42214a srzip: zip_append_analog(): Fix memory leaks
zip_append_analog() does not free most of the memory it allocates. Address
this by moving all sanity checks that do not rely on anything else at the
beginning of the function before any allocations are done. And then make
sure to properly free all allocated memory on all paths leaving the
function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-14 01:02:00 +02:00
Lars-Peter Clausen 9906dbf5a4 srzip: Fix handling of analog channels with index 0
0 is a valid index for a channel. Using it as the value for the terminating
entry of analog_index_map causes zip_append_analog() to falsely assume that
no channel was found when a packet for a channel with index 0 was received.
This prevents the data for the channel to be added to the sigrok session
file.

Instead use -1, which is not a valid channel index, as
the terminating entry value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-14 01:02:00 +02:00
Uwe Hermann 45884333ff scan(): Consistently start out with SR_ST_INACTIVE.
A later call to open() will set the status to SR_ST_ACTIVE.

Only in the case of firmware/bitstream upload start with
SR_ST_INITIALIZING first.
2016-05-12 14:59:56 +02:00
Uwe Hermann e91d4ce2b2 fx2lafw: Fix a -Wself-assign compiler warning.
This closes bug #793.
2016-05-12 14:59:48 +02:00
Lars-Peter Clausen c2fdcc25a4 Remove unnecessary std_init() wrapper functions
Now that the signature of std_init() matches that of the driver init()
callback we can remove all wrapper functions around std_init() and use it
directly as the init() callback.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 15:10:26 +02:00
Lars-Peter Clausen c45c32ce47 std_init(): Drop check if pass in driver is non-NULL
std_init() checks if the pass in struct sr_dev_driver is non-NULL and
prints a error message and returns an error if it is NULL.

std_init() is exclusively called from driver init() callbacks for which the
core already checks if the struct sr_dev_driver is non-NULL before invoking
the callback. This means the check in std_init() will always evaluate to
false. So drop this check.

This also means that the prefix parameter that was used in the error
message is no longer needed and can be removed from the function signature.
Doing so will make the std_init() function signature identical to the
init() callback signature which will allow to directly use it as such.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 15:10:26 +02:00
Lars-Peter Clausen 1f8f5bc08e Match std_init() parameter order to the driver init() callback
The std_init() callback has the order of the first two paramters opposite
to the init() callback. This is primarily due to historical development.

Since the std_init() function is usually called from a driver's init()
callback aligning the order will allow direct register pass through rather
than having to swap them around. It also allow to eventually use the
std_init() function directly as the init() callback.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 15:10:26 +02:00
Lars-Peter Clausen 87629577fe zeroplus-logic-cube: Fix USB device list
The zeroplus-logic-cube driver uses libusb_get_device_list() but neglects
to call the matching libusb_device_list_free() on the error path. This will
leak the memory allocated for the list as well as all the devices.

To address the issue use sr_usb_open() instead of open-coding its
functionality. sr_usb_open() correctly handles freeing the device list.

The issue was discovered using the following coccinelle semantic patch:
// <smpl>
@@
identifier devlist;
expression ctx, ret;
statement S;
@@
(
 libusb_get_device_list(ctx, &devlist);
|
 ret = libusb_get_device_list(ctx, &devlist);
 if (ret < 0) S
)
... when != libusb_free_device_list(devlist, ...)
*return ...;
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 14:17:33 +02:00
Lars-Peter Clausen 4af1f68f9a victor-dmm: Fix USB device list leak
The victor-dmm driver uses libusb_get_device_list() but neglects to call
the matching libusb_device_list_free() on the error path of libusb_open().
This will leak the memory allocated for the list as well as all the
devices.

To address the issue use sr_usb_open() instead of open-coding its
functionality. sr_usb_open() correctly handles freeing the device list.

The issue was discovered using the following coccinelle semantic patch:
// <smpl>
@@
identifier devlist;
expression ctx, ret;
statement S;
@@
(
 libusb_get_device_list(ctx, &devlist);
|
 ret = libusb_get_device_list(ctx, &devlist);
 if (ret < 0) S
)
... when != libusb_free_device_list(devlist, ...)
*return ...;
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 14:17:08 +02:00
Lars-Peter Clausen b75dc14a94 testo: Fix USB device list leak
The testo driver uses libusb_get_device_list() but neglects to call the
matching libusb_device_list_free() on the error path. This will leak the
memory allocated for the list as well as all the devices.

To address the issue use sr_usb_open() instead of open-coding its
functionality. sr_usb_open() correctly handles freeing the device list.

The issue was discovered using the following coccinelle semantic patch:
// <smpl>
@@
identifier devlist;
expression ctx, ret;
statement S;
@@
(
 libusb_get_device_list(ctx, &devlist);
|
 ret = libusb_get_device_list(ctx, &devlist);
 if (ret < 0) S
)
... when != libusb_free_device_list(devlist, ...)
*return ...;
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 13:32:23 +02:00
Lars-Peter Clausen ceb2da179f lascar-el-usb: lascar_scan(): Fix USB device list leak
lascar_scan() calls libusb_get_device_list() but never the matching
libusb_free_device_list(). This will leak the memory allocated for the
device list as well as all the devices. To fix this add the missing
libusb_free_device_list().

While we are at it also make sure to handle errors returned by
libusb_get_device_list().

The issue was discovered using the following coccinelle semantic patch:
// <smpl>
@@
identifier devlist;
expression ctx, ret;
statement S;
@@
(
 libusb_get_device_list(ctx, &devlist);
|
 ret = libusb_get_device_list(ctx, &devlist);
 if (ret < 0) S
)
... when != libusb_free_device_list(devlist, ...)
*return ...;
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 13:32:23 +02:00
Soeren Apel 6266deb84d Input/trace32_ad: Make the sample rate an option 2016-05-09 13:02:47 +02:00
Soeren Apel ab4c27cfa6 Input/wav: Add reset() function 2016-05-09 13:02:47 +02:00
Soeren Apel f4b4725bce Input/vcd: Add reset() function 2016-05-09 13:02:47 +02:00
Soeren Apel 87616181f9 Input/trace32_ad: Add reset() function 2016-05-09 13:02:47 +02:00
Soeren Apel 4c55ea47a7 Input/raw_analog: Add reset() function 2016-05-09 13:02:47 +02:00
Soeren Apel ad93bfb0b9 Input/csv: Add reset() function 2016-05-09 13:02:47 +02:00
Soeren Apel ef9d3fefbc Input/chronovu_la8: Add reset() function 2016-05-09 13:02:29 +02:00
Soeren Apel 3781b65d19 Input/binary: Add reset() function 2016-05-09 13:02:29 +02:00
Soeren Apel b6b4f03e40 Input: Add reset() function 2016-05-09 13:02:29 +02:00
Uwe Hermann c8f29d772b baylibre-acme: Drop unused last_sample_fin variable. 2016-05-09 12:44:42 +02:00
Lars-Peter Clausen cf9e86bc74 victor-dmm: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:44:42 +02:00
Lars-Peter Clausen 8a63a4064e uni-t-dmm: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:44:42 +02:00
Lars-Peter Clausen 2630f97ebb tondaj-sl-814: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:44:41 +02:00
Lars-Peter Clausen 91b77e6b1d testo: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:44:41 +02:00
Lars-Peter Clausen ffa5f177f1 teleinfo: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:44:41 +02:00
Lars-Peter Clausen 9f51c463d1 serial-dmm: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:44:41 +02:00
Lars-Peter Clausen 37dbffd15d norma-dmm: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:44:41 +02:00
Lars-Peter Clausen 8aafc5e64d motech-lps-30x: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:12:15 +02:00
Lars-Peter Clausen 301090aa58 mic-985xx: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:12:15 +02:00
Lars-Peter Clausen 45b75c368f maynuo-m97: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:12:15 +02:00
Lars-Peter Clausen a655b3fd08 manson-hcs-3xxx: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:12:15 +02:00
Lars-Peter Clausen 597deef91e korad-kaxxxxp: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:12:15 +02:00
Lars-Peter Clausen 7fc9dc31ac kern-scale: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:12:14 +02:00
Lars-Peter Clausen 9edb98982a colead-slm: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:12:14 +02:00
Lars-Peter Clausen 838f6906a4 center-3xx: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:12:14 +02:00
Lars-Peter Clausen dcba0c41f5 brymen-dmm: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:12:14 +02:00
Lars-Peter Clausen ab939ebba6 brymen-bm86x: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:12:14 +02:00
Lars-Peter Clausen d54a7c42ac baylibre-acme: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:12:14 +02:00
Lars-Peter Clausen e2492a3374 appa-55ii: Use software limit helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:12:14 +02:00
Lars-Peter Clausen aea4e45848 Add helper functions for software limits
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-09 12:12:14 +02:00
Bert Vermeulen ec1a1a8c46 testo: Minor code cleanup. 2016-05-04 01:33:31 +02:00
Lars-Peter Clausen efa9840222 Remove unnecessary driver context checks
Some drivers check in some of their driver callbacks if the driver has been
initialized and return an error if it has not.

For the scan() callback the sigrok core checks if the driver has been
initialized and if not returns an error. So it is not possible that the
scan() callback gets called if the driver is not initialized. Without the
scan() callback succeeding it is not possible to get a reference to a
device which is associated with the driver, so it is not possible that any
of the device specific callbacks is called without the driver first being
initialized either.

In conclusion these checks are not necessary since they never evaluate to
true and can be dropped. If they should ever become necessary they should
be done in the sigrok core so all drivers and all callbacks are equally
handled.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-04 01:33:02 +02:00
Lars-Peter Clausen e91bb0a6c4 Drop SR_CONF_SET flag from SR_CONF_CONTINUOUS options
SR_CONF_CONTINUOUS is a capability option indicating whether a device
supports continuous capture or not. If the option exists the device
supports continuous capture and otherwise it doesn't. There is no value
associated with it and hence setting the SR_CONF_SET flag is nonsensical.

None of the drivers which set SR_CONF_SET for SR_CONF_CONTINUOUS handle it
in their config_set() callback and return an error if an application tried
to perform a config_set() operation for SR_CONF_CONTINUOUS.

Simply remove the SR_CONF_SET flag from all SR_CONF_CONTINUOUS options.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-03 21:49:02 +02:00
Lars-Peter Clausen c01bf34ca2 Introduce standard implementation of the dev_list() callback
Every single hardware driver has the very same implementation of the
dev_list() callback. Put this into a helper function in the standard helper
library and use it throughout the drivers. This reduces boiler-plate code
by quite a bit.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-03 21:25:16 +02:00
Lars-Peter Clausen 88a0265ebc Remove unnecessary dev_clear() callbacks
If a driver does not implement a dev_clear() callback the core will
automatically call std_dev_clear(di, NULL). Remove all driver dev_clear()
implementations that are identical to default. This reduces the amount of
boiler-plate code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-03 21:24:55 +02:00
Lars-Peter Clausen 700d6b64d5 Introduce standard cleanup helper
std_init() allocates a drv_context struct which needs to be freed by the
driver in its cleanup struct. But the vast majority of drivers does never
does this causing memory leaks.

Instead of addressing the issue by manually adding code to free the struct
to each driver introduce a new helper function std_cleanup() that takes
care of this. In addition to freeing the drv_context struct std_cleanup()
also invokes sr_dev_clear() which takes care of freeing all devices
attached to the driver.

Combining both operations in the same helper function allows to use
std_cleanup() as the cleanup callback for all existing drivers, which
reduces the amount of boiler-plate code quite a bit.

All drivers are updated to use the new helper function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-03 21:24:39 +02:00
Lars-Peter Clausen 1e726f568d scpi-pps: Fix dev_clear() implementation
Devices for the scpi-pps driver do have additional data attached to it that
needs to be freed when the device is freed. While the driver gets it right
for the cleanup() callback it does not for the dev_clear() callback. This
will cause memory leaks when sr_dev_clear() is called for this driver.

To fix this let the dev_clear() free the additional data.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-03 21:24:26 +02:00
Lars-Peter Clausen 696b79d2aa deree-de5000: Provide dev_clear()
Devices for the deree-de5000 driver do have additional data attached to it
that needs to be freed when the device is freed. While the driver gets it
right for the cleanup() callback it does not implement a dev_clear()
callback, so the default dev_clear() implementation is used which will not
free the additional data. This will cause memory leaks when sr_dev_clear()
is called for this driver.

To fix this provide a dev_clear() implementation that frees the additional
data.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-03 21:24:12 +02:00
Lars-Peter Clausen 6ab687315b demo: Provide dev_clear()
Devices for the demo driver do have additional data attached to it that
needs to be freed when the device is freed. While the driver gets it right
for the cleanup() callback it does not implement a dev_clear() callback, so
the default dev_clear() implementation is used which will not free the
additional data. This will cause memory leaks when sr_dev_clear() is called
for this driver.

To fix this provide a dev_clear() implementation that frees the additional
data.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-03 21:23:57 +02:00
Lars-Peter Clausen 74c6d807ef beaglelogic: Use std_dev_clear() instead of open-coding it
The beaglelogic has an open-coded version of std_dev_clear(), replace it
with std_dev_clear().

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-03 21:23:41 +02:00
Lars-Peter Clausen a64fec2b8e baylibre-acme: Properly free GErrors returned by g_file_get_contents()
When g_file_get_contents() encounters an error a new GError will be
allocated and passed back to the application. The application is
responsible for freeing this GError.

The baylibre-acme driver currently does not do this and as a result leaks
memory during the scan process when no device is found.

Add the missing g_error_free() invocations to fix the issue.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-03 21:23:22 +02:00
Lars-Peter Clausen 7b6072d354 ftdi-la: Properly cleanup in scan_all()
Make sure to free the FTDI device list and the FTDI context in scan_all()
otherwise memory leaks can be observed. Also make sure to free the FTDI
context in scan_device() on the error path.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-05-03 21:22:38 +02:00
Uwe Hermann 61c9085898 dev_open(): Don't check for sdi != NULL.
The wrapper guarantees that sdi is not NULL.
2016-04-29 19:26:17 +02:00
Uwe Hermann c50805d59c Drop some unused or duplicated code. 2016-04-29 19:26:17 +02:00
Uwe Hermann 8f878dc6aa cem-dt-885x/colead-slm: Use std_serial_dev_open(). 2016-04-29 19:26:17 +02:00
Uwe Hermann a52e2a0b37 Random cosmetics and whitespace fixes. 2016-04-29 19:26:17 +02:00
Uwe Hermann 67ea60e03d uni-t-ut32x: Fix copy-paste error. 2016-04-29 19:26:17 +02:00
Uwe Hermann df3ea149cc dev_acquisition_start(): Ensure that sdi is always != NULL. 2016-04-29 19:26:17 +02:00
Uwe Hermann 8cb222e143 Drop some obsolete and unneeded comments. 2016-04-29 19:20:53 +02:00
Uwe Hermann 6525d819ee std_serial_dev_acquisition_stop(): Drop unneeded parameter. 2016-04-29 19:20:53 +02:00
Uwe Hermann 695dc859c1 dev_acquisition_{start,stop}(): Drop duplicate 'cb_data' parameter.
These are always 'sdi', which is passed in already.
2016-04-29 19:20:53 +02:00
Uwe Hermann 208c1d3543 Consistently don't check sdi->priv in dev_acquisition_start().
Most drivers already assume this to be != NULL anyway, and the check
should probably be in the API wrappers anyway.
2016-04-29 18:08:15 +02:00
Uwe Hermann 1c47e0da8f Drop unneeded std_session_send_df_header() comments. 2016-04-29 18:08:15 +02:00
Uwe Hermann 3be42bc22f Factor out std_session_send_df_end() helper.
This makes the code shorter, simpler and more consistent, and also
ensures that the (same) debug messages are always emitted and the
packet.payload field is consistently set to NULL always, etc.
2016-04-29 18:08:15 +02:00
Benjamin Larsson 7fb90f94d6 fx2lafw: Add working glue layer for frontends 2016-04-29 15:19:08 +02:00
Joel Holdsworth 7e5ccff2ec fx2lafw: Add analog sampling handler
This will be needed for the MSO support of the CWAV USBee AX and clones.
2016-04-27 22:49:51 +02:00
Joel Holdsworth 7b5d1c64fc fx2lafw: Factor out packet sending
This will make it possible to use different senders based on
driver mode. This is needed for USBee AX support.
2016-04-27 22:29:56 +02:00
Joel Holdsworth ce35b282de fx2lafw: Add CTL2 clocking command flag to header
The USBee AX hardware needs a sampling clock that is lower than
the 30MHz or 48MHz that the FX2 has to offer. This flag will enable
clocking via the CTL2 pin that is an even divisor of the main clock.
2016-04-27 22:29:16 +02:00
Joel Holdsworth 232a975fe2 fx2lafw: Add support for AX analog channel probing 2016-04-27 22:29:16 +02:00
Uwe Hermann 152e7f4d7c hwdriver.c: Add missing SR_MQFLAG_FOUR_WIRE entry. 2016-04-23 17:45:49 +02:00
Alexandru Gagniuc 9a093be9f5 hp-3457a: Implement support for rear terminals and plug-in cards 2016-04-23 17:44:26 +02:00
Alexandru Gagniuc 2c04f943ef hp-3457a: Implement AC, ACDC, and four-wire resistance modes
The driver did not look at the mq_flags provided with the
SR_CONF_MEASURED_QUANTITY key, and it defaulted to DC measurements.
Use the second member of the tuple provided by the config key, which
represents the flags for the measurement, and set the instrument's
measurement mode accordingly.
2016-04-23 17:44:26 +02:00
Alexandru Gagniuc 6d5cd3bd38 analog: Add MQ Flag for four-wire measurements
On the high-end bench multimeters, resistance can be measured with a
kelvin connection as well as the more common two wire method. Provide
a flag which can indicate if four-wire mode is used.
2016-04-23 17:44:26 +02:00
Alexandru Gagniuc e2626373b7 hp-3457a: Do not retrigger new measurement after the last sample
Due to a PEBKAC error, after the last sample was sent, a new
measurement was triggered, but its value was never sent down the
session bus. This is easily fixed by incrementing devc->num_samples
right after a measurement is sent instead of when a measurement is
retriggered.
2016-04-23 17:44:26 +02:00
Sergey Alirzaev cee6d3fa0c ftdi-la: added support for the device selection
Tested on FT232RL and FT2232H both attached to the same PC.
2016-04-23 17:37:46 +02:00
Benjamin Larsson 5954e71653 hantek-6xxx: fix memory leaks
Free the first flush packet and the driver context when closing.
2016-04-23 17:37:45 +02:00
Benjamin Larsson 2c4600191b memory leak fix: g_variant_print() usage fix
g_variant_print() allocates memory during call. Save the pointer
so that it can be free'd afterwards.

==10048== 16 bytes in 1 blocks are definitely lost in loss record 17 of 37
==10048==    at 0x4C2DEAE: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10048==    by 0x536C85D: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x53877C6: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x5388B60: g_string_append_vprintf (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x5388D83: g_string_append_printf (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x539D034: g_variant_print_string (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x539C92C: g_variant_print (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x4E5F713: log_key (hwdriver.c:597)
==10048==    by 0x4E5FCD5: sr_config_set (hwdriver.c:752)
==10048==    by 0x408C1A: run_session (session.c:661)
==10048==    by 0x404FC5: main (main.c:267)
==10048==
==10048== 16 bytes in 1 blocks are definitely lost in loss record 18 of 37
==10048==    at 0x4C2DEAE: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10048==    by 0x536C85D: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x53877C6: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x5388B60: g_string_append_vprintf (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x5388D83: g_string_append_printf (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x539D034: g_variant_print_string (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x539C92C: g_variant_print (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x4E5F713: log_key (hwdriver.c:597)
==10048==    by 0x4E5FBDD: sr_config_get (hwdriver.c:709)
==10048==    by 0x4080D7: datafeed_in (session.c:196)
==10048==    by 0x4E5D47E: sr_session_send (session.c:1192)
==10048==    by 0x4E62682: std_session_send_df_header (std.c:101)
2016-04-23 17:37:45 +02:00
Markus Siegert 050eb3b32d hantek-6xxx: Use power of 2 usb packet sizes
Using non power of 2 sizes causes the driver to not work on OS X.
Depending on the usb transfer mode the buffer sizes will map
perfectly to the underlying transport protocol.
2016-04-23 17:37:45 +02:00
Markus Siegert 1079324f9e hantek-6xxx: use 1D50:608E for Sainsmart DDS-120 2016-04-23 17:37:45 +02:00
Benjamin Larsson cc5ebc8a3d hantek-6xxx: add coupling support
Sainsmart DDS-120 supports AC or DC coupling. Add driver support
to control that feature.
2016-04-23 17:37:45 +02:00
Benjamin Larsson 10e0d374cb hantek-6xxx: store the amount samples received 2016-04-23 17:37:45 +02:00
Benjamin Larsson 8d6d7d5d0d hantek-6xxx: positive return code is not an error 2016-04-23 17:37:45 +02:00
Benjamin Larsson 692c3b229d hantek-6xxx: Add support for Sainsmart DDS120 2016-04-23 17:37:45 +02:00
Uwe Hermann f07298663f Fix two compiler warnings. 2016-04-23 17:37:45 +02:00
Stefan Brüns f4f273ce1e hameg-hmo: Also start reading on timeout (workaround for USBTMC)
scpi_serial generate an POLLIN event after the requested data is returned
by the instrument. For USBTMC it is necessary to
1. send an REQUEST_DEV_DEP_MSG_IN request
2. submit an USB bulk read transfer asynchronously.

Using the synchronous libusb_bulk_read() does not generate an POLLIN event.

Solving this properly needs major surgery in spci_usbtmc_libusb.
2016-04-23 17:09:52 +02:00
Stefan Brüns 055804e89e spci: Terminate all commands with a linefeed for all transports
While some transports add a terminating (carriagereturn+)linefeed
unconditionally, the USBTMC transport does not. At least the R&S HMO1002
requires the linefeed and locks up otherwise. Fixes bug #784.

This changes the TCP and VXI transport from CR+LF to LF only.

Also fixes a possible memory leak for VXI, where the temporary command
buffer was not freed in case of a write error.
2016-04-23 17:08:50 +02:00
Stefan Brüns 66836720f7 scpi/usbtmc: fix remote locking according to USBTMC spec
According to USBTMC usb488 subclass spec, wValue hast to be 0 for both
LOCAL_LOCKOUT and GO_TO_LOCAL. At least required for R&S HMO1002, the
bad request results in a STALL. Fixes bug #783.
2016-04-23 17:08:44 +02:00
Diego F. Asanza 3db03efa4a Working trigger on rising and falling edges. 2016-04-23 17:04:18 +02:00
Uwe Hermann 1a7ff3d087 fx2lafw: Only run dslogic_stop_acquisition() on DSLogic. 2016-04-17 15:49:47 +02:00
Diego F. Asanza 40ebad3524 Ensure DSLogic can be stopped.
After acquisition start, DSLogic stores samples in memory, and when done it
sends a USB packet with the trigger position.

This initial fillup can take some time. If the user requests a session stop
in between, the USB transfer is cancelled and the session hangs because it
is not closed properly.

This commit manages this case and closes the session properly when
acquisition is stopped by the user.

Signed-off-by: Diego F. Asanza <f.asanza@gmail.com>
2016-04-17 15:31:58 +02:00
Sergey Alirzaev c04ca4da17 ftdi-la: order the channels properly 2016-04-17 14:54:08 +02:00
Stefan Brüns d38f4e7a0f scpi/serial: Add USB IDs for R&S HMO 1002 Series 2016-04-17 14:50:42 +02:00
Stefan Brüns 356f64f8c7 hameg-hmo: support triggering on either falling or rising edge
At least the HMO 1002 allows triggering on rising or falling edge, the
corresponding SCPI value is "EITH"

See also bug #740
2016-04-17 14:50:42 +02:00
Stefan Brüns e3abd15d08 hameg-hmo: fix "invalid argument" exception when setting trigger edges
The hameg-hmo driver uses the values from the trigger_slopes array.
2016-04-17 14:50:42 +02:00
Stefan Brüns da1726cc4c hameg-hmo: Add Rohde&Schwarz HMO 1002
Hameg is a R&S measurement instruments subsidiary. The HMO 1002 is an
entry level scope, compatible with the SCPI commands of the larger models.
2016-04-17 14:50:42 +02:00
Uwe Hermann 797f1a0cf3 sanity_check_all_drivers(): Add some code comments. 2016-04-17 14:50:18 +02:00
Uwe Hermann bc48ec3755 gmc-mh-1x-2x: Make two functions static. 2016-04-17 14:24:05 +02:00
Uwe Hermann 3c996d8e23 scpi-pps: Drop unused function prototype. 2016-04-17 14:22:37 +02:00
Wolfram Sang 1f706c21a2 input: vcd: skip BOM at beginning of file
According to the infos I have, VCD files should be plain ASCII, but we
got report of a version adding a UTF8 BOM at the beginning of the file,
so we need to skip it.

This fixes bug #755.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-13 09:35:03 +02:00
Diego F. Asanza 62974b235a Set DSLogic in logic analyzer mode.
It was being initialized in DSO mode.

Signed-off-by: Diego F. Asanza <f.asanza@gmail.com>
2016-04-13 09:35:03 +02:00
Diego Asanza 3f0ff41284 Fix DSLogic FPGA binary image upload and signal acquisition.
For some reason, uploading the FPGA binary into DSLogic in small chunks
does not work. In this commit, the whole binary image is loaded into memory
and transfer is done in one chunk.

Furthermore, the FPGA configuration structure was not initialized
properly. This was changed with the initialization values taken from the
original DSLogic software.

Signed-off-by: Diego Asanza <f.asanza@gmail.com>
2016-04-13 09:35:02 +02:00
Soeren Apel 600cc1a8a5 Demo: Use 20Vpp as amplitude instead of 50Vpp 2016-04-06 21:11:37 +02:00
Uwe Hermann f9197887e4 ftdi-la: Move ftdi_la_set_samplerate() to protocol.c. 2016-04-03 17:22:05 +02:00
Uwe Hermann f227338297 Rename 'ft2232h' driver to 'ftdi-la'.
The driver already supports more than just the FT2232H chip.
2016-04-02 18:36:52 +02:00
Sergey Alirzaev 4f7fdcdd74 ft2232h: Add support for FTDI FT2232H/FT232R chip as LA.
This closes bug #780.
2016-03-30 13:36:02 +02:00
Alexandru Gagniuc 625430bf88 hp-3457a: Implement workaround for double-precision data
Certain output modules do not understand double-precision data.
Although we need double precision to represent the full resolution
of 7.5 digit readings, temporarily convert data to single precision
so that the output modules understand it. While the reasing might be
off by a few counts, we ensure the output modules do not display
completely bogus data.

For details, see bug #779.
2016-03-30 12:50:59 +02:00
Alexandru Gagniuc db23af7fc2 hp-3457a: Implement basic configuration and sampling
KNOWN ISSUES:
- When sampling with 100 NPLC, the poll function will timeout a few
times before the first sample is acquired. Increasing the timeout
passed to sr_scpi_source_add() will cause all the other commands to
be processed slowly, producing a sampling rate of about one sample
every ten seconds.
- Support for plug-in cards (44491A and 44492A) is not implemented.
- Support for AC, AC+DC and four-wire resistance measurements is not
implemented.
- Support for configuring the frequency measurement source is not
implemented.
2016-03-30 12:50:27 +02:00
Alexandru Gagniuc fadb19ac96 hwdriver: Add configuration key for number of powerline cycles
High precision multimeters have a special setting, called "number of
powerline cycles" (NPLC) which determines the integration time of the
ADC in terms of the power line period. Some devices need their NPLC
adjusted from the default value before they can measure at their full
rated precision.
2016-03-30 12:39:25 +02:00
Alexandru Gagniuc 8b0ad3a559 scpi/libgpib: Place device in local mode before closing handle
Devices connected on a real GPIB bus are placed in remote mode when
opening them. libgpib does not automatically place devices back in
local mode when closing the handle. It is thus possible to lock out a
GPIB device by probing it with libsigrok.

This happens on the HP 3457A meter, which does not have a "LOCAL"
command, and must be put back in local mode via GPIB handshake.
ibloc() takes care of this, and it does it on a per-device basis,
such that other devices on the GPIB bus are not affected.
2016-03-30 12:39:20 +02:00
Alexandru Gagniuc daf13c570f scpi/libgpib: Print error string instead of number on errors
libgpib has an error_string which formats a numeric error code into a
human-readable description. Use that instead of printing the numeric
code, as it makes debugging easier.
2016-03-30 12:32:55 +02:00
Alexandru Gagniuc 00b2a092c3 hp-3457a: Initial driver skeleton. 2016-03-30 12:32:55 +02:00
Soeren Apel 0586a0ef59 srzip: Optimize analog output saving
- Don't set capturefile if no logic channels are saved
 - Don't set total probes if no logic channels are saved
 - Save analog channels without index gaps (e.g. probe1/probe4)
2016-03-28 01:06:29 +02:00
Soeren Apel f476dd2d2b Enable loading of session files without total probes defined 2016-03-28 01:06:29 +02:00
Soeren Apel 9cfc695ffe Enable loading of session files without the unit size defined 2016-03-28 01:06:29 +02:00
Soeren Apel 7c69b528e4 Enable loading of session files without the capture file defined 2016-03-28 01:06:28 +02:00
Soeren Apel e5b280e4c7 analog save: Avoid index duplication between analog & logic channels. 2016-03-24 08:55:42 +01:00
Soeren Apel 1393bccfcb input/raw_analog: Prevent "duplicate const decl specifier" warning
Warnings emitted by gcc before this patch:
src/input/raw_analog.c:51:13: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
        const char const *fmt_name;
                   ^
src/input/raw_analog.c:55:35: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
static const struct sample_format const sample_formats[] =
                                  ^
2016-03-22 08:29:25 +01:00
Uwe Hermann 74a9c0adc0 output/srzip: Minor whitespace fixes. 2016-03-15 18:40:50 +01:00
Martin Ling 2dc4081540 session_driver: Process analog chunks into analog packets. 2016-03-14 00:34:09 +01:00
Martin Ling 906921bad2 session_driver: Read analog chunks from file. 2016-03-14 00:34:09 +01:00
Martin Ling b317d1bbfb sr_session_load(): Create analog channels from loaded file. 2016-03-14 00:34:09 +01:00
Martin Ling 26918dced0 srzip: Renumber analog channels from zero in output file. 2016-03-14 00:34:09 +01:00
Martin Ling 7163dcbe18 srzip: Save analog data. 2016-03-14 00:34:09 +01:00
Martin Ling eab052996c srzip: Store total number of analog channels. 2016-03-14 00:34:09 +01:00
Martin Ling 828832194f srzip: Count only logic channels in "total probes". 2016-03-14 00:34:09 +01:00
Uwe Hermann c940b7a32f hantek-6xxx: libusb_get_device_descriptor() cannot fail. 2016-03-13 23:33:56 +01:00
Chriter f2a66a8ee6 hantek-6xxx: Initial driver implementation.
Note: This commit is based on the initial implementation by
Christer Ekholm (but stashed into one commit), with some adaptations
(forward porting, coding style and consistency fixes) by Uwe Hermann.
2016-03-13 23:33:56 +01:00
Chriter 6c6bc80a99 hantek-6xxx: Initial driver skeleton. 2016-03-09 19:20:13 +01:00
Uwe Hermann 5af975b587 maynuo-m97: Fix a typo in an error message. 2016-03-05 18:51:39 +01:00
Alexandru Gagniuc 6cc931283d scpi-pps: Add profile for Agilent N5763A 12.5V 120A supply 2016-03-05 18:49:30 +01:00
Uwe Hermann ba4dfbde11 fluke-dmm: Add support for the Fluke 289.
Thanks to Julien Bresciani <julien.bresciani@free.fr> for providing
the information about the required changes!
2016-03-04 17:38:35 +01:00
Wolfram Sang b84f91ff2e session: allocate correct amount of memory in sr_packet_copy
We want the size of the struct, not of a pointer to the struct. And to
be absolutely future proof, dereference the pointer we are assigning the
memory to (not the one we are copying the data from). Found by Coverity,
CID 50858.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-02-28 18:21:18 +01:00
Uwe Hermann 2217be1dd4 arachnid-labs-re-load-pro: Handle undervoltage condition.
Support the SR_CONF_UNDER_VOLTAGE_CONDITION* keys.

Undervoltage (and overtemperature) conditions now emit a
warning-level message as well.
2016-02-11 14:42:50 +01:00
Uwe Hermann 2fe1011f1d Add SR_CONF_UNDER_VOLTAGE_CONDITION* config keys.
Add two new config keys:

 - SR_CONF_UNDER_VOLTAGE_CONDITION

 - SR_CONF_UNDER_VOLTAGE_CONDITION_ACTIVE
2016-02-11 14:42:50 +01:00
Uwe Hermann 8084e0fa81 arachnid-labs-re-load-pro: Only support firmware >= 1.10.
The "on\n" and "off\n" commands require this.
2016-02-11 14:42:50 +01:00
Uwe Hermann 8501448cfe arachnid-labs-re-load-pro: Add support for setting SR_CONF_ENABLED.
The firmware has "on\n" and "off\n" commands since 1.10, so use them.

Apparently you can only set the state (on/off) of the load, but it's
not possible to query the current state.
2016-02-11 14:42:50 +01:00
Uwe Hermann 6e68da5140 arachnid-labs-re-load-pro: Convert to SR_DF_ANALOG. 2016-02-11 14:42:50 +01:00
Uwe Hermann 803db07a1a arachnid-labs-re-load-pro: Add initial driver. 2016-02-08 15:02:29 +01:00
Uwe Hermann 6e8d31d468 arachnid-labs-re-load-pro: Initial driver skeleton. 2016-02-08 15:02:29 +01:00
Aurelien Jacobs 83bf4762e4 beaglelogic: use standard # operator instead of ugly __STRING macro
Also note that the __ namespace is reserved by POSIX for its private
usage, so user land software should never rely on any kind of API
with a __ prefix.
2016-02-06 17:24:34 +01:00
Soeren Apel 10c4ca9c5b hameg-hmo/yokogawa-dlm: Fix warning about pointer typecast 2016-01-29 23:13:32 +01:00
Soeren Apel a084a8f2a4 SCPI: Do not use RL1 lockout for Yokogawa devices 2016-01-29 21:59:06 +01:00
Soeren Apel b18b8a9202 yokogawa-dlm: Fix array_float_get() 2016-01-29 21:39:20 +01:00
Soeren Apel 8cccbac8da hameg-hmo: Fix array_float_get() and also use it for the time base 2016-01-29 21:35:16 +01:00
Soeren Apel fe227d17ae hameg-hmo: Add missing 20/50V vdiv entries 2016-01-29 21:13:07 +01:00
Soeren Apel e786b19467 hameg-hmo: Add more supported scope models 2016-01-29 21:08:49 +01:00
Lars-Peter Clausen b165a24234 hung-chang-dso-2100: Fix session source fd
For session sources without a file descriptor to poll a negative number
should be passed for the fd parameter. The hung-chang-dso-2100 driver
currently passes 0 instead, which is the stdin stream. Fix the issue by
passing -1 for the fd parameter.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2016-01-29 18:24:42 +01:00
Uwe Hermann eb8e6cd2cb Use libusb_error_name() more often for better diagnostics. 2016-01-29 18:00:11 +01:00
Aurelien Jacobs 9dfacd8706 demo: fix infinite loop with 0 channels of one type
The following command line exhibits the inifinit loop:
  sigrok-cli -d demo:analog_channels=0 --samples=8
2016-01-28 23:41:19 +01:00
Wolfram Sang 3f48fc82b5 input: vcd: by default do not limit number of channels
Accept (and set to default) 0 for numchannels which means 'unlimited'.
I think it is convenient to read all channels of a vcd file by default.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-28 19:03:53 +01:00
Wolfram Sang ab464eb3dc input: vcd: register channels when parsing header not when initializing
Benefits:

* only channels really used in vcd will be added
* we can give them the proper name found in the vcd file
* less code :)

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-28 19:03:53 +01:00
Wolfram Sang 34724ffa34 input: vcd: support 1 bit vectors
Use the new process_bit() function to parse 1 bit vectors, too.

This is the first step to fix bug #723. Minimal testcase vcd:

$timescale 1 ns $end
$var wire 1 n0 addr_0 $end
$var wire 1 n1 addr_1 $end
$enddefinitions $end
#0
0n0
b1 n1
#1
1n0
b0 n1
#2
0n0
b1 n1
#3
1n0
b0 n1

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-28 19:03:53 +01:00
Wolfram Sang 36dacf17bc input: vcd: refactor parsing a bit
Move to a separate function which we want to reuse later.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-28 19:03:53 +01:00
Wolfram Sang a66175c2b1 input: vcd: avoid needless copying
Current code moves the identifier string one byte to the front to
overwrite the bit value, so 'tokens[i]' is a string to compare against
the desired value. This copying is unnecessary, just pass a properly
setup pointer.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-28 19:03:53 +01:00
Wolfram Sang 76bc28c3f1 input: vcd: try to continue when a vector was found
No need to bail out on vectors. As long as there are tokens left, we can
try to parse the rest. Also, print a message so the user knows what's
going on. Here is a testcase vcd:

$timescale 1 ns $end
$var wire 1 n0 addr_0 $end
$var wire 1 n1 addr_1 $end
$enddefinitions $end
#0
0n0
b1 n1
#1
1n0
b0 n1
#2
0n0
b1 n1

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-28 19:03:53 +01:00
Wolfram Sang 73f052d329 input: vcd: properly bail out on missing identifiers
If we hit the missing identifier case, then we reached the end of the
token list. So, we should break out of the loop, and not continue.
Otherwise we will go past the end of the array as this minimal testcase
shows:

$timescale 1 ns $end
$var wire 1 n0 addr_0 $end
$enddefinitions $end
1

gives:

$ ./sigrok-cli -I vcd -i no_mod.vcd -O vcd -o /tmp/o.vcd
Segmentation fault

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-28 19:03:53 +01:00
Wolfram Sang e85e550d92 input: vcd: allow optional index item
A $var block can have an optional index item which looks like '[<sth>]'.
Parse it, too, and append it to the channel name.

This fixes bug #322. A first version was posted by Simon Richter. This
version is rebased and simplified.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-28 19:03:53 +01:00
Uwe Hermann 650847e7d3 hameg-hmo: Fix some compiler warnings. 2016-01-28 19:03:53 +01:00
Soeren Apel 8fff75196f hameg-hmo: Replace floating point comparison for vdiv
This should fix bug #731.
2016-01-28 19:03:53 +01:00
Soeren Apel a5be5d5bc0 Trace32 import module: Send trigger only once
As we're downsampling, several record time stamps can match the specified
trigger time. For this reason, it's possible that several trigger packets
are sent when a file is loaded. This prevents the issue and sends a
trigger packet only on the first matching record.
2016-01-28 19:03:52 +01:00
Uwe Hermann 1b4aedc06f Use ALL_ZERO in a few more places. 2016-01-07 23:50:17 +01:00
Uwe Hermann ff7c7cda93 lecroy-logicstudio: Fix some compiler warnings on MinGW.
src/hardware/lecroy-logicstudio/protocol.c: In function 'handle_fetch_samples_done':
src/hardware/lecroy-logicstudio/protocol.c:261:3: warning: passing argument 6 of 'libusb_fill_bulk_transfer' from incompatible pointer type
   recv_bulk_transfer, (void *)sdi, USB_TIMEOUT_MS);
   ^
In file included from ./src/libsigrok-internal.h:31:0,
                 from src/hardware/lecroy-logicstudio/protocol.h:26,
                 from src/hardware/lecroy-logicstudio/protocol.c:23:
/home/uwe/sr_mingw/include/libusb-1.0/libusb.h:1546:20: note: expected 'libusb_transfer_cb_fn' but argument is of type 'void (*)(struct libusb_transfer *)'
 static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer,
                    ^
src/hardware/lecroy-logicstudio/protocol.c: In function 'fetch_samples_async':
src/hardware/lecroy-logicstudio/protocol.c:314:4: warning: passing argument 6 of 'write_registers_async' from incompatible pointer type
    handle_fetch_samples_done);
    ^
src/hardware/lecroy-logicstudio/protocol.c:200:12: note: expected 'libusb_transfer_cb_fn' but argument is of type 'void (*)(struct libusb_transfer *)'
 static int write_registers_async(const struct sr_dev_inst *sdi,
            ^
src/hardware/lecroy-logicstudio/protocol.c: In function 'lls_start_acquisition':
src/hardware/lecroy-logicstudio/protocol.c:1122:3: warning: passing argument 6 of 'libusb_fill_interrupt_transfer' from incompatible pointer type
   recv_intr_transfer, (void *) sdi, USB_TIMEOUT_MS);
   ^
In file included from ./src/libsigrok-internal.h:31:0,
                 from src/hardware/lecroy-logicstudio/protocol.h:26,
                 from src/hardware/lecroy-logicstudio/protocol.c:23:
/home/uwe/sr_mingw/include/libusb-1.0/libusb.h:1602:20: note: expected 'libusb_transfer_cb_fn' but argument is of type 'void (*)(struct libusb_transfer *)'
 static inline void libusb_fill_interrupt_transfer(
                    ^
2016-01-07 23:50:17 +01:00
Uwe Hermann d64b5f43cc sysclk-lwla: Minor whitespace and consistency fixes. 2016-01-07 23:50:17 +01:00
Uwe Hermann 0cadb8a350 Minor whitespace and cosmetic fixes. 2016-01-07 23:50:17 +01:00
Wolfram Sang 3591481e87 dmm: vc870: drop unused variable
There is no status bit for RMS. We know about RMS if certain modes are
active. So, drop this superfluous variable.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-05 22:25:29 +01:00
Wolfram Sang ee2e9be21b dmm: vc870: support effective voltage & current
And rename the status variable because in sigrok the term RMS is used
instead of "effective value".

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-05 22:25:29 +01:00
Wolfram Sang 2e1c4817c7 dmm: vc870: render POWER_FACTOR as such and not as frequency
The primary display is the power factor, the secondary is the frequency.
This got mixed up, so change the order. We also need to fix the
conversion factor.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-05 22:25:29 +01:00
Wolfram Sang 4867dd177f dmm: vc870: keep the order when processing modes
is_power_apparent_power is index 0 of function 0x39, so it is better to
process it first and the later indices after that (we need to add
another one with a different patch later).

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-05 22:25:29 +01:00
Wolfram Sang b4a0770ef8 dmm: vc870: fix AC conversion factors
Testing showed that AC current needs to be handled different from DC.
Note that ACA is still untested because of limited testing equipment.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-05 22:25:29 +01:00
Wolfram Sang b89462e457 dmm: vc870: show display value properly in debug output
It was confusing to see the display value (5 digits) printed in debug
output as a float. Print it the same way as shown on the real device,
without comma, of course.
This also allows to simplify the code a little.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-01-05 22:25:29 +01:00
Daniel Elstner 32ba0d8005 resource: Replace ssize_t with gssize to avoid unistd.h 2016-01-04 20:53:30 +01:00
Uwe Hermann e43887683c baylibre-acme: Replace g_close() with close() for now.
This g_close(), the only one in the whole code-base, would unnecessarily
raise the minimum glib version to 2.36.

Thanks to Daniel Glöckner for the report.

This fixes bug #724.
2016-01-03 02:59:00 +01:00