Commit Graph

93 Commits

Author SHA1 Message Date
Bert Vermeulen 681803dfde Don't try to close devices when removing them from the session
That's the frontend's job.
2013-04-28 22:35:42 +02:00
Bert Vermeulen efdecf4c05 Add sr_dev_open()/sr_dev_close()
Frontends will be required to open a device before using
sr_config_set() or starting acquisition.
2013-04-24 22:02:34 +02:00
Uwe Hermann 50985c2019 GPL headers: Use correct project name. 2013-04-23 22:24:30 +02:00
Uwe Hermann 85222791a9 Doxygen: Add missing parameter docs. 2013-04-16 12:48:58 +02:00
Martin Ling 2726474a61 Add a void *cb_data parameter to datafeed callbacks. 2013-04-16 11:13:18 +02:00
Alexandru Gagniuc 33c6e4c5a4 session: Make sr_session_stop thread-safe
With the sigrok session running in a worker thread, if sr_session_stop is called
from another thread, it shuts down the pollfds used by the hardware drivers,
without ensuring that the sigrok event loop is no longer using those pollfds.

On the demo driver, this involves shutting down the GIOChannels, causing a
segfault when the sigrok event loop tries to use them. This is evident when
using the Stop button in PulseView, while the session is running.

This isn't a problem with just the demo driver; any driver's resources may be
freed by sr_session_stop concurrently with the sigrok session running.

To solve this problem, we don't touch the session itself in sr_session_stop().
Instead, we mark it for decommissioning and return. The session polls this flag,
and shuts itself down when requested.

This fixes bug 4.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2013-04-14 23:39:15 +02:00
Uwe Hermann a819da9c25 Drop deprecated sr_session_halt().
This has been deprecated in favor of sr_session_stop() since a while.

None of the current frontends use sr_session_halt() anymore, neither
does libsigrok.
2013-03-03 18:02:24 +01:00
Uwe Hermann c7142604a2 session.c: Drop left-over 'session: ' prefix.
This is added automatically now.
2013-02-07 11:26:02 +01:00
Uwe Hermann 961009b0c4 hw_dev_close(): Move common checks to wrapper.
Check the relevant arguments for != NULL before calling the actual
driver-specific function, so that the driver can safely assume those
arguments are non-NULL. This removes the need to duplicate these
checks in every driver.
2013-02-05 18:46:33 +01:00
Uwe Hermann a421dc1d7b session: Use message logging helpers. 2013-01-29 12:56:02 +01:00
Bert Vermeulen c71bac3b98 Adjust session debugging to the new SR_DF_META packets. 2013-01-21 23:32:49 +01:00
Uwe Hermann b7c3e8499c session: Fix compiler warning.
session.c:258:6: warning: 'ret' may be used uninitialized in this
function [-Wmaybe-uninitialized]
2012-12-31 21:05:11 +01:00
Alexandru Gagniuc f1f7e62d6d session.c: Remove all remaining sources on sr_session_stop
Some sources may not be necessarily associated with a device. The best example
is the anykey pollfd from sigrok-cli. sr_session_stop only removes sources
associated with hardware devices via dev_acquisition_stop. Sources such as
anykey are not removed, and thus session->num_sources will not get to 0. As a
result, we may get into situations where the event loop enters an infinite
state.

To prevent this, all we have to do is remove any active sources that are still
present after dev_acquisition_stop has been called for all devices.

This fixes bug 14.
2012-12-24 20:24:13 +01:00
Joel Holdsworth bf53457d1d Pass sr_datafeed_packets and payloads with const pointers
This patch marks packet structures and their payloads as const.
This indicates to packet receivers that modifications to these are
not allowed. In general all pointers should be marked const unless
modification of the referenced data is explicitly allowed.
2012-12-20 07:51:21 +00:00
Uwe Hermann 393fb9cb18 Doxygen: Add @file items for the relevant files.
These short descriptions are shown in the "Files" section of the
Doxygen output.
2012-10-22 11:56:18 +02:00
Uwe Hermann 6b2d8d3e5c Doxygen: TODO cleanup, use @todo where needed.
Turn TODOs which should be user-visible into @todo so that Doxygen
shows them in the function docs, and also on the special "Todo List" page.

