Commit Graph

448 Commits

Author SHA1 Message Date
Bert Vermeulen 3a0fe4023d genericdmm: use new scan API 2012-08-03 10:27:37 +02:00
Bert Vermeulen bbb40871c8 genericdmm: more flexible device discovery 2012-08-03 10:27:37 +02:00
Bert Vermeulen 75337758d8 genericdmm: use driver struct-based device instance list 2012-08-03 10:27:37 +02:00
Bert Vermeulen a8cc8e44b9 fx2lafw: use driver struct-based device instance list 2012-08-03 10:27:37 +02:00
Bert Vermeulen 06717a8a60 fx2lafw: use new instance-based probe list 2012-08-03 10:27:37 +02:00
Bert Vermeulen 3a7a22cb07 fx2lafw: use new init/scan API 2012-08-03 10:27:37 +02:00
Bert Vermeulen 633b2fac75 genericdmm: better subdriver API arguments 2012-08-03 10:27:37 +02:00
Bert Vermeulen 1ef445b3d6 genericdmm/fs9922: no initialization needed 2012-08-03 10:27:36 +02:00
Bert Vermeulen 7fc754a0db genericdmm: allow for default options in DMM profiles
Much better than the special-cased USB vid.pid
2012-08-03 10:27:36 +02:00
Bert Vermeulen 7356a55db8 genericdmm: use vid.pid as USB conn spec
: is just too hard for the CLI
2012-08-03 10:27:36 +02:00
Bert Vermeulen db1352007d genericdmm: fix header guard 2012-08-03 10:27:36 +02:00
Bert Vermeulen 61136ea603 sr: add new driver API call: scan()
This changes the semantics of the init() call as well. That now only
initializes the driver -- an administrative affair, no hardware gets
touched during this call. It returns a standard SR_OK or SR_ERR* code.

The scan() call does a discovery run for devices it knows, and returns
the number found. It can be called at any time.
2012-08-03 10:27:36 +02:00
Bert Vermeulen 40dda2c3a5 sr: remove unused argument from hardware driver function init()
It was actually used in one way: the session file loaded abused it for
passing in the filename -- something it definitely wasn't intended for.
This now uses the proper way to pass arguments to a driver: the new
SR_HWCAP_SESSIONFILE.

The OLS driver could also use it as an indication of the serial port to
use instead of actively probing all serial ports on the system, but there
wasn't any frontend code that passed in such a parameter, making it
entirely useless. That will soon be handled differently with the new
scan() API call, regardless.
2012-08-03 10:27:36 +02:00
Ivan Fedorov 0e8d0e24d0 sr: fx2lafw: Add 16bit support for USBee DX and clones
gnuplot script support only 8 channels
2012-08-03 00:25:37 +02:00
Ivan Fedorov c9166745f2 sr: fx2lafw: Add basic support for USBee DX and clones 2012-08-01 00:12:00 +04:00
Bert Vermeulen d67b663e21 sr: chronovu-la8: fix segfault on discovery
If the uninitialized value didn't happen to contain 0, and there
is no Chronovu LA8 connected, the la8_close() causes a segfault
in libftdi.
2012-07-24 00:53:01 +02:00
Uwe Hermann 74e5f12d3d sr: la8: Support for newer USB VID/PID of the device.
Thanks to Jerry Jacobs for the patch!
2012-07-15 00:34:27 +02:00
Uwe Hermann 43be303c84 sr: la8: Drop useless cast. 2012-07-12 23:23:13 +02:00
Uwe Hermann 615183ea16 sr: Drop mastech-va18b, code will be in genericdmm. 2012-07-11 12:57:15 +02:00
Bert Vermeulen 28b9dd1861 sr: fix conditional build for ezusb and serial helpers 2012-07-11 12:36:49 +02:00
Lars-Peter Clausen e6e8f8e053 sr: demodevice: Make read channel non-blocking
Both pipe channels are currently configured as blocking. We read from the pipe
in receive_data. Since the channel is configured as blocking we'll block in
receive_data until all data has been received. receive_data will be called from
the mainloop, so as consequence the mainloop will be blocked until the demo
device has finished sampling. This is not so much of a problem if we are
sampling in blocking mode (using sr_session_run()) and the demo device is the
only device in the session, but it will fail badly for all other configurations
(e.g. multiple devices or async sampling).

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-10 20:13:31 +02:00
Lars-Peter Clausen e7d087bf0e sr: fx2lafw: Free transfers in reverse order
Free the USB transfers in the reverse order of which they were submitted. This
will avoid that while transfer 0 is cancelledd transfer 1 is started by the
host controller, and so on.

