6 years agodemo: Use a switch() instead of '} else if {' in hw_dev_config_set()
Alexandru Gagniuc [Wed, 12 Dec 2012 01:57:24 +0000 (19:57 -0600)]
demo: Use a switch() instead of '} else if {' in hw_dev_config_set()

Signed-off-by: Alexandru Gagniuc <>
6 years agodemo: Move static variables into dev_context
Alexandru Gagniuc [Tue, 11 Dec 2012 23:26:09 +0000 (17:26 -0600)]
demo: Move static variables into dev_context

Information such as samplerate, time limit or sample limit is context specific.
Information about samplerate, time limit, sample limit, and pattern is currently
kept in static global variables, while a count of the number of samples sent is
kept in the device context.

These variables belong in a device context, since they are device-specific.

Store these variables in dev_context, following the model that most other
drivers use: keep devc in sdi->priv.

Signed-off-by: Alexandru Gagniuc <>
6 years agodemo: Implement basic 100Hz analog sine-wave generator
Alexandru Gagniuc [Mon, 3 Dec 2012 19:20:59 +0000 (13:20 -0600)]
demo: Implement basic 100Hz analog sine-wave generator

Implement a 2V peak-to-peak, 100Hz sine wave.
At the moment, this only works correctly with one probe.

To test, use:
sigrok-cli --driver=demo -d pattern=sine100 --samples 2001 -p 1 -O analog -l 5

The last sample should be exactly 0.000000 V.
If we had used sinf() instead of sin(), the last sample would be 0.349691 uV.

Signed-off-by: Alexandru Gagniuc <>
6 years agodemo: Add unimplemented option for 100 Hz sine wave
Alexandru Gagniuc [Mon, 3 Dec 2012 17:43:23 +0000 (11:43 -0600)]
demo: Add unimplemented option for 100 Hz sine wave

Add the infrastructure to support selecting a 100 Hz sine wave.

Signed-off-by: Alexandru Gagniuc <>
6 years agobrymen-dmm: Add support for Brymen BM857
Alexandru Gagniuc [Mon, 26 Nov 2012 23:09:05 +0000 (17:09 -0600)]
brymen-dmm: Add support for Brymen BM857

This patch my also work for a number of other Brymen models
-- 859(a), 867, 869---
including their respective rebadges from Greenlee, Extech, and Amprobe.

Signed-off-by: Alexandru Gagniuc <>
6 years agobrymen-dmm: Initial driver skeleton.
Alexandru Gagniuc [Thu, 22 Nov 2012 03:20:39 +0000 (21:20 -0600)]
brymen-dmm: Initial driver skeleton.

6 years agooutput/text: Fix memory leak when receiving SR_DF_END
Alexandru Gagniuc [Thu, 3 Jan 2013 08:25:23 +0000 (02:25 -0600)]
output/text: Fix memory leak when receiving SR_DF_END

The modules in output/text like to cleanup when receiving a SR_DF_END packet.
o->internal was cleaned up, but the malloc'd members of the module context were

To make it easier to match the malloc and free calls, factor put the cleanup
in a NULL-tolerant context_free() function, and use context_free() in error
paths, instead of manual  g_free() calls.

Test with:
$ G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --leak-check=full \
 sigrok-cli --driver=demo --samples 8 -O [text_module] -l 5

where [text_module] can be bits, hex, or ascii

Signed-off-by: Alexandru Gagniuc <>
6 years agosession: Remove datafeed callbacks when destroying session
Alexandru Gagniuc [Thu, 3 Jan 2013 05:53:41 +0000 (23:53 -0600)]
session: Remove datafeed callbacks when destroying session

The datafeed callback list was not freed when a session was destroyed. This
caused a "definitely lost" memory leak.

Remove all datafeed callbacks when destroying the session. This causes the
session->datafeed_callbacks list to be freed, and prevents the memory leak.

Tested with Radioshack 22-812 connected to /dev/ttyUSB10:
$ G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --leak-check=full \
sigrok-cli --driver=radioshack-22-812:conn=/dev/ttyUSB10 --continuous -O analog

Signed-off-by: Alexandru Gagniuc <>
6 years agoserial-dmm: Add separate error exit path for serial_dmm_scan()
Alexandru Gagniuc [Thu, 3 Jan 2013 03:51:33 +0000 (21:51 -0600)]
serial-dmm: Add separate error exit path for serial_dmm_scan()

The problem with having a single exit path for serial_dmm_scan was that we would
not know if we encountered an error or not. When we encounter error, we need to
clear any allocated resources. This was not done, causing memory leaks when
hw_scan() was invoked, but no device was connected.

Having a separate exit path for errors allows us to properly clean up any
allocated resources. We can simply free all our resources in the error path,
since our cleanup helpers are NULL-tolerant.

For example, when the device was not detected, struct sr_serial_dev_inst *serial
was never freed, causing a "definitely lost" memory leak.

