Commit Graph

4042 Commits

Author SHA1 Message Date
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 e9869966be configure: Add check for __int128_t and __uint128_t types 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
Marvin Schmidt 4def782b6e gitignore: Add files generated when building Ruby bindings 2016-05-14 01:02:00 +02:00
Marvin Schmidt b571f84c84 build: Replace AX_CXX_COMPILE_STDCXX_11 with latest AX_CXX_COMPILE_STDCXX
The former appended the necessary switch to enable C++11 to the CXXFLAGS
whereas AX_CXX_COMPILE_STDCXX appends it to CXX which has the benefit
that all C++ sources are compiled using the same C++ standard. Therefore
it is no longer necessary to manually hardcode '-std=c++11' anywhere
like we did in the Ruby bindings linker command and assures that the
compilation of them is done with C++11 support as well.

This fixes bug #795
2016-05-14 00:36:43 +02:00
Marvin Schmidt c4a1015a29 build: Fix distribution of Ruby bindings
The bindings file was not listed in EXTRA_DIST and therefore not
distributed. We also need to provide an target to uninstall the Ruby
bindings and add it to UNINSTALL_EXTRA in order to make `make distcheck`
happy.

This fixes bug #741
2016-05-14 00:32:37 +02:00
Aurelien Jacobs 17165513f3 ruby: Fix out-of-tree build of the bindings.
This closes bug #797.
2016-05-12 23:08:21 +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