Reported-by: Peter Stuge <peter@stuge.se>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-08 21:39:30 +02:00
Lars-Peter Clausen 249ae2be8f sr: session/demo: Remove Windows specific hack
The session and demo device code contain a hack to make the demo device work on
Windows. This was neccessary since polling on windows requires special handling
and we can not just pass in the raw fd to poll.

With the previous patches which added support for non-fd based event sources
this hack is no longer required. The patch moves the GIOChannels used by the
demo device to the demo device context and uses sr_session_source_add_channel
to register a source for the channels instead of using the raw pipe fds.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-05 01:41:01 +02:00
Bert Vermeulen 45c59c8bdd sr: moved sigrok.h so libsigrok/libsigrok.h
All frontends will have to include <libsigrok/libsigrok.h> from now on.
This header includes proto.h and version.h, both installed from the
distribution into $INCLUDE/libsigrok/ as well.

The only dynamically changed header is now version.h, which has both
libsigrok and libtool compile-time versions in it.
2012-07-05 01:17:28 +02:00
Lars-Peter Clausen 8489264f1e sr: demodevice: Reset sample limit when setting time limit and vice versa
Only one limit should be active at a time. Make sure that the sample limit is
disabled when a time limit is set and vice versa.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-04 01:11:50 +02:00
Lars-Peter Clausen 25f5d66a77 sr: fx2lafw: Fix potential leaks in acquisition_start error paths
Call abort_acquisition if starting sampling fails in acquisition_start, this
will ensure that all already allocated resources are being freed again.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-04 01:11:50 +02:00
Lars-Peter Clausen c03f045004 sr: fx2lafw: Do not start a new acquisition if the old is still running
This may happen if the acquisition_start is called right after calling
acquisition_stop and not all transfers have been freed or on repeated calls to
acquisition_start. If it happens we'll enter an undefined state and all kind of
strange behavior may occur, so error out in such a case.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-04 01:11:50 +02:00
Lars-Peter Clausen 0caa1ef0cb sr: fx2lafw: Abort pending transfers when sampling is stopped
The recent reworks of the fx2lafw made sure that the total buffer size is large
enough hold 500ms of data. This was done to improve performance and stability.
That the timeout value for a transfer was also increased to over 500ms, a side
effect of this is that when sampling is stopped there will be a additional delay
of 500ms. This is because the driver waits for all transfers to be freed
before it sends a SR_DF_END packet. Once sampling has stopped this will only
happen once a transfer times out. This patch cancels all pending transfers when
sampling is stopped, this will cause them to be freed almost immediately and the
additional delay will disappear.

Also make sure, that if we know, that we just have received the last transfer to
not resubmit this transfer again.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-04 01:11:50 +02:00
Bert Vermeulen ca3d84cca1 sr: add genericdmm driver 2012-07-01 22:37:15 +02:00
Bert Vermeulen f8c1fcda46 sr: use proper definitions for parity setting
ols driver fixed to use these as well.
2012-07-01 22:31:31 +02:00
Uwe Hermann 163f0523f6 sr: Mastech VA18B: Partial protocol supports (WIP).
Disable the driver for now, as it's not usable for the general public, yet.
2012-06-28 22:57:03 +02:00
Uwe Hermann 99f5d45ecc sr: hantek-dso: Fix copy-paste error. 2012-06-28 01:47:38 +02:00
Lars-Peter Clausen 2769eed991 sr: fx2lafw: Move empty_transfer_count to device ctx
If one device is failing it should not affect the transfers of other devices.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-06-28 00:40:52 +02:00
Lars-Peter Clausen 5af666a94e sr: fx2lafw: Calculate buffer size and timeout based on sample rate
Currently timeout and buffer size are hard-coded in the fx2lafw driver which is
non-optimal if we want to get good results at both high and low sample rates.

The timeout is hard-coded to 40ms, which doesn't work well when sampling at
a low sample rate. E.g. at 20kHz filling all available buffer space alone takes
6 seconds. So naturally we'll see a lot of transfers timeout in this case.

The buffer size is hard-coded to 4096 bytes, which does not work well with high
sample rates. E.g. at 24MHz these 4096 bytes are enough space for 0.17ms of
data. The total buffer size is enough for about 5ms of data. Sooner or later the
application won't be able to resubmit a transfer within this time span and the
device will abort data acquisition. Usually this happens within the first few
seconds of sampling.

This patch adds a few new helper functions which calculate the buffer size and
timeout based on the current sample rate.

The buffer size is chosen to be large enough to hold about 10ms of data and it
also must be a multiple of 512 bytes since the firmware will send us the data
in 512 byte chunks.

The timeout is set to the time it would take to fill the whole available buffer
space plus a 25% headroom to accommodate for jitter. This is more than enough,
but there is no need to make the timeout a tight deadline, since it is only
meant as a last resort in case the device stops submitting data. And in this
case data acquisition will be aborted anyway.

