Commit Graph

133 Commits

Author SHA1 Message Date
Martin Ling 23f43dff15 Make SCPI functions device independent, with separate serial backend. 2013-12-03 22:00:31 +00:00
Uwe Hermann 8d558c7a9f strutil.c: Don't expose sr_atox() as API calls for now. 2013-12-03 17:16:59 +01:00
poljar (Damir Jelić) 1bd9e678ac serial: Add function to extract serial options.
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.
2013-12-03 15:10:01 +01:00
poljar (Damir Jelić) 1a323dd887 scpi: Add function to fetch uint8_t.
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.
2013-12-03 15:10:01 +01:00
poljar (Damir Jelić) 8acbb89a1d scpi: Add function to get an array of floats.
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.
2013-12-03 15:10:01 +01:00
poljar (Damir Jelić) f5922adef5 scpi: Add a function to read and wait on a *OPC? reply.
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.
2013-12-03 15:10:01 +01:00
poljar (Damir Jelić) d730f70e06 scpi: Add more functions (getting int/bool/float/double).
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.
2013-12-03 15:10:01 +01:00
poljar (Damir Jelić) 7b9d732031 scpi: Add helper functions for SCPI communication.
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.
2013-12-03 15:10:00 +01:00
Martin Ling 9647ce694b Use new libserialport blocking/nonblocking API calls. 2013-12-01 18:51:24 +01:00
Martin Ling ae67644fe5 Create & use new sr_usbtmc_dev_inst for Rigol DS driver. 2013-11-29 01:13:22 +00:00
Uwe Hermann e2b2382101 Make struct sr_session opaque.
The fields of this structure should not be used directly by frontends
(and none of the current ones do). Thus, make the struct opaque and hide
its contents from the API.
2013-11-22 15:02:12 +01:00
Uwe Hermann dc99135322 libsigrok-internal.h: Fix libserialport.h name. 2013-11-15 09:48:34 +01:00
Uwe Hermann c4f2dfd0f0 configure.ac: libserialport is optional.
Disable drivers that need serial port support if libserialport is not found.

Also, disable building various other serial port related code in that case.
2013-11-15 09:36:51 +01:00
Martin Ling c9bc57b6bc Update to new libserialport API. 2013-11-14 23:48:16 +01:00
Martin Ling a9bce5a561 Use libserialport for serial port access. 2013-11-14 23:48:16 +01:00
Uwe Hermann 6bf4273ee8 Fix two FreeBSD build issues related to libusb-1.0.
FreeBSD's libusb-1.0 compatible library has a few differences compared
to the "normal" libusb-1.0 from libusb.org which we have to work around.

LIBUSB_CLASS_APPLICATION doesn't exist in FreeBSD's libusb, and
libusb_handle_events_timeout_completed() doesn't exist either.
The latter is basically libusb_handle_events_timeout() with an extra
(unused by us) parameter, so the workaround is relatively simple.

This fixes bug #185.
2013-10-28 22:59:32 +01:00
Uwe Hermann c02dc3e261 metex14: Add support for pF (picofarad).
This is used on some Metex DMMs.
2013-10-23 18:41:13 +02:00
Aurelien Jacobs bfb926c1d2 es519xx: restore correct packet size 2013-10-21 00:35:23 +02:00
Uwe Hermann 93d719cde6 es519xx: Fix incorrect packet size, and a typo. 2013-10-07 00:36:18 +02:00
Uwe Hermann 72e1672fc9 es519xx: Cosmetics, coding style, minor fixes. 2013-10-07 00:36:18 +02:00
Aurelien Jacobs c01bdebc57 add cyrustek es519xx generic protocol parser 2013-10-07 00:36:18 +02:00
Bert Vermeulen f438e0c923 Add sr_session_append(): add captured data to an existing session file
This extends the session file format to contain logic data files named
either "logic-1" as before, or "logic-1-1", "logic-1-2", ...
representing chronologically ordered chunks of captured data.

The chunks are transparently concatenated together by sr_session_load().
2013-09-18 13:28:07 +02:00
Uwe Hermann e52bb9be83 Voltcraft VC-830: Fix diode mode handling.
This DMM is not using the standard bits in the FS9922 protocol/structure
to indicate the "volt" and "diode mode" flags. Instead, it only sets the
user-defined bit "z1" to indicate both "diode mode" and "volt".

