Commit Graph

73 Commits

Author SHA1 Message Date
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
Uwe Hermann bb7ef79377 sr/cli/gtk/qt: s/device/dev/ in many places.
Also, a few s/instance/inst/ occurences.
2012-02-17 23:47:00 +01:00
Uwe Hermann 44dae53925 sr: Random cosmetics, fix/amend Doxygen comments. 2012-02-17 22:40:51 +01:00
Uwe Hermann 7b48d6e104 sr: Prefix log messages with subsystem string. 2012-02-17 22:40:51 +01:00
Bert Vermeulen c73d2ea421 sr: adjust copyright year 2012-02-13 14:31:51 +01:00
Bert Vermeulen a1645fcd81 sr: more API cleanup and documentation 2012-02-13 03:36:32 +01:00
Bert Vermeulen 996b0c7234 sr: clean up public/private split in headers 2012-02-13 02:13:51 +01:00
Bert Vermeulen 18beaeff94 sr: cleaned up session bus debug helper 2012-02-13 00:08:23 +01:00
Uwe Hermann 133a37bfba Use g_try_malloc/g_free/g_strdup consistently.
Avoid plain malloc()/free() in sr/srd, especially in the API calls.
Also avoid g_malloc*() in favor of g_try_malloc*().

Use g_strdup() instead of strdup() so that we can use g_free()
consistently everywhere.

Exceptions: Stuff that is allocated via other libs (not using glib),
should also be properly free'd using the respective free-ing function
(instead of g_free()). Examples: Stuff allocated by libusb, libftdi, etc.

Also, use sr_err() instead of sr_warn() for actual errors. sr_warn() is
meant for non-fatal/uncritical warnings.
2012-02-11 22:34:16 +01:00
Uwe Hermann 3d2efd7d15 sr: Compile fix for Windows/MinGW. 2012-02-05 13:36:03 +01:00
Uwe Hermann 1a081ca67d sr: Mark API functions with SR_API/SR_PRIV.
Use SR_API to mark public API symbols, and SR_PRIV for private symbols.

Variables and functions marked 'static' are private already and don't
need SR_PRIV. However, functions which are not static (because they need
to be used in other libsigrok-internal files) but are also not meant to
be part of the public libsigrok API, must use SR_PRIV.

This uses the 'visibility' feature of gcc (requires gcc >= 4.0).

Details: http://gcc.gnu.org/wiki/Visibility
2012-02-02 00:03:17 +01:00
Bert Vermeulen 0146970797 sr: remove unused time/duration fields from datafeed packets 2012-02-01 02:59:41 +01:00
Bert Vermeulen 8c76be539e clean up drivers at the end of a session, and fix session file init. 2012-01-08 22:05:00 +01:00
Uwe Hermann e0508e6799 sr: session: Make most functions return int.
This allows us to return error codes etc.

Add a little more error handling.
2012-01-07 17:11:50 +01:00
Renato Caldas 446a037205 session: Fixed error reporting. 2012-01-06 15:05:28 +01:00
Uwe Hermann 3b7c8f54fc sr: Drop some obsolete and commented out code. 2012-01-02 14:25:52 +01:00
Uwe Hermann 9f45fb3aea sr: session: Add docs and some error checks. 2012-01-02 14:23:33 +01:00
Uwe Hermann b7f09cf86d libsigrok: Fix #includes.
In the lib, we should only #include "sigrok.h" or "sigrok-internal.h",
but not the (possibly installed and thus different/older versions) via
<sigrok.h> or <sigrok-internal.h>.

Frontends should of course use <sigrok.h> and <sigrok-internal.h>.
2011-12-28 23:07:08 +01:00
Uwe Hermann a0ecd83bc6 Make more variables/functions static and non-global.
The 'GSList *devices' from device.c was actually really global (i.e.,
listed in sigrok.h), which is now fixed.
2011-12-28 22:55:21 +01:00
Gareth McMullin 5c582d9f61 Remove IO source if callback returns FALSE. 2011-11-06 11:44:25 +13:00
Bert Vermeulen 7d2afd6c95 better session bus logging 2011-06-20 11:42:43 +02:00