Commit Graph

3487 Commits

Author SHA1 Message Date
Soeren Apel 42f4619d6b Fix #550 by allowing an empty trigger match list
1e7659609b is related
to this change and required to fix #550 as well.
2015-09-08 19:09:54 +02:00
Bert Vermeulen 1e7659609b Don't free trigger when destroying the session.
The trigger must be freed by the client.
2015-09-08 15:44:47 +02:00
Daniel Elstner 4512ccd36c Build: Show compiler versions in summary 2015-09-08 04:57:59 +02:00
Daniel Elstner a6e8a8f766 sigrok.m4: Add SR_PROG_VERSION macro 2015-09-08 04:57:59 +02:00
Daniel Elstner c178386178 sigrok.m4: Suppress make variable for ORDER 2015-09-08 04:10:44 +02:00
Daniel Elstner 39cf2004dc Build: Fix restore of LIBS after temporary change 2015-09-08 04:02:04 +02:00
Daniel Elstner 1b8d3a6d09 session: Compile USB-specific code only if available 2015-09-08 00:08:16 +02:00
Daniel Elstner c1adbb1e23 Build: Add configure check for libusb event-abstraction
This is intended to make people notice when libusb is too old
for the new Windows code. However, this is not foolproof, since
the libusb version may be different at runtime.
2015-09-08 00:08:16 +02:00
Daniel Elstner 534b634ce2 USB: Handle live changes to the set of FDs to poll
Introduce new internal session API for changing the set of polled
file descriptors for an already installed event source. Use the
new API to apply changes to the USB poll FDs when requested to do
so by libusb. Doing so is necessary to make the generic USB code
work on Windows.
2015-09-08 00:08:16 +02:00
Daniel Elstner 1b0c6b6d15 USB: On Windows, assume G_IO_IN for the event mask 2015-09-08 00:08:16 +02:00
Daniel Elstner 3a1a6d6b04 session: More main loop debug output 2015-09-08 00:08:16 +02:00
Daniel Elstner 4b9e253213 USB: Remove Windows-specific event handling code
For the generic code to work on Windows, a version of libusb
with the experimental event-abstraction changes is required.
2015-09-08 00:04:22 +02:00
Daniel Elstner 2defc4116b sigrok.m4: Update serial 2015-09-07 23:57:03 +02:00
Daniel Elstner 3841c4c58d Build: Use SR_PROG_MAKE_NO_PRINT_DIRECTORY 2015-09-07 23:54:00 +02:00
Daniel Elstner 82b01e42f8 sigrok.m4: Add SR_PROG_MAKE_NO_PRINT_DIRECTORY macro 2015-09-07 23:54:00 +02:00
Daniel Elstner 6aa7fcf16a Build: Show compiler and flags in configure summary 2015-09-07 23:20:17 +02:00
Daniel Elstner 5b9e9bba74 Build: Use SR_PROG_MAKE_ORDER_ONLY
As of now, the resulting substitution @ORDER@ is unused.
2015-09-07 23:20:17 +02:00
Daniel Elstner c2b0f42989 sigrok.m4: Add SR_PROG_MAKE_ORDER_ONLY macro 2015-09-07 23:20:17 +02:00
Daniel Elstner 8c2024e021 Build: Implement libieee1284 check via SR_ARG_OPT_CHECK 2015-09-07 23:20:17 +02:00
Daniel Elstner 38662688e8 sigrok.m4: Add generic macro for optional dependencies
Provide SR_ARG_OPT_CHECK, a generalized variant of SRG_ARG_OPT_PKG
that can be used with custom check commands. Implement the latter
in terms of SR_ARG_OPT_CHECK.
2015-09-07 23:20:17 +02:00
Martin Lederhilger aff94d065e scpi: Fix incorrect serial_read_nonblocking call().
There was a problem in scpi_serial.c in the scpi_serial_read_data()
function. Incoming data was written at the read position in the buffer,
although it should be written at the count position in the buffer.
2015-09-07 22:49:58 +02:00
Daniel Elstner dd7a4a71ca drivers: Match dummy FD passed to source add/remove 2015-09-07 14:33:30 +02:00
Daniel Elstner 5a7d8dac90 USB: Handle the case of a callback removing its event source 2015-09-05 04:21:26 +02:00
Daniel Elstner 358c4ed5b8 USB: On Windows, block to wait for libusb events
This is another attempt at getting the mess that is libusb event
handling on Windows under control. Until libusb makes its HANDLEs
available for polling, we have no choice but to block while waiting
for libusb events. Since we do not want to force drivers to deal
with multi-threading issues, that means we have to block in the
session main loop.