This fixes #142.
2013-09-01 15:27:21 +02:00
Uwe Hermann 1861be0baf Make sr_session_iteration() static.
This function is not used outside of session.c at the moment, so make
it static for now.
2013-08-07 16:21:57 +02:00
Bert Vermeulen f6eb2cb555 Make sr_session_iteration() private 2013-07-18 15:06:37 +02:00
Uwe Hermann f6beaac55c std: Drop hw_ from function names.
The per-driver API calls no longer have a hw_ prefix (e.g. hw_init()
became init() and so on), so drop the 'hw_' from the std versions
for those API callbacks too.
2013-06-02 16:46:18 +02:00
Uwe Hermann 6078d2c996 Use consistent API callback function names.
This now matches what the 'new-driver' tool generates.
2013-05-10 20:01:37 +02:00
Uwe Hermann 2451a20ff5 fs9721: Factor out common code from serial-dmm.
These functions are FS9721 specific (and DMM specific), and can be used
from various drivers (e.g. serial-dmm or uni-t-dmm or possibly others).
2013-05-01 02:16:55 +02:00
Uwe Hermann 4853559466 uni-t-dmm/serial-dmm: Handle Voltcraft VC-840 temperature. 2013-05-01 01:58:42 +02:00
Uwe Hermann 7381251e33 common/dmm: Drop obsolete *is_packet_start() functions. 2013-04-26 20:05:44 +02:00
Uwe Hermann 913abe8321 fs9922: Use common DMM API.
Use the same functions and structs as the other DMM protocol parsers
in hardware/common/dmm. Among other things, this allows the functions
to be used from drivers in a generic way, e.g. in serial-dmm, uni-t-dmm,
and possibly other drivers.
2013-04-26 20:05:44 +02:00
Uwe Hermann 50985c2019 GPL headers: Use correct project name. 2013-04-23 22:24:30 +02:00
Uwe Hermann 522a34343f Drop obsolete g_match_info_unref() workaround.
We hard-depend on glib >= 2.32.0 now anyway, so this is no longer needed.
2013-04-20 13:43:48 +02:00
Bert Vermeulen ae5859fff0 Allow for sdi->priv helper function in std_dev_clear 2013-04-17 00:49:41 +02:00
Bert Vermeulen 49f00e13f7 Add driver helper std_dev_clear() 2013-04-16 17:57:08 +02:00
Alexandru Gagniuc 33c6e4c5a4 session: Make sr_session_stop thread-safe
With the sigrok session running in a worker thread, if sr_session_stop is called
from another thread, it shuts down the pollfds used by the hardware drivers,
without ensuring that the sigrok event loop is no longer using those pollfds.

On the demo driver, this involves shutting down the GIOChannels, causing a
segfault when the sigrok event loop tries to use them. This is evident when
using the Stop button in PulseView, while the session is running.

This isn't a problem with just the demo driver; any driver's resources may be
freed by sr_session_stop concurrently with the sigrok session running.

To solve this problem, we don't touch the session itself in sr_session_stop().
Instead, we mark it for decommissioning and return. The session polls this flag,
and shuts itself down when requested.

This fixes bug 4.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2013-04-14 23:39:15 +02:00
Bert Vermeulen 722db131a4 Add sr_config_free()
Due to struct sr_config now containing a GVariant, this needs to be
cleaned up after use properly. This is a helper function for that.
2013-04-11 18:32:06 +02:00
Bert Vermeulen bc1c2f001a Use GVariant for sr_config_*() functions
sr_config_get() provides a GVariant owned by the caller, so it must be
released with g_variant_unref() when done.

sr_config_set() takes a GVariant from the caller which may be floating;
it will be properly sunk and release after use by this function. Thus
the output of g_variant_new_*() may be used as an argument.

sr_config_list() also provides a GVariant owned by the caller, to be
unreferenced when done.

sr_config_make() can take a floating reference.
2013-04-11 18:32:06 +02:00
Bert Vermeulen 13d8e03c4f Bump copyright year 2013-04-11 18:32:06 +02:00
Uwe Hermann 3ebce226a2 s/sr_config_make/sr_config_new/.
This matches the naming of other/similar functions better.
2013-03-23 14:16:00 +01:00
Uwe Hermann cd2f0fe22c Add/use std_hw_dev_acquisition_stop_serial(). 2013-02-08 23:32:45 +01:00
Uwe Hermann 4afdfd4628 Add and use std_session_send_df_header().
This is a small helper function which sends the SR_DF_HEADER packet that
drivers usually emit in their hw_dev_acquisition_start() API callback.
It simplifies and shortens the hw_dev_acquisition_start() functions
quite a bit.

It also simplifies the input modules which send an SR_DF_HEADER packet, too.

