This patch adds a function for a common operation of all serial based drivers.
It extracts the serial options from the options linked list that is passed down
to every hardware driver.
This patch adds a function to read and parse a SCPI response which contains a
comma separated list of unsignet 8-bit integer numbers (e.g "1,0,64").
This is particularly useful if the instrument sends digital measurement data
in this format.
This patch adds a function to read and parse a SCPI response which contains a
comma-separated list of floating-point numbers (e.g. "1.0e-5,2.0e-4,3.0e-3").
This is particularly useful if the instrument sends analog measurement
data in this format.
The SCPI standard specifies the "*OPC?" command (Operation complete query) which
queries the instrument for its operative state. When all pending operations are
complete, the instrument responds with a "1".
Some manufacturers block before completing all operations and don't respond
with anything and some of them respond with a "0". This function handles both
cases uniformly.
This patch adds helper functions to read an SCPI response and parse the response
as an integer, boolean, floating-point or double-precision floating-point number.
The Standard Commands for Programmable Instruments (SCPI) defines a standard
for syntax and commands to use in controlling programmable test and measurement
devices.
SCPI documentation:
http://www.ivifoundation.org/docs/scpi-99.pdf
This patch adds helper functions for sending SCPI commands, reading a SCPI
response and reading and parsing a SCPI "*IDN?" response.
A new sp_port is created every time we call serial_open (sp_get_port_by_name
implicitly creates one for us), so free it every time we call serial_close.
Disable drivers that need serial port support if libserialport is not found.
Also, disable building various other serial port related code in that case.
Most Metex DMMs use e.g. " mV" as unit field, others use "mV ",
though. Support these (and other) whitespace variants by stripping all
spaces and only comparing non-space characters.
g_usleep(XX) sleeps for *at least* XX microseconds but may sleep for
longers (on older kernels the sleep will typically be 10000us). Thus
byte receive loops containing an unconditional sleep will perform
very poorly (for example it causes the scan in agilent-dmm to timeout
prematurely).
Even on modern kernels serial_readline() has a 2ms sleep per byte which
means it will read at a maximum rate of half a character per millisecond
(~4800baud).
This is fixed by only sleeping when read() returns no data.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>