Fortunately, it turns out that our drivers aren't using multiple
event sources, so it is actually possible to block the main loop
without disrupting too much. This also gets rid of the USB thread
on Windows. Thankfully, libusb does not seem to care that we are
now calling libusb_handle_events_timeout_completed() twice per
iteration: first a blocking call (with timeout) in the callback
wrapper, followed by the non-blocking call in the driver-supplied
callback.
2015-09-04 19:04:23 +02:00
Daniel Elstner 92248e7821 session: Allow multiple poll FDs per event source
Turns out that having one event source per libusb poll FD is
a bad idea. There is only a single callback for all poll FDs,
and libusb expects to be called only once per poll iteration,
no matter how many FDs triggered.

Also, they should all share the same timeout, which should get
reset on events from any polled FD. The new timeout handling made
this problem apparent, as it caused the callback to be invoked
multiple times on timeouts, once for each separate event source.

In order to fix this, change the implementation to allow for an
arbitrary number of poll FDs per event source. This number is
zero for timer FDs, one for normal I/O sources, and one or more
for libusb sources (Unix only).

Also, on Windows, do not get an additional timeout from libusb
in the event loop. This is only appropriate when polling the
libusb FDs directly, which we aren't doing on Windows.
2015-09-03 19:37:09 +02:00
Daniel Elstner 7637fa35b5 session: More poll spewing 2015-09-03 19:37:09 +02:00
Daniel Elstner 15408b51f3 log: Output time stamps at log level spew 2015-09-03 19:37:09 +02:00
Daniel Elstner c650d3ecbf drivers: Use timer sources instead of polling stdin 2015-09-03 19:37:09 +02:00
Daniel Elstner 027bf07796 demo: Use simple timer source instead of pipe
Get rid of the Unix pipe and the GIOChannel wrapping it. Instead,
install a simple timer event source with the appropriate timeout.
2015-09-03 19:37:09 +02:00
Daniel Elstner b5887bd0c3 session: Add poll debug spew 2015-09-03 19:37:09 +02:00
Daniel Elstner faa5d7d997 session: Unify handling of I/O and timer sources
Handle I/O sources and timer ("dummy") sources within the same
polling loop, so that both may be used together. Slightly change
the API to improve consistency: a timeout value of -1 now disables
the timeout, and 0 makes the source always time out immediately.
The "dummy" sources already behaved that way, although it wasn't
documented as such.

Make sure that I/O events are processed preferentially: Skip any
timeout callbacks if an I/O event occurred within the same poll
iteration. This applies to both timer/idle sources and timeouts
of I/O sources.

Do not create dummy GPollFDs for timer/idle sources. Instead,
split the sources array into an I/O section and a timer section,
and create corresponding GPollFDs only for the I/O section. Use
GArray to simplify the handling of the dynamic arrays.
2015-09-03 19:37:09 +02:00
Daniel Elstner 62d7945f80 session: Properly accumulate event source timeouts
Keep track of when source timeouts are due and properly compare
against accumulated elapsed time between invocations. This prevents
sources with short timeouts from blocking other sources with longer
timeouts indefinitely.
2015-09-03 19:37:09 +02:00
Daniel Elstner 4399cc0f41 session: Do not expect meaningful errno on non-UNIX
Looking at the g_poll() implementations for various systems, it
appears that on Windows the return value is 0 if the wait was
interrupted, and errno is never set. Also, the MacOS X wrapper
around select() does not clear revents on timeout.

To deal with these issues, check for EINTR only on Unices, and
assume revents to be invalid unless g_poll() returned a positive
value.
2015-09-03 19:37:09 +02:00
Daniel Elstner 32af282c5e session: Check for errors from g_poll()
If the call to g_poll() in sr_session_iteration() fails, report
the error back to the caller. Do not treat EINTR as error though.

Check for session abort only if a source callback was actually
invoked, or at least once if none of the callbacks are invoked.
Stop checking for abort if the session has already been stopped,
just in case a callback sets abort_session again.

Also change the documentation to match the actual behavior.
2015-09-03 19:37:09 +02:00
Daniel Elstner 89efe06460 session: Fix USB timeout handling
In sr_session_iteration(), remove the inverted evaluation of the
block parameter if a USB source is present. This stops the deluge
of USB event callbacks due to the timeout always being zero.