Other possible failure points were simulated by replacing the if(!malloc())
clauses with if(!0).

Tested with no device attached
$ G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --leak-check=full \
sigrok-cli --driver=radioshack-22-812:conn=/dev/ttyUSB10 --continuous -O analog

Signed-off-by: Alexandru Gagniuc <>
6 years agoserial-dmm: Simplify clear_instances()
Alexandru Gagniuc [Thu, 3 Jan 2013 03:48:33 +0000 (21:48 -0600)]
serial-dmm: Simplify clear_instances()

Use g_slist_free_full() instead of traversing the list and freeing each element

Signed-off-by: Alexandru Gagniuc <>
6 years agoserial-dmm: Rename scan() to serial_dmm_scan()
Alexandru Gagniuc [Thu, 3 Jan 2013 03:39:00 +0000 (21:39 -0600)]
serial-dmm: Rename scan() to serial_dmm_scan()

There is no technical reason to do this. serial_dmm_scan() is static, so there
will be no name conflicts. The real value in this change comes when running
valgrind. If all scan functions are named scan(), then it becomes difficult to
tell from valgrind output which scan() caused the memory leak.

Signed-off-by: Alexandru Gagniuc <>
6 years agodevice.c: Make sr_*_inst_free() tolerant to NULL parameters
Alexandru Gagniuc [Thu, 3 Jan 2013 03:20:11 +0000 (21:20 -0600)]
device.c: Make sr_*_inst_free() tolerant to NULL parameters

g_free() is already tolerant to NULL pointers. If any sigrok internal free
function is passed a partially initialized structure (i.e. some fields are
null), it will safely free it. However, if the struct pointer itself is NULL, it
will dereference it, creating a segmentation fault.

Check for NULL pointers in all *_free() functions in device.c. This makes them
tolerant to NULL pointers, and more closely mimics the behavior of g_free().

Unavoidably, this patch also contains a memory leak fix for sr_dev_inst_free().
The sr_probe structures in sdi->probes were freed, but the GSList structure
itself was not freed ("definitely lost" memory leak).

Tested with Radioshack 22-812 connected to /dev/ttyUSB10:
$ G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --leak-check=full \
sigrok-cli --driver=radioshack-22-812:conn=/dev/ttyUSB10 --continuous -O analog

Signed-off-by: Alexandru Gagniuc <>
6 years agofx2lafw: Say if chip is old FX2 or FX2LP master
Alexandru Gagniuc [Sun, 6 Jan 2013 15:31:30 +0000 (09:31 -0600)]
fx2lafw: Say if chip is old FX2 or FX2LP

Look at the extracted REVID, and print out if it is an FX2 (non-LP), or FX2LP.

Signed-off-by: Alexandru Gagniuc <>
6 years agolink-mso19: Use more portable g_htons().
Uwe Hermann [Tue, 8 Jan 2013 02:12:01 +0000 (03:12 +0100)]
link-mso19: Use more portable g_htons().

Not all systems provide <arpa/inet.h> and/or htons(). Use portable and
always available g_htons() from glib instead.

6 years agolink-mso19: Fix a bunch of compiler warnings.
Uwe Hermann [Tue, 8 Jan 2013 02:02:53 +0000 (03:02 +0100)]
link-mso19: Fix a bunch of compiler warnings.

6 years agolink-mso19: Fix white-space, cosmetics, coding-style.
Uwe Hermann [Tue, 8 Jan 2013 01:48:49 +0000 (02:48 +0100)]
link-mso19: Fix white-space, cosmetics, coding-style.

Fix the bare minumum of whitespace/indentation/coding-style via
automatic 'indent' run, followed by some minor manual fixes.
Some more fixes and cleanups might follow later.

6 years agolink-mso19: Fix (C) lines.
Uwe Hermann [Tue, 8 Jan 2013 01:30:40 +0000 (02:30 +0100)]
link-mso19: Fix (C) lines.

Bring back the original (C) lines from before the split into api.c
and protocol.[ch].

Add "Copyright (C) 2013 Lior Elazary <>" since there
were nontrivial changes to those files.

6 years Enable Link Instruments MSO-19.
Uwe Hermann [Tue, 8 Jan 2013 00:27:11 +0000 (01:27 +0100)] Enable Link Instruments MSO-19.

This driver now compiles again and (partially) seems to work, so enable it.

6 years agoAdded limit samples Eveything seems to work find up to 1024 samples
lelazary [Mon, 7 Jan 2013 15:49:31 +0000 (07:49 -0800)]
Added limit samples Eveything seems to work find up to 1024 samples

6 years agoRewrote the trigger config. Added trigger position and trigger slope
lelazary [Sun, 6 Jan 2013 17:46:01 +0000 (09:46 -0800)]
Rewrote the trigger config. Added trigger position and trigger slope

