Commit Graph

4073 Commits

Author SHA1 Message Date
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
Benjamin Larsson afb001a359 udev rules file: Add entry for Sainsmart DDS120. 2016-05-05 14:06:51 +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