Also, just for cleanliness, initialize the revents member of each
GPollFD instance to zero.
2015-09-03 19:37:09 +02:00
Daniel Elstner 452986bec4 Build: Fix installation of Python bindings
Apparently setup.py install behaves differently when given
the --root option, so omit that if DESTDIR is empty.

Fixes #644.
2015-09-02 14:07:06 +02:00
Uwe Hermann a2e4d88205 python: Fix the build for Python >= 3.
SWIG_init() returns void for Python 2.x and 'PyObject *' for Python 3.

Use an #if to handle both cases properly, otherwise the Python bindings
for either Python 2 or 3 will fail to build.

Python 3.x failure:

sigrok/core/classes_wrap.cpp: In function ‘PyObject* PyInit__classes()’:
sigrok/core/classes_wrap.cpp:59002:5: error: return-statement with no
value, in function returning ‘PyObject* {aka _object*}’ [-fpermissive]
     return;
     ^

Python 2.x failure:

In file included from /usr/include/dirent.h:244:0,
                 from /usr/include/glib-2.0/glib/gdir.h:32,
                 from /usr/include/glib-2.0/glib.h:45,
                 from /usr/include/pygobject-3.0/pygobject.h:7,
                 from sigrok/core/classes_wrap.cpp:3179:
sigrok/core/classes_wrap.cpp: In function ‘void init_classes()’:
sigrok/core/classes_wrap.cpp:59002:12: error: return-statement with a
value, in function returning 'void' [-fpermissive]
     return NULL;
            ^
2015-08-31 21:08:08 +02:00
Bert Vermeulen b05409d792 Remove SR_OK_CONTINUE.
This brings error reporting back to the usual: either return codes
are SR_OK (0) or they are < 1 indicating an error.

This fixes bug #633.
2015-08-31 16:23:10 +02:00
Bert Vermeulen b93006789f output/csv: Avoid using SR_OK_CONTINUE. 2015-08-30 21:13:51 +02:00
Bert Vermeulen 2d05415f2e scpi: Avoid using SR_OK_CONTINUE. 2015-08-30 20:42:54 +02:00
Bert Vermeulen 2634b77812 serial: Check event ptr before using.
This avoids a NULL dereference when called twice.
2015-08-30 20:42:54 +02:00
Bert Vermeulen 661cc2ec46 Convert SR_CONF_MEASURED_QUANTITY to SR_T_MQ. 2015-08-30 20:40:56 +02:00
Bert Vermeulen 83478149b1 deree-de5000: Drop SR_CONF_MEASURED_QUANTITY functionality.
This was superfluous -- there is no need to be able to query the
last MQ(s) sent by the device, since they're already being sent
along with the measurements in analog packets.

Since there is also no way to change the MQ (that is done with the
buttons on the device), there is no need to even list the possible
MQs.
2015-08-30 20:40:56 +02:00
Bert Vermeulen 75772c721d Change SR_T_MQLIST to SR_T_MQ.
The need to make this a list no longer applies.

SR_T_MQ is thus a type consisting of a tuple with two elements: the first
item is the MQ (type G_VARIANT_TYPE_UINT32), and the second is the MQ
flags value (G_VARIANT_TYPE_UINT64).
2015-08-30 20:40:56 +02:00
Daniel Glöckner 28d86fa9a5 Check for libieee1284
Will be needed by the Hung-Chang DSO-2100 driver.
2015-08-30 19:03:51 +02:00
Daniel Glöckner 4ec436c4d5 sr_session_send: pass transformed packet to datafeed callbacks
After the packet has been passed through the transformation modules,
the transformed data is in packet_in but the following code uses
the packet variable which still points to the original input.

This fixes bug #631.
2015-08-30 18:54:13 +02:00
Daniel Glöckner 1e6b5b9303 hantek-dso: fix memory leak
This fixes bug #632.
2015-08-30 18:53:21 +02:00
Daniel Glöckner 96127d0fea lascar-el-usb: fix memory leak
This fixes bug #630.
2015-08-30 18:51:18 +02:00
Daniel Glöckner 80e20c10e3 es51919: fix memory leak
This fixes bug #629.
2015-08-30 18:48:50 +02:00
Uwe Hermann d40b8557a9 Don't set _POSIX_C_SOURCE for VXI/RPC related files.
Make vxi.h the first #include in all affected files and #undef the
_POSIX_C_SOURCE macro in vxi.h.

This avoids various build issues on e.g. FreeBSD or Mac OS X where
setting _POSIX_C_SOURCE leads to the unavailability of certain types
such as u_long (as used in the VXI/RPC code).
2015-08-29 17:15:26 +02:00