6 years agoEveything seems to work now except for triggers.
lelazary [Sun, 6 Jan 2013 02:12:45 +0000 (18:12 -0800)]
Eveything seems to work now except for triggers.

6 years agoMore cleanup. Communication with mso19 is working, but its not triggering. Need to...
lelazary [Sat, 5 Jan 2013 17:29:00 +0000 (09:29 -0800)]
More cleanup. Communication with mso19 is working, but its not triggering. Need to check why.

6 years agoAdded flow control to serial configuration to support xon/xoff for link-mso19
lelazary [Sat, 5 Jan 2013 17:00:52 +0000 (09:00 -0800)]
Added flow control to serial configuration to support xon/xoff for link-mso19

6 years agoAdded missing mso functions
lelazary [Sat, 5 Jan 2013 01:22:15 +0000 (17:22 -0800)]
Added missing mso functions

6 years agoRemoving the old link-mso19 files and changing makefile
lelazary [Sat, 5 Jan 2013 01:05:17 +0000 (17:05 -0800)]
Removing the old link-mso19 files and changing makefile

6 years agoRewrote the link-mso19.c into api and protocol. Still need to test and cleanup some...
lelazary [Sat, 5 Jan 2013 01:03:20 +0000 (17:03 -0800)]
Rewrote the link-mso19.c into api and protocol. Still need to test and cleanup some more

6 years agoAdd gnuplot_rigol_ds1xx2.gpi gnuplot script.
Uwe Hermann [Thu, 3 Jan 2013 18:17:51 +0000 (19:17 +0100)]
Add gnuplot_rigol_ds1xx2.gpi gnuplot script.

This is a very simple gnuplot script for testing the Rigol DS1xx2 driver.
It currently has various issues and limitations (e.g. only one channel
is displayed, the scaling is not usable, and so on) to be fixed later.

6 years agorigol-ds1xx2: Cosmetics, whitespace.
Uwe Hermann [Thu, 3 Jan 2013 18:04:11 +0000 (19:04 +0100)]
rigol-ds1xx2: Cosmetics, whitespace.

6 years agorigol-ds1xx2: Autoprobe for usbtmc devices on Linux.
Martin Ling [Sun, 30 Dec 2012 14:29:00 +0000 (15:29 +0100)]
rigol-ds1xx2: Autoprobe for usbtmc devices on Linux.

6 years agorigol-ds1xx2: Fix setting trigger parameters.
Martin Ling [Sun, 30 Dec 2012 13:17:08 +0000 (14:17 +0100)]
rigol-ds1xx2: Fix setting trigger parameters.

6 years agorigol-ds1xx2: Assorted parameter setting fixes.
Martin Ling [Sun, 30 Dec 2012 13:06:58 +0000 (14:06 +0100)]
rigol-ds1xx2: Assorted parameter setting fixes.

6 years agorigol-ds1xx2: First working version.
Martin Ling [Sun, 30 Dec 2012 03:17:56 +0000 (04:17 +0100)]
rigol-ds1xx2: First working version.

Currently hardcoded to use /dev/usbtmc1. Analog data readout works.

6 years agorigol-ds1xx2: Initial driver skeleton.
Martin Ling [Sat, 29 Dec 2012 21:22:10 +0000 (22:22 +0100)]
rigol-ds1xx2: Initial driver skeleton.

6 years agools: Implement SR_DI_HWOPTS.
Uwe Hermann [Thu, 3 Jan 2013 01:15:27 +0000 (02:15 +0100)]
ols: Implement SR_DI_HWOPTS.

6 years agoserial-dmm: Add UNI-T UT61E support (UT-D02 cable).
Uwe Hermann [Wed, 26 Dec 2012 00:53:50 +0000 (01:53 +0100)]
serial-dmm: Add UNI-T UT61E support (UT-D02 cable).

6 years agoAdd Cyrustek ES51922 DMM chip parser.
Uwe Hermann [Wed, 7 Nov 2012 18:10:36 +0000 (19:10 +0100)]
Add Cyrustek ES51922 DMM chip parser.

6 years agoalsa: Add some more samplerates.
Uwe Hermann [Mon, 31 Dec 2012 23:33:05 +0000 (00:33 +0100)]
alsa: Add some more samplerates.

Add some more samplerates that seem to be supported by some devices
(found via random grepping of alsa and kernel sources).

6 years agoalsa: Add missing % for PRIu64.
Uwe Hermann [Mon, 31 Dec 2012 22:31:48 +0000 (23:31 +0100)]
alsa: Add missing % for PRIu64.

6 years agoalsa: Improved error reporting.
Uwe Hermann [Mon, 31 Dec 2012 22:31:31 +0000 (23:31 +0100)]
alsa: Improved error reporting.

6 years agoalsa: Cosmetics, coding style, typos.
Uwe Hermann [Mon, 31 Dec 2012 21:54:17 +0000 (22:54 +0100)]
alsa: Cosmetics, coding style, typos.

