Commit Graph

3461 Commits

Author SHA1 Message Date
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
Daniel Elstner c05a0ba528 Build: Pass compiler flags from make to setup.py
Extend setup.py to allow environment variables to be set on the
command line. Use that functionality to replace the pkg-config
invocations with flags passed on from make. Suppress the annoying
-Wstrict-prototypes warning by overriding the OPT variable.

Also move the "cd bindings/python" from Makefile.am to setup.py
to side-step problems with "cd" in make rules.

This also fixes bug #628.
2015-08-29 17:08:34 +02:00
Daniel Elstner 5b869e978a Build: Go back to _POSIX_C_SOURCE=200112L 2015-08-28 18:35:16 +02:00
Daniel Elstner bbb3996c06 configure: Enable largefile support on 32-bit systems 2015-08-28 18:35:16 +02:00
Uwe Hermann 8006cdc53d configure.ac: Add libserialport dependency to kern-scale. 2015-08-28 16:32:14 +02:00
Uwe Hermann ca7dbb5616 Various key lists: Add reminders of what needs updates upon changes. 2015-08-28 16:32:14 +02:00
Uwe Hermann 55c9f09dbc session.c: Fix key order. 2015-08-28 16:29:07 +02:00
Uwe Hermann f7bcc68604 analog.c: Fix key order, add missing items. 2015-08-28 16:29:07 +02:00
Uwe Hermann c984f2f997 output/analog: Fix key order, add missing items. 2015-08-28 16:29:07 +02:00
Uwe Hermann 29ae6f0880 hwdriver.c: Fix key order, add missing items. 2015-08-28 16:29:07 +02:00
Uwe Hermann 607dcdeae1 kern-scale: Add initial driver contents.
This currently supports (and is tested on) the KERN EW 6200-2NM,
other models will be added later.
2015-08-28 11:59:31 +02:00
Uwe Hermann 9380ec2f05 kern-scale: Initial driver skeleton. 2015-08-28 11:43:04 +02:00
Uwe Hermann e5d953b559 Add a protocol parser for KERN scales.
(KERN & SOHN GmbH, http://www.kern-sohn.com/)
2015-08-28 11:43:04 +02:00
Uwe Hermann 34eaf4bcbb output/analog: Support mass related units / MQ flags. 2015-08-28 11:43:04 +02:00
Uwe Hermann 28af4c714e Add a few scale related flags.
- SR_MQ_MASS: Mass, as measured by scales / balances.

 - SR_UNIT_*: Various units of mass.

 - SR_MQFLAG_UNSTABLE: A flag denoting that a value has not
   yet stabilized (settled). E.g. when placing an object on a scale
   it'll take a few moments until a stable reading is available.
   Measurement values marked with SR_MQFLAG_UNSTABLE denote that they
   are "unsettled", unstable values (not yet stabilized).
   The absence of SR_MQFLAG_UNSTABLE denotes that the value is stable.

 - SR_CONF_SCALE: A device class for weighing scales / balances.
2015-08-28 11:43:04 +02:00
Daniel Elstner 68799618f6 Build: Define feature test macro _DEFAULT_SOURCE
This basically makes glibc expose the same set of features as
if gcc was invoked without any restricting -std=c* option. Unlike
_GNU_SOURCE however, it does not enable GNU-specific extensions.

So, with this macro defined the behavior of Linux with glibc
should match that of other platforms.
2015-08-26 13:55:53 +02:00
Daniel Elstner 65489c1ada Build: Use TESTS prefix instead of CHECK for flag variables
In order to avoid confusion of the flags-gathering pkg-config
result with the actual test for the availability of "check",
change the pkg-config output variable prefix from CHECK to TESTS.
2015-08-26 13:13:39 +02:00
Bert Vermeulen a1f7c854c5 Add SR_T_MQLIST.
This type consists of an array, with each item a two-member tuple,
representing an MQ/MQflags pair: the first item is the MQ (type
G_VARIANT_TYPE_UINT32), and the second is the MQ flags value
(G_VARIANT_TYPE_UINT64).

A GVariant of type SR_T_MQLIST can thus always represent more than
one MQ/MQflag pair.
2015-08-26 01:54:34 +02:00
Bert Vermeulen 0176c92fea Add key info tables for MQ and MQflags. 2015-08-26 01:54:34 +02:00
Bert Vermeulen 2fb60e2329 Replace sr_config_info with sr_key_info.
The tables defined with this struct can now be used for information
on items other than config keys.

Functions to access these tables have been renamed sr_key_info_[name_]get.
These take an extra argument, keytype, which should be set to SR_KEY_CONFIG
to get the config key tables. Other key types will be added.
2015-08-26 01:08:42 +02:00
Bert Vermeulen 0b2b92f6c3 scpi/usbtmc: Use sr_usb_close(). 2015-08-25 19:13:17 +02:00
Bert Vermeulen 67e95ed37d Add sr_usb_close(). 2015-08-25 19:13:17 +02:00
Bert Vermeulen 558d438d1f scpi: Strip leading/trailing spaces from *IDN? response. 2015-08-25 19:13:17 +02:00
Bert Vermeulen c0d257790a scpi: Propagate error codes in API functions.
This allows client drivers to detect e.g. timeout conditions.
2015-08-25 19:13:17 +02:00
Bert Vermeulen 9c24d16a1d Make sr_next_enabled_channel() from scpi-pps available library-wide. 2015-08-25 19:13:17 +02:00
Bert Vermeulen 91ef511db2 scpi: Make helper functions from scpi-pps available library-wide. 2015-08-25 19:13:17 +02:00
Bert Vermeulen 5a1afc0907 scpi: Move SCPI-related definitions to separate header file. 2015-08-25 19:13:16 +02:00