This patch also automatically removes some unneeded malloc/free in some
drivers for the 'packet' and 'header' structs used for SR_DF_HEADER.
2013-02-07 10:46:28 +01:00
Uwe Hermann bf6f8399fc Make 'struct rs9lcd_info' non-empty.
Empty structs can be an issue (compiler-dependent), so add a dummy entry
for this one.
2013-02-02 12:14:26 +01:00
Uwe Hermann 063e7aef6d Factor out common hw_init() driver code.
Most drivers do pretty much the same things in their hw_init()
right now, so factor out that code to std_hw_init() in std.c.
2013-01-29 12:56:02 +01:00
Bert Vermeulen 4c0e310ca3 Add small helper for creating struct sr_config 2013-01-21 23:32:49 +01:00
Bert Vermeulen 5635705c83 cleanup of obsolete definition 2013-01-13 18:07:05 +01:00
Uwe Hermann fe0c0b98c6 Add Cyrustek ES51922 DMM chip parser. 2013-01-03 01:13:06 +01:00
Bert Vermeulen 9116262931 add USBTMC device search helper 2012-12-30 01:44:58 +01:00
Joel Holdsworth bf53457d1d Pass sr_datafeed_packets and payloads with const pointers
This patch marks packet structures and their payloads as const.
This indicates to packet receivers that modifications to these are
not allowed. In general all pointers should be marked const unless
modification of the referenced data is explicitly allowed.
2012-12-20 07:51:21 +00:00
Alexandru Gagniuc e7ed87a469 serial-dmm: Use dummy info struct for rs9lcd parser
The rs9lcd parser, which is used for the RadioShack 22-812 does not use its
*info parameter, and therefore did not have a rs9lcd_info struct declared.

With recent re-factoring of the receive data callbacks, it became necessary to
pass a struct pointer. This made the RECV_DATA macro look like:

- RECV_DATA(RADIOSHACK_22_812, metex14)

giving the wrong impression that the RadioShack 22-182 uses the
metex14 protocol, which is not the case.

Create a dummy rs9lcd_info struct, and correctly identify the parser
as rs9lcd in the RECV_DATA macro:

+ RECV_DATA(RADIOSHACK_22_812, rs9lcd)

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2012-12-13 23:16:34 +01:00
Bert Vermeulen 7ae6a75826 usb: sr_usb_find() uses standardized connection string to find a USB device 2012-12-04 23:25:11 +01:00
Peter Stuge 1ebe4b4e69 hw_init(): Save struct sr_context * parameter in struct drv_context 2012-12-03 12:07:40 +01:00
Alexandru Gagniuc 21829e6708 radioshack-dmm: Integrate into serial-dmm
Use the infrastructure of serial-dmm to handle the RadioShack 22-812,
and completely remove radioshack-dmm.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2012-12-02 22:22:07 +01:00
Alexandru Gagniuc 05f134abc2 radioshack-dmm: Separate protocol parser from driver
Move the parsing part of radioshack-dmm into a separate protocol
parser, following the model from hardware/common/dmm.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2012-12-02 22:18:22 +01:00
Uwe Hermann 9871215c83 metex14: Add dB mode and hFE mode support.
This is found e.g. on the Metex M-3640D DMM.
2012-12-02 14:22:51 +01:00
Uwe Hermann ce3777ada9 serial-dmm: Add Metex ME-31 support. 2012-12-02 14:22:46 +01:00
Uwe Hermann 1fbab46626 metex14: Pass 'info' as a void pointer.
This is done so that the function prototype of all sr_*_parse() DMM
functions is the same, which will be needed later.
2012-12-02 14:21:17 +01:00
Uwe Hermann 93357bc3ce fs9721: Pass 'info' as a void pointer.
This is done so that the function prototype of all sr_*_parse() DMM
functions is the same, which will be needed later.
2012-12-02 14:21:17 +01:00
Uwe Hermann a54dd31e38 serial: Use OS-independent flags for serial port opening.
Add SERIAL_RDWR, SERIAL_RDONLY, and SERIAL_NONBLOCK (for now), which are
mapped to the respective OS-specific mechanism in serial_open().
2012-12-02 12:45:54 +01:00
Bert Vermeulen 71caaad46b serial: allow for extra rts and dtr options in conn string
Options in addition to the usual "9600/8n1" syntax start with a
slash, and take the form of key=value, where different options are
also separated by slashes. For example:

	"9600/8n1/rts=0/dtr=1"

This sets RTS low and DTR high.
2012-11-27 00:55:08 +01:00
Uwe Hermann ac913e5c35 Add Metex 14-byte ASCII protocol parser. 2012-11-17 22:27:54 +01:00
Uwe Hermann 766456be1c Move serial_stream_detect() to serial.c. 2012-11-14 18:40:07 +01:00
Bert Vermeulen 299bdb249e serial: revamp internal API
The only thing to get passed around now is the struct sr_serial_dev_inst
pointer. This should make things more portable as well.
2012-11-12 00:27:17 +01:00
Alexandru Gagniuc a99e0d2a0c ols: Do not randomly probe serial ports
ols driver used to probe a series of available serial ports obtained
by regexp matching of common serial port names.
There are a number of problems with this approach:
1. It will probe all serial devices, including devices that do not
like to be probed, potentially causing them to act up.
2. It will try to probe serial ports which may already be opened in
other applications for other purposes.
3. It assumes the naming of the serial ports is set in stone, and
creates an unnecessary OS-specific list.
4. It produces unnecessary debug output even when an OLS device is
not connected.
5. etc...