6 years agoalsa: Find supported samplerates during device scan
Alexandru Gagniuc [Wed, 26 Dec 2012 18:11:33 +0000 (12:11 -0600)]
alsa: Find supported samplerates during device scan

Since we are using the 'hw' interface of ALSA, we don't have the luxury of
samplerate conversion, given by the 'plughw' interface. If we try to set a
samplerate that is not supported, ALSA will just throw an error.

We can test for the supported samplerates, and create a list of supported
samplerates, then limit the selection to only those values. The frontend can
query the list of supported samplerates.

Signed-off-by: Alexandru Gagniuc <>
6 years agoalsa: Fix sample acquisition and send normalized values
Alexandru Gagniuc [Sun, 23 Dec 2012 18:57:37 +0000 (12:57 -0600)]
alsa: Fix sample acquisition and send normalized values

The alsa driver requested signed 16-bit integers from ALSA, but casted them to
to an unsigned 16bit before finally casting them to a float. The end result was
that half of the wave would be clipped off.
We also requested data in little endian format. ALSA can be instructed to send
data with the correct endianness for the platform, without needing to worry
about what that is.

This patch attempts three points, which, together, fix the acquisition:
1) Request data from ALSA without specifying endianness; ALSA will handle the
2) Simplify the int16_t to float loop by using straightforward indexes.
3) Normalize every value before sending it on the session bus.

NOTE: If testing with PulseView, it will appear as if sigrok is sending all
zeroes. sigrok is sending correct data, but since the data is normalized,
PulseView will incorrectly plot it as a straight line.

Signed-off-by: Alexandru Gagniuc <>
6 years agoalsa: Scan all soundcards and create a sigrok device per input
Alexandru Gagniuc [Thu, 20 Dec 2012 19:47:09 +0000 (13:47 -0600)]
alsa: Scan all soundcards and create a sigrok device per input

The alsa driver only works with device "default". This limits the driver's
scope to whatever device ALSA deems to be "default". It is desirable to have
access to all ALSA devices from sigrok.

Change the alsa device scan so that:
Each alsa device (not alsa card) gets its own sigrok device
For example,
    hw:1,0 == sigrok device 0
    hw:1,1 == sigrok device 1
    hw:2,0 == sigrok device 2
    hw:2,1 == sigrok device 3
    hw:2,2 == sigrok device 4

We don't currently look at alsa subdevices. We only use subdevice 0.
Every input device will have its own channels (left, right, etc). Each of
those channels gets mapped to a different sigrok probe. A device with 4
channels will have 4 probes from sigrok's perspective.

Signed-off-by: Alexandru Gagniuc <>
6 years agoalsa: Do not use snd_pcm_hw_params_set_rate_near()
Alexandru Gagniuc [Thu, 27 Dec 2012 02:14:54 +0000 (20:14 -0600)]
alsa: Do not use snd_pcm_hw_params_set_rate_near()

snd_pcm_hw_params_set_rate_near() will try to use the samplerate closest to the
given value, potentially starting the acquisition with a different samplerate
than the one specified.

Instead, use snd_pcm_hw_params_set_rate(). It will return an error if the
samplerate is not supported by the hardware, which is arguably better than
collecting data with a different samplerate than the one specified.

Signed-off-by: Alexandru Gagniuc <>
6 years agors9lcd: Add missing 'break;'
Alexandru Gagniuc [Mon, 31 Dec 2012 21:14:49 +0000 (15:14 -0600)]
rs9lcd: Add missing 'break;'

A break was missing for "case MODE_AMP_WIDTH:" in sr_rs9lcd_parse().

Signed-off-by: Alexandru Gagniuc <>
6 years agoasix-sigma: Fix two compiler warnings.
Uwe Hermann [Mon, 31 Dec 2012 20:21:39 +0000 (21:21 +0100)]
asix-sigma: Fix two compiler warnings.

asix-sigma.c:648:9: warning: 'ret' may be used uninitialized in this
function [-Wmaybe-uninitialized]

asix-sigma.c:1337:20: warning: 'triggerselect' may be used uninitialized
in this function [-Wmaybe-uninitialized]

6 years agosession: Fix compiler warning.
Uwe Hermann [Mon, 31 Dec 2012 20:05:11 +0000 (21:05 +0100)]
session: Fix compiler warning.

session.c:258:6: warning: 'ret' may be used uninitialized in this
function [-Wmaybe-uninitialized]

6 years agovictor-dmm: Fix compiler warning.
Uwe Hermann [Mon, 31 Dec 2012 20:03:45 +0000 (21:03 +0100)]
victor-dmm: Fix compiler warning.

protocol.c:106:10: warning: 'factor' may be used uninitialized in this
function [-Wmaybe-uninitialized]