Those TODOs that should not be in the Doxygen docs are moved out of the
/** */ comment blocks.

Also fix some comments/items, and remove some obsolete ones.
2012-10-22 11:56:18 +02:00
Uwe Hermann 9c5332d291 Doxygen: Fix a bunch of warnings and outdated docs. 2012-10-22 11:56:18 +02:00
Uwe Hermann 7b870c38e3 Doxygen: Initial groups and topic short descriptions. 2012-10-22 11:56:18 +02:00
Uwe Hermann b4bd70889f Doxygen: Mark non-public stuff for exclusion.
- /** @private */ can be used for functions, and /** @cond PRIVATE */ and
   /** @endcond */ for variables or #defines.

 - Document the above in HACKING.
2012-10-22 11:56:17 +02:00
Alexandru Gagniuc dfd8f56ef4 libsigrok: (Trivial) fix packet type in datafeed_dump
datafeed_dump would print SR_DF_META_LOGIC when a SR_DF_META_ANALOG
was recieved. Fix that.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2012-10-20 23:03:51 +02:00
Bert Vermeulen 2cbeb2b7fb sr: drivers should remove their sources from the session when done 2012-08-03 11:29:01 +02:00
Bert Vermeulen e8d3d6c843 sr: properly initialize and check on device instance driver field 2012-08-03 11:29:00 +02:00
Bert Vermeulen 2ac2e629fc sr: cosmetic changes 2012-08-03 11:28:59 +02:00
Bert Vermeulen de4d3f99d9 sr: change session API/code to use sdi 2012-08-03 11:28:59 +02:00
Bert Vermeulen b04781bb2b sr: extra checks for properly handling driverless devices 2012-07-29 02:16:17 +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
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 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
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
Uwe Hermann c13536fa9c sr: backend/zeroplus: Improve debug output. 2012-06-19 23:33:50 +02:00
Bert Vermeulen 6ea7669c9d support for frame begin/end packets 2012-05-30 23:56:12 +02:00
Bert Vermeulen ee7489d234 sr: SR_DF_ANALOG type, and meta types for analog+logic 2012-05-30 23:55:36 +02:00
Uwe Hermann 01c3e9dbd5 sr: s/_clear/_remove_all/ for consistency. 2012-03-31 11:33:43 +02:00
Uwe Hermann 8ec95d2282 sr/srd: Small fixes, constifications, doc updates. 2012-03-21 23:20:09 +01:00
Uwe Hermann d6eb0c333c sr: Fix handling of virtual devices.
I.e., handling of sessions which use input from files (not from actual
logic analyzer hardware).
2012-03-18 12:57:34 +01:00
Uwe Hermann 0abee5076f sr: Fix some TODOs, improve comments/docs. 2012-03-04 15:10:12 +01:00
Uwe Hermann 1f9813eb6c sr: Name all callback data 'cb_data'. 2012-03-02 02:25:42 +01:00
Uwe Hermann 31ccebc492 sr: s/sr_session_bus/sr_session_send/. 2012-03-01 23:49:25 +01:00
Uwe Hermann d08490aaba sr/srd: Consistency fixes for callbacks.
- Callback function pointer typedefs end with _t.

 - Variables holding callback functions are named 'cb' everywhere.
2012-03-01 23:49:25 +01:00
Uwe Hermann c09f0b578c sr/cli/gtk/qt/: s/plugin/driver/. 2012-02-28 23:52:30 +01:00
Uwe Hermann 69040b7c8f sr: s/acquisition_*/dev_acquisition_*/.
These functions are per-device-instance, so use dev_ as prefix as with
the other ones.
2012-02-18 12:03:49 +01:00
Uwe Hermann e7eb703fff sr: opendev/closedev -> dev_open/dev_close. 2012-02-18 11:57:43 +01:00
Uwe Hermann 8105505d06 sr: s/st*_acquisition/acquisition_st*/. 2012-02-18 11:46:51 +01:00