Janne Huttunen [Sat, 11 Oct 2014 12:47:34 +0000 (15:47 +0300)]
Add protocol decoder for Cyrustek ES51919 LCR meter chip.
Add a protocol decoder for the Cyrustek ES51919 LCR meter chip.
This chipset (together with ES51920 front-end) is supposedly used
by multiple different portable LCR meters including at least
DER EE DE-5000, Yihua V&A VA520, Mastech MS5308, Uni-T UT612,
CEM DT-9935 and various OEM rebadges of them.
The communication protocol seems to be implemented on the Cyrustek
chip itself so all the different models are expected to use the
same protocol if they implement a host connection. Unfortunately
the protocol is not available in the public documentation of the
chipset, so this implementation is based on reverse engineering it
from traffic captures.
The actual connection between the meter and the host computer may be
different from meter to meter even when based on the same chip. This
module implements a decoder for the protocol and some common helper
functions for interfacing with the meter via an RS-232 serial port.
Janne Huttunen [Sat, 11 Oct 2014 12:47:30 +0000 (15:47 +0300)]
Add two new 'auto' flags.
Add flags for indicating that the meter has selected the measured
quantitiy and/or the used measurement model automatically. These
are similar to the existing auto-range flag.
Janne Huttunen [Sat, 11 Oct 2014 12:47:29 +0000 (15:47 +0300)]
Add quantity and flag for difference measurements.
Add 'SR_MQ_DIFFERENCE' quantity for reporting relative difference
between the current measurement and the reference value. The value
of this quantity will normally be reported in percents. Add also
the flag 'SR_MQFLAG_REFERENCE' for indicating that the reported
value is not the current measurement but the reference value instead.
Janne Huttunen [Sat, 11 Oct 2014 12:47:28 +0000 (15:47 +0300)]
Add measured quantities for LCR meters.
Add parallel and serial model inductance, capacitance and resistance
for LCR meter measurements. Add also secondary quantities many LCR
meters calculate, namely dissipation factor, quality factor and phase
angle.
Janne Huttunen [Sat, 11 Oct 2014 12:47:27 +0000 (15:47 +0300)]
Add two new units.
Add degrees and henrys to the list of supported units. Degree is
an unit of plane angle where one degree is 1/360th of a full circle.
Henry is the SI unit of inductance.
bindings: Better error handling in enumeration get() function.
Prior to this patch a call to get() with an invalid enumeration value
would raise an exception that would, for example, terminate the python
interpreter, whereas now the exception is handled and translated into a
proper python exception.
Bert Vermeulen [Mon, 6 Oct 2014 10:10:25 +0000 (12:10 +0200)]
serial: Add serial_timeout().
This calculates a proper timeout value for blocking writes on the
given serial port, for the given number of bytes. Timeout is based
on a fixed 10ms OS overhead, baud rate, data bits and stop bits.
Martin Ling [Sun, 28 Sep 2014 12:05:33 +0000 (13:05 +0100)]
Add a timeout parameter to blocking serial calls.
Set this new parameter to 0 (no timeout) at every call site. This is
consistent with previous behaviour, so cannot cause any regressions.
Waiting forever for a serial operation is clearly always wrong. Without
specific knowledge of each device and driver however, I can't choose
appropriate timeouts for each call. The maintainers of these drivers
will need to do so, and also add appropriate handling of timeouts.
When this commit is merged, a bug should be entered for each driver
that is touched by it.
Bert Vermeulen [Thu, 2 Oct 2014 09:32:52 +0000 (11:32 +0200)]
Clean up sr_session_load().
This cleans up some warnings generated by clang's static analyzer.
The function now also returns SR_ERR to signify the specified filename
does not point to a valid session file.
Other SR_ERR_* returns indicate a session file was found, but loading
failed.
This signifies to the module instance no more input will come. This
will cause the module to process any data it may have buffered. The
SR_DF_END packet will also typically be sent at this time.
When an input module instance has received enough input to fully
populate the struct sr_dev_inst, sdi_ready is set to TRUE and its
receive() method returns immediately. Any remaining received data
is buffered until the next time the function is called.
fx2lafw: Use physical USB connection instead of sdi->index
Previously, sdi->index was used to tell several identical fx2lafw-compatible
devices apart. This was a bit of a hack, so this patch makes it use physical
device connections instead. They're guaranteed to remain the same even if
the USB device reconnects.
Martin Ling [Sun, 21 Sep 2014 18:24:33 +0000 (19:24 +0100)]
tondaj-sl-814: Mark serial read/write calls as blocking.
These calls are executed from an event handler and were previously nonblocking,
but they have no partial read/write handling. The code is already marked TODO
for improvement.
Martin Ling [Sun, 21 Sep 2014 18:14:05 +0000 (19:14 +0100)]
norma-dmm: Make serial write call block.
This call is executed from an event handler and was previously nonblocking,
but has no partial write handling. It sends a short packet so should be OK
to block, most likely the output buffer will be empty anyway.
Martin Ling [Sun, 21 Sep 2014 18:11:23 +0000 (19:11 +0100)]
norma-dmm: Mark serial read call as nonblocking.
This call was already nonblocking since the driver opens the port with the
SERIAL_NONBLOCK flag. It only reads one byte, and a zero result is handled
appropriately.
Martin Ling [Sun, 21 Sep 2014 18:03:26 +0000 (19:03 +0100)]
motech-lps-30x: Make serial write call block.
This call was previously explicitly nonblocking, but has no partial write
handling. It sends a short packet so should be OK to block, most likely the
output buffer will be empty anyway.
Martin Ling [Sun, 21 Sep 2014 17:59:45 +0000 (18:59 +0100)]
motech-lps-30x: Mark serial read call as nonblocking.
This call was already nonblocking since the driver opens the port with the
SERIAL_NONBLOCK flag. It only reads one byte, and a zero result is handled
appropriately.
Martin Ling [Sun, 21 Sep 2014 17:54:00 +0000 (18:54 +0100)]
mic-985xx: Make serial write call block.
This call is executed from an event handler and was previously nonblocking,
but has no partial write handling. It sends a short packet so should be OK
to block, most likely the output buffer will be empty anyway.
Martin Ling [Sun, 21 Sep 2014 17:44:20 +0000 (18:44 +0100)]
gmc-mh-1x-2x: Make serial write calls block.
These calls are executed from an event handler and were previously nonblocking,
but have no partial write handling. They send short packets so should be OK to
block, most likely the output buffer will be empty anyway.
Fix error handling for some: serial_write can return any negative error code.
Martin Ling [Sun, 21 Sep 2014 17:36:00 +0000 (18:36 +0100)]
gmc-mh-1x-2x: Mark serial read calls as nonblocking.
These calls were already nonblocking since the driver opens the port with the
SERIAL_NONBLOCK flag. They only read one byte. A return value of zero is not
handled, but should not occur in theory due to the G_IO_IN check. It might be
good to add handling of a zero return anyway, since I'm not sure if this is
always accurate.
Martin Ling [Sun, 21 Sep 2014 17:33:34 +0000 (18:33 +0100)]
gmc-mh-1x-2x: Mark serial read call as nonblocking.
This call was already nonblocking since the driver opens the port with the
SERIAL_NONBLOCK flag. It only reads one byte, and a zero result is handled
appropriately.
Martin Ling [Sun, 21 Sep 2014 17:26:16 +0000 (18:26 +0100)]
fluke-dmm: Make serial write calls block, and fix error handling.
These calls are executed from an event handler and were previously nonblocking,
but have no partial write handling. They send short packets so should be OK to
block, most likely the output buffer will be empty anyway.
Also fix error handling for these calls, which seems to have been retained from
previous direct usage of write() to a serial port fd.
Martin Ling [Sun, 21 Sep 2014 17:16:04 +0000 (18:16 +0100)]
fluke-dmm: Make serial write calls block, and fix error handling.
These calls were previously nonblocking, but have no partial write handling.
They are made from scan and acquisition_start contexts where they are free
to block.
Remove the SERIAL_NONBLOCK at open, which only applied during scan, since all
calls in the scan are now explicitly blocking.
Also fix error handling for these calls, which appears to have been kept
from a previous direct usage of write() on a serial port fd.
Martin Ling [Sun, 21 Sep 2014 17:12:48 +0000 (18:12 +0100)]
fluke-dmm: Mark serial read call as nonblocking.
This call was already nonblocking since the driver opens the port with the
SERIAL_NONBLOCK flag. Only one byte is read. The case of 0 being returned
is not handled, but the call is only made if G_IO_IN occurred so in theory,
there should be a byte available. It might be wise to add handling for a
return of 0 nonetheless, as I'm not sure if this is always accurate.
Martin Ling [Sun, 21 Sep 2014 16:54:18 +0000 (17:54 +0100)]
colead-slm: Mark serial read calls as nonblocking.
This is an odd one. These calls are made from a receive handler so should not
block, and appear to be setup correctly to handle partial reads or no data
available. However, the driver was not opening the port with SERIAL_NONBLOCK
so these calls would have been blocking. Make them nonblocking.
Martin Ling [Sun, 21 Sep 2014 16:51:25 +0000 (17:51 +0100)]
center-3xx: Make serial write call block.
This call is executed from an event handler and was previously nonblocking,
but has no partial write handling. It sends a short packet so should be OK
to block, most likely the output buffer will be empty anyway.