6 years agonexus-osciprime: Fix compiler warning.
Uwe Hermann [Mon, 31 Dec 2012 20:02:14 +0000 (21:02 +0100)]
nexus-osciprime: Fix compiler warning.

protocol.c:26:46: warning: unused parameter 'fd' [-Wunused-parameter]

6 years agouni-t-dmm: Fix compiler warning.
Uwe Hermann [Mon, 31 Dec 2012 20:01:53 +0000 (21:01 +0100)]
uni-t-dmm: Fix compiler warning.

protocol.c:84:5: warning: 'ret' may be used uninitialized in this
function [-Wmaybe-uninitialized]

6 years agors9lcd: Fix compiler warning.
Uwe Hermann [Mon, 31 Dec 2012 19:58:14 +0000 (20:58 +0100)]
rs9lcd: Fix compiler warning.

rs9lcd.c:289:19: warning: 'rawval' may be used uninitialized in this
function [-Wmaybe-uninitialized]

6 years agoadd USBTMC device search helper
Bert Vermeulen [Sun, 30 Dec 2012 00:44:58 +0000 (01:44 +0100)]
add USBTMC device search helper

6 years agotondaj-sl-814: remove unneeded debugging
Bert Vermeulen [Sat, 29 Dec 2012 10:19:19 +0000 (11:19 +0100)]
tondaj-sl-814: remove unneeded debugging

6 years agools: Add missing 'extern'.
Uwe Hermann [Fri, 28 Dec 2012 16:13:20 +0000 (17:13 +0100)]
ols: Add missing 'extern'.

6 years agoadded VID:PIDs for all Hantek DSO-2xxx/5xxx
Bert Vermeulen [Fri, 28 Dec 2012 15:46:21 +0000 (16:46 +0100)]
added VID:PIDs for all Hantek DSO-2xxx/5xxx

6 years Fix CFLAGS settings.
Uwe Hermann [Fri, 28 Dec 2012 10:22:16 +0000 (11:22 +0100)] Fix CFLAGS settings.

Don't override/overwrite CFLAGS in, but rather amend it
with (currently) "-Wall -Wextra -fvisibility=hidden".

This properly allows users/packagers to do things like:

 ./configure (this will default to using "-g -O2" additionally)

 CFLAGS="-g -O2" ./configure (same as above)

 CFLAGS="" ./configure (no additional flags)

 CFLAGS="-g -O0" ./configure (disable optimization, e.g. for valgrind use)

 etc. etc.

6 years agoserial-dmm: Rename VOLTCRAFT_VC820 to VOLTCRAFT_VC820_SER.
Uwe Hermann [Wed, 19 Dec 2012 21:50:07 +0000 (22:50 +0100)]
serial-dmm: Rename VOLTCRAFT_VC820 to VOLTCRAFT_VC820_SER.

This matches the _ser suffix of the other functions/variables for this
device ("ser" denotes that it is used with the serial UNI-T UT-D02 cable
as opposed the USB/HID based cables which are handled by the uni-t-dmm driver).

But more importantly, the _SER suffix for the enum value will prevent
name clashes later, when the uni-t-dmm driver gets a VOLTCRAFT_VC820 enum.

Do the same for VOLTCRAFT_VC840.

6 years agoFix limit_samples check in various drivers.
Uwe Hermann [Wed, 26 Dec 2012 00:29:27 +0000 (01:29 +0100)]
Fix limit_samples check in various drivers.

Check whether a sample limit was actually set (> 0) before checking if
that sample limit is reached. This also fixes continuous acquisition mode
for drivers which have that.

6 years agoShorten probe_names[] arrays everywhere.
Uwe Hermann [Tue, 25 Dec 2012 23:12:52 +0000 (00:12 +0100)]
Shorten probe_names[] arrays everywhere.

Also, NULL-terminate all of them.

6 years agonexus-osciprime: suppress warnings
Bert Vermeulen [Tue, 25 Dec 2012 23:01:37 +0000 (00:01 +0100)]
nexus-osciprime: suppress warnings

6 years agoserial-dmm: Handle time-limited acquisition
Alexandru Gagniuc [Sun, 23 Dec 2012 18:48:48 +0000 (12:48 -0600)]
serial-dmm: Handle time-limited acquisition

Implement SR_HWCAP_LIMIT_MSEC capability, to allow acquisition to automatically
stop after a specified amount of time.

Signed-off-by: Alexandru Gagniuc <>
6 years agors9lcd: Fix segfault with unusual modes.
Alexandru Gagniuc [Tue, 25 Dec 2012 22:21:24 +0000 (16:21 -0600)]
rs9lcd: Fix segfault with unusual modes.

Some unusual modes required re-parsing the value. Instead of assigning the
re-parsed value to *floatval, it was reassigned directly to *analog->data;
however, analog->data is not initialized at this point, causing a segfault.
This situation was created when moving the radioshack-dmm code to serial-dmm,
with the segfault not being observed at that time.