Do not implicitly probe serial ports. Only probe the port specified
by the frontend, if any; otherwise, just quit.
Also get rid of all functionality in serial.c which was designed
specifically for random probing.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2012-11-11 03:12:10 +01:00
Bert Vermeulen b87f8504dc g_get_monotonic_time() takes a signed int64 2012-11-07 01:23:24 +01:00
Uwe Hermann 0c632d36be genericdmm: Factor out USB functions.
Move sr_usb_connect() and sr_usb_open() to hardware/common/usb.c in a
slightly more generic form and add more error checks and logging.

Let genericdmm use the new/moved functions.
2012-11-03 00:02:56 +01:00
Uwe Hermann b19f4622b6 serial: More error-checking & logging, add baudrates.
This mostly affects the non-Windows code so far, the rest will follow.
2012-11-02 18:02:20 +01:00
Uwe Hermann 8c1adf3738 Rework FS9721 parser.
Merge parts of the tekpower-dmm code (the chip of the TekPower
TP4000ZC seems to be an FS9721_LP3 too) and rework parts of the functions.

Adapt the tekpower-dmm and uni-t-dmm code accordingly.
2012-11-02 01:09:58 +01:00
Uwe Hermann 6f22a8ef2c Factor out serial_readline() to serial.c.
Only one (slightly different) variant remains in agilent-dmm, this will
be merged soon too, though.
2012-10-30 19:59:21 +01:00
Uwe Hermann 6c701476ad Add protocol parser for FS9721_LP3/FS9721B.
The Fortune Semiconductor FS9721_LP3 and FS9721B/Q100 DMM chips are very
similar and the protocol looks identical.

Tested on a Voltcraft VC-820 (FS9721_LP3) with the uni-t-dmm driver
(needs some small changes, tbd).
2012-10-29 15:17:17 +01:00
Uwe Hermann 79081ec80c Initial support for UNI-T DMMs.
This is not yet fully finished, but works for most use-cases.

Tested with a UNI-T UT61D using the UT-D04 USB/HID cable (new version).
2012-10-27 23:17:30 +02:00
Uwe Hermann 545f978639 config.h usage cleanups.
- Drop config.h #include from files that don't actually use any of
   its contents (at the moment).

 - Add comment for those that do need it.
2012-10-24 00:41:21 +02:00
Uwe Hermann 393fb9cb18 Doxygen: Add @file items for the relevant files.
These short descriptions are shown in the "Files" section of the
Doxygen output.
2012-10-22 11:56:18 +02:00
Peter Stuge 785b9ff290 Add and init libusb_context * in struct sr_context when using libusb-1.0
This allows hardware drivers to use a common libusb_context.
2012-10-21 20:23:36 +02:00
Peter Stuge b8072700c1 Add a struct sr_context * parameter to sr_init() and sr_exit() 2012-10-21 20:23:14 +02:00
Uwe Hermann 026c822d8c Move 'struct drv_context' to sigrok-internal.h.
It's not meant to be visible to frontends.
2012-10-21 16:40:13 +02:00
Uwe Hermann 33df15f144 Quick workaround for g_match_info_unref(). 2012-10-11 23:57:26 +02:00
Bert Vermeulen 792fc68658 serial: add serial_set_paramstr() 2012-09-02 15:42:56 +02:00
Bert Vermeulen 48a486cd3e sr: code organization cleanup
Device-specific functions (public and private) go in device.c,
more general driver-related code in hwdriver.c
2012-08-03 11:29:00 +02:00
Bert Vermeulen d6a8df467d sr: remove obsolete sr_dev_inst_get() call 2012-08-03 11:29:00 +02:00
Bert Vermeulen de4d3f99d9 sr: change session API/code to use sdi 2012-08-03 11:28:59 +02:00
Bert Vermeulen 47211d65b4 sr: add probe list to device instance
There is no point in libsigrok copying probe lists around. The driver now
builds a list of probes according to the model device it found, and will
make that available to a frontend. The frontend thus has a reference of
what the driver has, including default names, and doesn't need libsigrok
to provide an unnecessary level of abstraction.

The sr_probe_new() library-private function is a helper for drivers.
2012-08-03 10:27:37 +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
Renamed from sigrok-internal.h (Browse further)