Commit Graph

760 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 dd34b8d3c4 sr: add GSList of instances to the driver struct
This gives the driver a private place to keep its instances, without
polluting the global namespace.
2012-08-03 10:27:37 +02:00
Bert Vermeulen 47211d65b4 sr: add probe list to device instance
There is no point in libsigrok copying probe lists around. The driver now
builds a list of probes according to the model device it found, and will
make that available to a frontend. The frontend thus has a reference of
what the driver has, including default names, and doesn't need libsigrok
to provide an unnecessary level of abstraction.

The sr_probe_new() library-private function is a helper for drivers.
2012-08-03 10:27:37 +02:00
Bert Vermeulen 80bf042635 sr: split driver init into init() and scan()
init() now only does whatever administrative stuff it needs (typically not
much), and returns an error code.

scan() can be called multiple times during the life of an application, and
returns a GSList of struct sr_dev_inst * of devices found during that scan.
The instances are a copy of the ones stored in the driver's own instance
list, to be freed by the caller with g_slist_free() only.

The scan() call can be passed a GSList of struct sr_hwopt *, to direct the
scanning.
2012-08-03 10:27:37 +02:00
Bert Vermeulen b159add3d9 sr: move SR_HWOPT into its own enum, and create struct sr_hwopt
SR_HWOPT_* entries are driver options, not device instance parameters, so
they will never be mixed together.

Also, driver options are always passed in a GSList, where the data field
is a struct sr_hwopt.
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 0d012ede9d sr: fix gnuplot script for USBee DX and clones
- Now channels order is right
 - Added 16bit version
2012-08-03 00:25:38 +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 c19298d141 sr: add gnuplot script for USBee DX and clones 2012-08-01 00:12:00 +04:00
Ivan Fedorov c9166745f2 sr: fx2lafw: Add basic support for USBee DX and clones 2012-08-01 00:12:00 +04:00
Bert Vermeulen 0d1297a291 sr: always use uint64_t for samplerate 2012-07-29 02:45:40 +02:00
Bert Vermeulen b04781bb2b sr: extra checks for properly handling driverless devices 2012-07-29 02:16:17 +02:00
Bert Vermeulen 3dafb92bde sr: fix struct sr_input for parameter passing 2012-07-29 02:16:17 +02:00
Tomaž Šolc c506a6a688 Allow setting samplerate when reading binary files
I had a binary file that I needed to decode using UART decoder. UART
decoder needs to know the sample rate for the data, but currently it's
not possible to pass parameters to input formats and so the "binary"
file format always sets the samplerate to 0.

This patch adds the possibility to append a colon-separated list of
key=value options to the -I argument, in the same way -d supports it.
Also, it makes the "binary" format support the "samplerate" option.

I included the GHashTable containing input format options directly in
the sr_input struct. I'm not sure if that's the right way to do it. I
saw that -d uses a much more elaborate system with device capabilities
and typed options, but that seemed like an overkill for input formats.
2012-07-29 02:16:17 +02: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 b5a8e84825 sr: Add sr_strerror() and sr_strerror_name(). 2012-07-12 23:23:07 +02:00
Lars-Peter Clausen 9ffbde0e84 sr: session: Deprecate sr_session_halt()
sr_session_halt() in its current state is kind of useless and even dangerous.
All it will do is mark the session as not running, but wont signal the devices
to stop to capture data. This is not so much of a problem with the blocking
sr_session_run(), but once there is support for asynchronous data acquisition by
attaching the session sources to the applications mainloop sr_session_halt()
basically becomes a no-op. sr_session_stop() already does what needs to be done,
marking the session as not running and signal the devices to stop acquisition,
so make sr_session_halt() an alias for sr_session_stop() and deprecate its
usage.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-11 23:28:35 +02:00
Lars-Peter Clausen 9213ad012a sr: session: Do not cleanup the driver state in sr_session_stop()
By cleaning up the driver state all devices will become inaccessible, which
means that is neither possible to query any information from it (like sample
rate) and it is also not possible to restart data acquisition.

sr_session_save() tries to query the sample rate from the device, as a result
calling sr_session_save() after calling sr_session_stop() - which is for example
done by sigrok-cli - will cause a segfault. This patch resolves the issue.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-11 23:28:35 +02:00
Lars-Peter Clausen ed229aaa8f sr: session: Close a device when it is removed from a session
A device is opened when it is added to a session, in the same fashion it should
be closed again when it is removed from a session.

Also remove all still attached devices from a session when the session is
destroyed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-11 23:28:35 +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 b7e941113f sr: session: Moves sources to session struct
The sources really belong to the session, so move them into the session struct.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-10 20:14:06 +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 93b03d091a sr: session: Realloc correct array for pollfds in _sr_session_source_remove
Commit 7149ad7c ("sr: session: Keep a global pollfd array") contained a small
copy paste error. This patch fixes it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-10 20:12:01 +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
Uwe Hermann 1a895c6185 sr: Minor cosmetics. 2012-07-05 01:47:44 +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
Lars-Peter Clausen aac0ea2563 sr: session: Add support for GPollFD or GIOChannel based sources
A raw file descriptor to poll on is not always available, this patch adds
support for adding a source for a GIOChannel or GPollFD.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-05 01:41:00 +02:00
Lars-Peter Clausen 0687dfcde9 sr: session: Keep a global pollfd array
Currently we keep a file descriptor for each source and construct a pollfd array
from these during each loop iteration in sr_session_run(). This patch modifies
the code to keep a global pollfd array which is only modified when a source is
added or removed. On one hand this gets rid of the constant constructing and
subsequent freeing of the pollfd array in sr_session_run(), on the other hand it
will allow us to implement support for non-fd based pollfds.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-05 01:41:00 +02:00
Lars-Peter Clausen 2bccd322bc sr: session: Use realloc to resize source array
Use realloc to resize the source array when adding or removing a source. This
makes the code a bit smaller. In the remove function we now check whether the fd
is valid before doing anything else and if it is not simply do nothing. If it is
valid use memove to move the elements following the source one element down in
the array. Only after that has been done the array is re-allocated.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-05 01:41:00 +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 45edd0b204 sr: add HWCAP type SR_T_KEYVALUE (char **) 2012-07-01 22:33:57 +02:00