Do not write directly to analog->data, but instead use the intermediate
variable rawval.

Signed-off-by: Alexandru Gagniuc <>
6 years agors9lcd: Convenience fixes
Alexandru Gagniuc [Tue, 25 Dec 2012 21:40:30 +0000 (15:40 -0600)]
rs9lcd: Convenience fixes

Convert bit masks from hardcoded hex values to bit shifts. For example 0x80
becomes (1 << 7). This also fixes a typo error in the definition of INFO_DIODE.

Add comments explaining that some case values in sr_rs9lcd_parse() are meant to
fall through without a 'break;', and explain some of the unusual modes.

Signed-off-by: Alexandru Gagniuc <>
6 years agoadded Nexus-Computing OsciPrime VID:PID
Bert Vermeulen [Tue, 25 Dec 2012 18:13:20 +0000 (19:13 +0100)]
added Nexus-Computing OsciPrime VID:PID

6 years agonexus-osciprime: basic scanning functionality
Bert Vermeulen [Tue, 25 Dec 2012 18:09:12 +0000 (19:09 +0100)]
nexus-osciprime: basic scanning functionality

Unfortunately the device doesn't have an EEPROM on board at all, and so
initially enumerates with the default Cypress FX2 VID:PID (04b4:8613).
Since we already support using plain FX2* as basic logic analyzers using
the fx2lafw firmware, we cannot support that same VID:PID for the
OsciPrime. Therefore a USB conn is required for the initial scan.

However, once the firmware is uploaded the device re-enumerates as
04b4:1004, which we do detect for scanning automatically.

Thus, the OsciPrime driver requires one scan with conn parameter to get
the firmware uploaded, but it will then keep working until powered off.

6 years agonexus-osciprime: Initial driver skeleton.
Bert Vermeulen [Mon, 24 Dec 2012 19:11:38 +0000 (20:11 +0100)]
nexus-osciprime: Initial driver skeleton.

6 years agofluke-dmm: Properly handle continuous mode
Bert Vermeulen [Mon, 24 Dec 2012 19:27:45 +0000 (20:27 +0100)]
fluke-dmm: Properly handle continuous mode

Same bug+fix as commit d55c89f523e74a2f629bb23e8fd9bf6db7e3758a

6 years agosession.c: Remove all remaining sources on sr_session_stop
Alexandru Gagniuc [Wed, 19 Dec 2012 10:15:18 +0000 (04:15 -0600)]
session.c: Remove all remaining sources on sr_session_stop

Some sources may not be necessarily associated with a device. The best example
is the anykey pollfd from sigrok-cli. sr_session_stop only removes sources
associated with hardware devices via dev_acquisition_stop. Sources such as
anykey are not removed, and thus session->num_sources will not get to 0. As a
result, we may get into situations where the event loop enters an infinite

To prevent this, all we have to do is remove any active sources that are still
present after dev_acquisition_stop has been called for all devices.

This fixes bug 14.

6 years agoasix-sigma: Quickfix for an ASIX SIGMA issue.
Uwe Hermann [Mon, 24 Dec 2012 15:57:55 +0000 (16:57 +0100)]
asix-sigma: Quickfix for an ASIX SIGMA issue.

It's not entirely clear whether this is the right fix, but we're merging
it for now, pending later review.

See also:

6 years agofx2lafw: Tidied probe_names
Joel Holdsworth [Tue, 11 Dec 2012 20:51:53 +0000 (20:51 +0000)]
fx2lafw: Tidied probe_names

6 years agools: Split into api.c and protocol.[ch].
Uwe Hermann [Sun, 23 Dec 2012 19:41:27 +0000 (20:41 +0100)]
ols: Split into api.c and protocol.[ch].

Also, drop various no longer needed #include files.

6 years agools: Use logging helper macro.
Uwe Hermann [Sun, 23 Dec 2012 18:09:11 +0000 (19:09 +0100)]
ols: Use logging helper macro.

6 years agofluke-dmm: 190 series scopemeter support
Bert Vermeulen [Mon, 24 Dec 2012 10:00:55 +0000 (11:00 +0100)]
fluke-dmm: 190 series scopemeter support

199B only for now.

6 years agofluke-dmm: parser cleanup
Bert Vermeulen [Mon, 24 Dec 2012 09:59:41 +0000 (10:59 +0100)]
fluke-dmm: parser cleanup

6 years agofluke-dmm: adapt scanner to accomodate 190 series scopemeters
Bert Vermeulen [Mon, 24 Dec 2012 09:56:54 +0000 (10:56 +0100)]
fluke-dmm: adapt scanner to accomodate 190 series scopemeters

6 years agofluke-dmm: make poll timeout configurable
Bert Vermeulen [Mon, 24 Dec 2012 09:40:04 +0000 (10:40 +0100)]
fluke-dmm: make poll timeout configurable

