Commit Graph

110 Commits

Author SHA1 Message Date
Uwe Hermann 4711724141 Add/update Doxygen @since tags. 2014-05-04 20:53:53 +02:00
Uwe Hermann 144f6660d0 Don't define names ending with _t (POSIX reserved).
Avoid defining any names ending in _t, those are generally reserved
for POSIX usage. For details see:

http://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html
http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html
2014-05-04 16:16:17 +02:00
Uwe Hermann 7ea458625c session: Show unitsize of the received data. 2014-04-25 19:34:41 +02:00
Uwe Hermann 2ad1deb89d Don't include LOG_PREFIX in the Doxygen output.
(files in hardware/, input/, and output/ don't need this since none of
those directories contain API stuff and are thus not included in the
list of input files for Doxygen at all).
2014-04-25 18:44:40 +02:00
Daniel Elstner 32b7cd4f02 session: Auto-commit settings before acquisition.
(sr_session_start): Just before starting acquisition on
a device, call sr_config_commit() to apply pending config
changes to the hardware device.
(sr_session_dev_add): Ditto.  Also, return an error code
if starting acquisition failed.
2014-01-21 13:09:51 +01:00
Martin Ling 3544f848e0 Centralise duplicated logging helper defines. 2013-12-27 12:54:05 +01:00
Bert Vermeulen 98582bf53f Make API docs more consistent, avoid tabs to line up comments. 2013-12-09 22:49:12 +01:00
Matthias Heidbrink 04cb915716 Improved doxygen docs. 2013-12-09 15:17:17 +01:00
Bert Vermeulen 568dcacc1a Better error reporting on session start failure 2013-10-16 10:40:53 +02:00
Bert Vermeulen 72a08bccff Minor documentation fixes 2013-09-25 11:51:54 +02:00
Bert Vermeulen 5451816fd1 When adding a device instance to a running session, start acquisition on it 2013-09-21 17:44:49 +02:00
Bert Vermeulen 2bb311b482 New API function sr_session_dev_list()
This exposes the list of devices added to the session. In the case of
loading a session from file, these struct sr_dev_inst are otherwise
not exposed to the frontend. See bug 145.
2013-09-02 14:24:32 +02:00
Uwe Hermann 1861be0baf Make sr_session_iteration() static.
This function is not used outside of session.c at the moment, so make
it static for now.
2013-08-07 16:21:57 +02:00
Bert Vermeulen f6eb2cb555 Make sr_session_iteration() private 2013-07-18 15:06:37 +02:00
Bert Vermeulen b483be7456 Add sr_session_iteration() API function 2013-07-16 16:08:38 +02:00
Uwe Hermann 29a27196a1 s/DRIVER_LOG_DOMAIN/LOG_PREFIX/.
This is more correct anyway, and also a bit shorter and more readable.
2013-05-03 21:59:32 +02:00
Bert Vermeulen 0372864451 Don't remove stray source from the session after stopping
It's up to the drivers and frontends to remove the sources they
added to the session.

Also don't tell the driver about a forced session stop more than
once, because it's sloppy.

Fixes bug 62.
2013-04-30 00:09:20 +02:00
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