Commit Graph

429 Commits

Author SHA1 Message Date
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
Uwe Hermann 9956f2851f sr: analog: Add MQ and UNIT enums.
MQ is the measured quantity, e.g. voltage, current, temperature.

UNIT is the unit in which these quantities are measured, e.g. volt,
ampere, celsius, kelvin, etc. etc.

The same MQ can be specified in different UNITs by the driver, depending
on what the hardware reports. Conversion is left to the frontends.
2012-06-20 23:55:23 +02:00
Uwe Hermann c13536fa9c sr: backend/zeroplus: Improve debug output. 2012-06-19 23:33:50 +02:00
Bert Vermeulen 6e6eeff47a hantek-dso: capturestate packet also contains the trigger point
Not yet used, but it's the key to knowing where in the frame to
start displaying; the frame is used as a circular buffer, and what
is sent is effectively a snapshot.
2012-06-18 23:09:37 +02:00
Bert Vermeulen a217bcdf10 hantek-dso: relays now set properly
They appear to be arranged to switch on/off a hierarchical series of
devices that attenuate the channel by an order of magnitude.
2012-06-18 23:05:02 +02:00
Uwe Hermann 384c28d9e7 sr: hantek-dso: Use portable g_ntohs() function.
The ntohs() from <arpa/inet.h> is not available on MinGW/Windows. There
are ways to work around this, but as we use glib already, using g_ntohs()
is the best option anyway.
2012-06-14 01:21:00 +02:00
Bert Vermeulen c5841b2809 hantek-dso: calculate voltage based on vdiv setting 2012-06-05 18:18:23 +02:00
Bert Vermeulen a10c805636 hantek-dso: default to DC coupling 2012-06-05 18:18:23 +02:00
Bert Vermeulen 1d97091e71 hantek-dso: fix CH2 vdiv setting 2012-06-05 18:18:23 +02:00
Bert Vermeulen aff5a729ab sr: add unit field to sr_df_analog packet 2012-06-05 18:18:23 +02:00
Uwe Hermann 62bb8840e1 sr: hantek-dso: Consistency renames, constification. 2012-06-01 01:12:09 +02:00
Uwe Hermann 0a88ec3d9c sr: fx2lafw: Use gboolean, cosmetics, fix gcc warning. 2012-05-31 22:48:40 +02:00
Uwe Hermann af36b80969 hantek-dso: Update to constified libsigrok API. 2012-05-31 22:43:12 +02:00
Uwe Hermann 88ff66c2c9 hantek-dso: Quickfix for build issue (will be removed later). 2012-05-31 22:40:41 +02:00
Joel Holdsworth f4575b6549 fx2lafw: Added a check to limit the sample rate during 16-bit sampling 2012-05-31 19:53:36 +01:00
Joel Holdsworth d1ddc7a9a8 fx2lafw: Added device caps and added support for wide sampling 2012-05-31 19:52:32 +01:00
Joel Holdsworth a533743dd1 sr: Made sample rate lists const 2012-05-31 19:51:11 +01:00
Joel Holdsworth 1b79df2f57 sr: Made the dev_config_set parameter a const pointer 2012-05-31 19:51:11 +01:00
Joel Holdsworth b7f578bef5 sr: Made the dev_info_get return value const 2012-05-31 19:51:10 +01:00
Joel Holdsworth 915f7cc87a sr: Made hwcap const 2012-05-31 19:51:09 +01:00