Defaulted to 1s before, but a simple "QM" command on a 199B in scope
mode takes 1.7s to come through.

6 years agoserial: more debug cleanup
Bert Vermeulen [Sun, 23 Dec 2012 17:54:24 +0000 (18:54 +0100)]
serial: more debug cleanup

6 years agoserial: get rid of overly verbose spew
Bert Vermeulen [Thu, 20 Dec 2012 09:41:48 +0000 (10:41 +0100)]
serial: get rid of overly verbose spew

It just made spew-level logging unusable; the way sigrok async comms work
guarantees most of it was a false error.

6 years agoalsa: Split into api.c and protocol.c
Alexandru Gagniuc [Thu, 20 Dec 2012 17:33:49 +0000 (11:33 -0600)]
alsa: Split into api.c and protocol.c

This is the driver model agreed upon for all drivers.

As a result of the split, a devc->num_probes field had to be added in order to
reduce the interdependence between api.c and protocol.c .

Signed-off-by: Alexandru Gagniuc <>
6 years agodevice.c: Fix memory leak in sr_serial_dev_inst_free
Alexandru Gagniuc [Thu, 20 Dec 2012 03:39:38 +0000 (21:39 -0600)]
device.c: Fix memory leak in sr_serial_dev_inst_free

sr_serial_dev_inst_free() freed all members of sr_serial_dev_inst, but did not
free the struct itself, as expected from a free_*() function. This inadvertently
caused a memory leak in every place sr_serial_dev_inst is used.

Free the struct itself

+ g_free(serial);

Signed-off-by: Alexandru Gagniuc <>
6 years agoserial-dmm: Properly handle continuous mode
Alexandru Gagniuc [Sat, 22 Dec 2012 22:00:44 +0000 (16:00 -0600)]
serial-dmm: Properly handle continuous mode

serial-dmm does not check if a sample limit is actually in place before deciding
to stop acquisition. Since the sample limit is set at 0 by default, operating
in continuous mode will cause acquisition to stop before even sending the first

Check to make sure we actually are in a sample-limited mode before stopping for
this reason.

Signed-off-by: Alexandru Gagniuc <>
6 years Improve check for libusb-1.0.
Uwe Hermann [Sat, 22 Dec 2012 00:33:03 +0000 (01:33 +0100)] Improve check for libusb-1.0.

PKG_CHECK_MODULES() checks for libusb-1.0 via pkg-config already, no
need to use a "manual" additional check via AC_CHECK_LIB() just to set
HAVE_LIBUSB_1_0 in config.h.

This helps with cross-compiling setups, among other things.

6 years agoalsa: Update to latest APIs/conventions.
Uwe Hermann [Mon, 17 Dec 2012 18:39:13 +0000 (19:39 +0100)]
alsa: Update to latest APIs/conventions.

The alsa driver was out of date wrt APIs and libsigrok conventions in
general, and wasn't compiling.

This fixes the compile and updates it to _basically_ work with the current
state of analog support in libsigrok.

This is not finished/full support for ALSA analog sampling yet, though,
various TODOs remain that will be addressed later.

6 years agoPass sr_datafeed_packets and payloads with const pointers
Joel Holdsworth [Thu, 13 Dec 2012 21:07:53 +0000 (21:07 +0000)]
Pass sr_datafeed_packets and payloads with const pointers

This patch marks packet structures and their payloads as const.
This indicates to packet receivers that modifications to these are
not allowed. In general all pointers should be marked const unless
modification of the referenced data is explicitly allowed.

6 years agohardware/agilent-dmm/ Fix typo.
Uwe Hermann [Tue, 18 Dec 2012 01:25:17 +0000 (02:25 +0100)]
hardware/agilent-dmm/ Fix typo.

6 years agochronovu-la8: Fix memory leak in hw_scan
Alexandru Gagniuc [Mon, 17 Dec 2012 08:04:35 +0000 (02:04 -0600)]
chronovu-la8: Fix memory leak in hw_scan

Hardware scanning creates an ftdi_context before attempting to locate devices
based on PID/VID. If no devices are detected, execution jumps to cleanup. The
context is freed with free(), instead of ftdi_free().

We cannot assume that the libftdi context is stored in a contiguous memory
region, and thus cannot use a simple free. Case in point, this situation is
identified by valgrind as a "definitely lost" memory leak.

Use ftdi_free() instead of a simple free() in hw_scan(). Valgrind no longer
complains about a memory leak in this area.

clear_instances() does not need any modification, as it correctly uses

Signed-off-by: Alexandru Gagniuc <>
6 years agofx2lafw: Fix int64_t printing.
Uwe Hermann [Tue, 18 Dec 2012 00:30:34 +0000 (01:30 +0100)]
fx2lafw: Fix int64_t printing.

6 years agofx2lafw: Various cosmetics, typo fixes, etc.
Uwe Hermann [Tue, 18 Dec 2012 00:26:58 +0000 (01:26 +0100)]
fx2lafw: Various cosmetics, typo fixes, etc.

