Daniel Elstner [Fri, 9 Oct 2015 00:35:47 +0000 (02:35 +0200)]
session: Make sr_session_run() optional
Introduce a new API function sr_session_stopped_callback_set()
which can be used to receive notification when a session stops
running. This allows applications to integrate libsigrok event
processing with their own main loop, instead of blocking in
sr_session_run().
Daniel Elstner [Sat, 3 Oct 2015 12:08:32 +0000 (14:08 +0200)]
build: Do not define FIRMWARE_DIR on Windows
The hard-coded location is bound to be wrong anyway. Instead, rely
on the new resource lookup code to find the firmware files in a
location relative to the library or executable.
Daniel Elstner [Fri, 2 Oct 2015 18:09:46 +0000 (20:09 +0200)]
session-file: Use 32-bit int for channel count
SR_CONF_NUM_LOGIC_CHANNELS is defined as SR_T_INT32. Create the
GVariant with the correct type to avoid a type mismatch error in
sr_variant_type_check().
Daniel Elstner [Sat, 26 Sep 2015 11:38:30 +0000 (13:38 +0200)]
resource: New internal API for accessing resource files
The resource API provides a generic means for accessing resources
that are bundled with sigrok, such as device firmware files. Since
the manner of resource bundling is platform-dependent, users of
libsigrok may override the functions used to open, close and read
a resource. The default implementation accesses resources as files
located in one of the XDG data directories or a directory defined
at compile time.
Daniel Elstner [Sun, 20 Sep 2015 18:32:03 +0000 (20:32 +0200)]
srzip: Avoid low-level FD-based I/O
Use in-memory buffers instead of temporary files. This avoids
the need for low-level I/O on the FD returned by g_mkstemp().
Refactor the code accordingly. Also plug a number of leaks and
tighten the error checking.
Daniel Elstner [Sun, 20 Sep 2015 12:10:42 +0000 (14:10 +0200)]
session-file: Remove old session save API
Completely remove the old session save code that has been
superseded by the srzip output module. Also refactor a bit,
plug a number of leaks and tighten the error checking.
Daniel Elstner [Sat, 19 Sep 2015 18:43:25 +0000 (20:43 +0200)]
input: Use fseeko/ftello to get the size of a file
Introduce the sr_file_get_size() utility function to retrieve the
size of an open FILE stream. This is based on fseeko() followed by
ftello(), which are POSIX functions but quite portable in practice.
Since these calls operate on FILE streams instead of filenames, the
issue of filename encoding no longer arises.
Daniel Elstner [Fri, 18 Sep 2015 22:24:50 +0000 (00:24 +0200)]
input: Clean up input file scanning
Do not use Unix low-level I/O for reading a regular input file.
Read in the file header once and re-use the buffer for all input
modules participating in the scan. Also re-use a prefilled metadata
table instead of creating it anew for each input module tried.
Uwe Hermann [Fri, 25 Sep 2015 06:52:58 +0000 (08:52 +0200)]
Fix a few "value never read" scan-build warnings.
This fixes parts of bug #423.
The list of fixed warnings:
src/output/srzip.c:285:3: warning: Value stored to 'ret' is never read
ret = zip_append(o, logic->data, logic->unitsize, logic->length);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/scpi/scpi.c:610:2: warning: Value stored to 'ret' is never read
ret = SR_OK;
^ ~~~~~
src/scpi/scpi.c:667:2: warning: Value stored to 'ret' is never read
ret = SR_OK;
^ ~~~~~
src/dmm/vc870.c:410:2: warning: Value stored to 'info_local' is never read
info_local = (struct vc870_info *)info;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~
src/hardware/conrad-digi-35-cpu/api.c:130:2: warning: Value stored to 'ret' is never read
ret = SR_OK;
^ ~~~~~
src/hardware/fx2lafw/api.c:658:2: warning: Value stored to 'timeout' is never read
timeout = fx2lafw_get_timeout(devc);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~
src/hardware/gmc-mh-1x-2x/protocol.c:941:3: warning: Value stored to 'retc' is never read
retc = SR_ERR_ARG;
^ ~~~~~~~~~~
src/hardware/gmc-mh-1x-2x/api.c:168:2: warning: Value stored to 'model' is never read
model = METRAHIT_NONE;
^ ~~~~~~~~~~~~~
src/hardware/ikalogic-scanalogic2/api.c:325:2: warning: Value stored to 'ret' is never read
ret = SR_OK;
^ ~~~~~
src/hardware/openbench-logic-sniffer/api.c:185:3: warning: Value stored to 'devc' is never read
devc = sdi->priv;
^ ~~~~~~~~~
src/hardware/rigol-ds/api.c:813:3: warning: Value stored to 'devc' is never read
devc = sdi->priv;
^ ~~~~~~~~~
src/hardware/scpi-pps/api.c:405:2: warning: Value stored to 'ret' is never read
ret = SR_OK;
^ ~~~~~
src/hardware/yokogawa-dlm/api.c:239:2: warning: Value stored to 'ret' is never read
ret = SR_ERR_NA;
^ ~~~~~~~~~
Daniel Elstner [Tue, 22 Sep 2015 04:54:33 +0000 (06:54 +0200)]
demo: Increase timer interval to 100 ms
Timer intervals shorter than about 100 ms are unnecessarily taxing
on system resources. Also, on systems like Windows the smallest
resolvable time unit without using high precision timers is about
15 ms. Regular timer intervals should be well above that value to
avoid being dominated by noise and round-off.
scpi/usbtmc: Implement Rigol DS1000 workaround on any firmware version.
Firmware versions starting with 00.02.04 apparently cause the in and out
bulk endpoints to end up in a HALT state. This is likely related to the
larger transfer size quirk implemented in the Linux kernel for the Rigol
DS1000: this USBTMC implementation does not have that workaround.
Instead, if the firmware version is >= 00.02.04, both endpoints have the HALT
condition cleared on device close.
Martin Ling [Mon, 7 Sep 2015 08:15:52 +0000 (09:15 +0100)]
sr_analog_to_float: Avoid comparison between signed and unsigned.
The check for p == q is basically checking whether p/q == 1. We should
be normalising the rational before it gets here though, so in this case
we should have p == q == 1 here.
scpi: scpi_cmd_resp() shouldn't return SR_OK without filling the gvar
scpi-pps at line 212 assumes that an SR_OK return means that the gvar
is valid, which leads to the following error:
** GLib:ERROR:/build/glib2.0-2.45.8/./glib/gvarianttypeinfo.c:184:g_variant_type_info_check: assertion failed: (0 <= index && index < 24)
baylibre-acme: gpio: Don't set direction in get/set functions.
GPIO direction should be set once right after exporting. There's no need
to reset it again - in fact it's a bug which causes the probe to be reset
every time the value is read/set and gives incorrect results when reading
the GPIO values with direction == 'in'.
Revision B of ACME hardware introduces probes with on-board at24cs02
EEPROM. Extend the ACME driver to support reading the contents of
the EEPROM via linux' sysfs interface.
Also: make the driver be able to tell the difference between revisions,
add new GPIO layout and set the shunt resistance for revB at probe
registration.
baylibre-acme: Check for power-switch presence at probe's initialization.
Only perform a single check at initialization time to see if the probe is
equipped with a power-switch. This is done in preparation for revision B
support which has this kind of information encoded in EEPROM.
Daniel Elstner [Wed, 16 Sep 2015 20:35:13 +0000 (22:35 +0200)]
sysclk-lwla: Set USB device configuration
After opening the USB device, set the device configuration to 1.
Actually, do it twice, just as the vendor driver seems to do. This
is supposed to trigger a lightweight reset of the device.
Originally, I omitted this reset sequence from the sigrok driver
because it simply did not work at all for me. However, it does seem
to work now, so that may have been a problem in libusb or the kernel
which is now fixed.
Daniel Elstner [Wed, 16 Sep 2015 19:31:42 +0000 (21:31 +0200)]
sysclk-lwla: Clean up open/closed state handling
Use states SR_ST_ACTIVE and SR_ST_INACTIVE to indicate that the
device is open or closed, respectively. Do not use any of the
other state values. Improve the robustness of the open and close
methods in face of errors. Introduce a separate flag to indicate
that a running acquisition should be canceled.
Daniel Elstner [Sun, 30 Aug 2015 16:20:41 +0000 (18:20 +0200)]
sysclk-lwla: Streamline trigger setup logic
Prepare the trigger masks at config_commit() time, so that the
trigger setup can be validated before starting an acquisition.
Accordingly, do actually report validation errors back to the
caller.
Daniel Elstner [Wed, 16 Sep 2015 21:33:45 +0000 (23:33 +0200)]
fx2lafw, sysclk-lwla: Avoid g_stat()
It turns out that g_stat() breaks apart when using 64 bit stat on
32-bit systems. Since the actual type of GStatBuf is decided when
glib/gstdio.h is included, it is thus possible for GLib itself to
be compiled with a different type than user code.
Ouch. Unfortunately going back to plain stat() also means that we
lose Unicode filename support on Windows.