This will replace dev_info_get(), and will be used to fetch both
driver and device instance-specific information. The sr_dev_inst
argument is NULL in case of a driver info fetch. In line with the
libsigrok wrapper, this function returns an error code, using the
supplied void ** to return the requested data.
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.
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.
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.
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.
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.
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.
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>
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>
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>
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>
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>
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>
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>