6 years agoConsistently use 'di' as variable name.
Uwe Hermann [Mon, 17 Dec 2012 23:52:39 +0000 (00:52 +0100)]
Consistently use 'di' as variable name.

Use 'di' consistently in all drivers as the name for a local, static
pointer to the respective driver's 'struct sr_dev_driver'.

6 years agofx2lafw: Print device failed to renumerate error
Alexandru Gagniuc [Thu, 6 Dec 2012 21:55:14 +0000 (15:55 -0600)]
fx2lafw: Print device failed to renumerate error

commit 378abfeac6cc94d88dc82b8481dec9c9f691f3da tried to solve a bug where
the fx2lafw driver would print "Device came back" even if a timeout had occured.

It solved that issue, but inadvertently introduced a new bug:
"Device came back" would be printed even if no firmware upload was performed.
This is counterintuitive, as the device is only reset when a firmware upload is

There are three cases:
i)   Firmware upload was successful
ii)  Firmware upload failed
iii) Firmware upload was NOT needed

Each case warrants a separate message from the driver. Print the
following messages depending on the outcome:

i)   "Device came back"
ii)  "Device failed to renumerate"
iii) "Firmware upload was not needed."

Signed-off-by: Alexandru Gagniuc <>
6 years agofx2lafw: Use DRIVER_LOG_DOMAIN for log messages
Alexandru Gagniuc [Thu, 13 Dec 2012 21:08:05 +0000 (15:08 -0600)]
fx2lafw: Use DRIVER_LOG_DOMAIN for log messages

Use the new DRIVER_LOG_DOMAIN mechanism, where explicitly writing
the driver name in the message string is no longer required.


- sr_err("fx2lafw: Something bad happened.");


+ sr_err("Something bad happened.");

In either case, the log output is the same.

Signed-off-by: Alexandru Gagniuc <>
6 years agoserial_stream_detect(): Drop unneeded sr_spew().
Uwe Hermann [Sun, 16 Dec 2012 21:27:04 +0000 (22:27 +0100)]
serial_stream_detect(): Drop unneeded sr_spew().

6 years agoserial-dmm: Add Voltcraft VC-840 (UT-D02) support.
Uwe Hermann [Sun, 16 Dec 2012 21:17:48 +0000 (22:17 +0100)]
serial-dmm: Add Voltcraft VC-840 (UT-D02) support.

This works with the UNI-T UT-D02 (RS232) cable. For the USB/HID
based cable (UNI-T UT-D04), the uni-t-dmm driver must be used.

Note: This is untested, but should work just fine for all settings, with
the possible exception of temperature (testers needed!)

6 years agoserial-dmm: Add Voltcraft VC-820 (UT-D02) support.
Uwe Hermann [Sun, 16 Dec 2012 21:03:28 +0000 (22:03 +0100)]
serial-dmm: Add Voltcraft VC-820 (UT-D02) support.

This works with the UNI-T UT-D02 (RS232) cable. For the USB/HID
based cable (UNI-T UT-D04), the uni-t-dmm driver must be used.

6 years agoserial-dmm: Eliminate unneeded "subdriver" field.
Uwe Hermann [Sun, 16 Dec 2012 20:28:26 +0000 (21:28 +0100)]
serial-dmm: Eliminate unneeded "subdriver" field.

Just use the 'int dmm' + wrapper method that is used for all other
functions which need this information. There is no real need to
special-case the hw_dev_acquisition_start() API call here.

6 years agoserial-dmm: Cosmetics, documentation fixes.
Uwe Hermann [Sun, 16 Dec 2012 20:23:49 +0000 (21:23 +0100)]
serial-dmm: Cosmetics, documentation fixes.

6 years agolascar-el-usb: fix sample limit parameter
Bert Vermeulen [Sun, 16 Dec 2012 22:06:15 +0000 (23:06 +0100)]
lascar-el-usb: fix sample limit parameter

6 years agolinsigrok.h: Document meaning of SR_UNIT_CONCENTRATION
Alexandru Gagniuc [Sat, 15 Dec 2012 17:03:10 +0000 (11:03 -0600)]
linsigrok.h: Document meaning of SR_UNIT_CONCENTRATION

Having concentration as a unit is vague, as it can be expressed in
many ways. In the context of sigrok, concentration means a normalized
number from 0 to 1.

Document its meaning.

Signed-off-by: Alexandru Gagniuc <>
6 years agolascar-el-usb: support for EL-USB-2*
Bert Vermeulen [Sun, 16 Dec 2012 17:48:20 +0000 (18:48 +0100)]
lascar-el-usb: support for EL-USB-2*

6 years agoadd relative humidity MQ
Bert Vermeulen [Sun, 16 Dec 2012 17:38:44 +0000 (18:38 +0100)]
add relative humidity MQ