The patch also limits the the number of transfers so that the total buffer
space is not much more of 500ms. This will ensure that we do not have to
wait too long when aborting data acquisition.

This patch also significantly reduces the number of context switches when
sampling at a higher sample rate. On my system for example the CPU load of
sigrok-cli when sampling at 24MHz goes down from ~25% to 3-4%.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-06-28 00:40:52 +02:00
Lars-Peter Clausen 7ce737a77c sr: fx2lafw: Handle the transfer's status
While errors are usually already implicitly caught by looking at the packet
length field there is one error status which is worth special handling. If the
device has been removed there is not really a chance to recover from this error
so data acquisition can be stopped immediately.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-06-28 00:40:52 +02:00
Lars-Peter Clausen 17dff8a1e6 sr: fx2lafw: Avoid unnecessary alloc/free combo
In receive_transfer for each completed transfer a new buffer is allocated and
the old one is freed. We can avoid this by simply reusing the buffer for the
next transfer. This is possible if we only resubmit the transfer after all
processing on the data buffer has been done. A new buffer is only allocated if
the size of the old one is not 4096 bytes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-06-28 00:40:51 +02:00
Lars-Peter Clausen f855de7575 sr: fx2lafw: Properly free transfer
When freeing a transfer we also have to free the transfer buffer. We also have
to keep track of the number of allocated transfers and if the freed transfer was
the last one stop acquisition. This patch introduces a helper function which
takes care of all of this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-06-28 00:40:51 +02:00
Lars-Peter Clausen bd47acabe3 sr: fx2lafw: Allocate header and packet struct on the stack
The header and packet struct are only used in the scope of this function and
they are freed at the end of it. Also these structs are rather small, so they
can safely be allocated on the stack. By doing so memory leaks on the error
paths are avoided.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-06-28 00:40:51 +02:00
Joel Holdsworth 0c156e06c5 fx2lafw: Made libusb_claim_interface error messages more informative 2012-06-28 00:40:48 +02:00
Bert Vermeulen 88a13f30bd hantek-dso: add profiles for all five models in the series
Also cleaned up profile struct, and use the new firmware filenames.
2012-06-27 19:36:30 +02:00
Bert Vermeulen 3b6c19303d fx2lafw: fix broken firmware upload timeout
Also corner case error init.
2012-06-27 01:02:39 +02:00
Bert Vermeulen fc8fe3e314 hantek-dso: get rid of broken GTV_TO_MSEC firmware upload timeout 2012-06-27 01:02:06 +02:00
Bert Vermeulen e749a8cb50 hantek-dso: start sending the frame only from the trigger point
Samples received before the trigger point are stored. From the
trigger point on, every chunk received from the device is sent
up the session bus. After the device has finished sending, the
stored samples are transmitted.
2012-06-26 23:26:55 +02:00
Lars-Peter Clausen fa114e4ab1 sr: fx2lafw: Set correct unitsize for trigger buffer
Commit 88b75eb719 ("fx2lafw: Added device caps and added support for wide
sampling") increased the size of the trigger buffer from 8 to 16 bit, but forgot
to adjust the unitsize logic packet which is used to send the contents of the
trigger buffer. This patch sets the unitsize to sizeof() of the trigger buffer.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-06-25 19:48:21 +02:00
Bert Vermeulen e05a174be2 hantek-dso: fix triggerpoint conversion 2012-06-24 18:57:37 +02:00
Lars-Peter Clausen f3ab43a8fb sr: fx2lafw: Fix multistage trigger
Multistage triggers currently do no work, because there is a return statement
in the middle of the trigger detector which will be hit as soon as the first
stage in a multistage trigger matches. This patch removes the return statement
so that the trigger detector can continue to try to match the next stage. In
order for this to work we also make sure that the trigger stage is only reset
if the current sample does not match.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-06-24 14:35:26 +02:00
Lars-Peter Clausen eabf24035b sr: fx2lafw: Fix memory leaks in receive_transfer
There are a few memory leaks in the receive_transfer transfer function. The most
serve of them is that a sample buffer is not freed if the triggered has not
matched yet, which causes a sigrok process which is waiting for a trigger to
consume several megabytes of memory within seconds. The other leaks are on the
error paths in that function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-06-22 09:23:30 +02:00
Uwe Hermann 9edfee3ee3 sr: ols: Fix incorrect comment. 2012-06-21 23:59:27 +02:00
Uwe Hermann eb1f1eb407 sr: Unfinished Mastech VA18B (DMM) support. 2012-06-21 23:56:24 +02:00
Uwe Hermann b908f067f2 sr: chronovu-la8: Split code into api.c and driver.c.
We should generally use api.c for API related functions and put the other
functions (mostly hardware-specific low-level code) into other C file(s)
for better readability.
2012-06-21 23:34:38 +02:00