Commit Graph

70 Commits

Author SHA1 Message Date
Uwe Hermann e66d1892d0 drivers: Add and use STD_CONFIG_LIST().
This ensures consistent handling of the SR_CONF_SCAN_OPTIONS and
SR_CONF_DEVICE_OPTIONS (with sdi NULL or non-NULL) config keys
and also reduces copy-pasted boilerplate in the drivers a bit.

This function does not handle channel-group specific items, that's
very driver-specific and thus left to the individual drivers.

Also move some generic checks and error messages from the drivers into
the sr_config_list() wrapper.
2017-07-19 15:11:01 +02:00
Uwe Hermann 91057d2fc2 Various log message cleanups.
Drop unneeded log messages, add some others that might be useful,
document which ones we're intentionally not emitting.

Don't log "$operation successful" type of messages in most cases,
that's too verbose; logging failures only is sufficient there.

baylibre-acme: Don't log "No such file or directory" messages during scan,
this triggers on all kinds of unrelated devices (e.g. "AMDGPU i2c bit
bus 0x91" in this case):

  sr: [...] baylibre-acme: Name for probe 1 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0040/name”: No such file or directory
  sr: [...] baylibre-acme: Name for probe 2 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0041/name”: No such file or directory
  sr: [...] baylibre-acme: Name for probe 3 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0044/name”: No such file or directory
  sr: [...] baylibre-acme: Name for probe 4 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0045/name”: No such file or directory
  sr: [...] baylibre-acme: Name for probe 5 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0042/name”: No such file or directory
  sr: [...] baylibre-acme: Name for probe 5 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-004c/name”: No such file or directory
  sr: [...] baylibre-acme: Name for probe 6 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0043/name”: No such file or directory
  sr: [...] baylibre-acme: Name for probe 6 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0049/name”: No such file or directory
  sr: [...] baylibre-acme: Name for probe 7 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0046/name”: No such file or directory
  sr: [...] baylibre-acme: Name for probe 7 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-004f/name”: No such file or directory
  sr: [...] baylibre-acme: Name for probe 8 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0047/name”: No such file or directory
  sr: [...] baylibre-acme: Name for probe 8 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-004b/name”: No such file or directory
2017-07-13 11:59:11 +02:00
Uwe Hermann 89ab9fc39c sr_config_commit(): Factor out SR_ERR_DEV_CLOSED check.
This ensures consistent checks and log messages across all drivers
and reduces the per-driver boilerplate.
2017-07-07 21:51:22 +02:00
Uwe Hermann c3cd66a00c sr_config_set(): Factor out SR_ERR_DEV_CLOSED check.
This ensures consistent checks and log messages across all drivers
and reduces the per-driver boilerplate.
2017-07-07 21:51:19 +02:00
Uwe Hermann f670835f1f Add sr_dev_acquisition_start(), factor out SR_ERR_DEV_CLOSED check.
This ensures consistent checks and log messages across all drivers
and reduces the per-driver boilerplate.
2017-07-07 21:51:16 +02:00
Uwe Hermann d2f7c417fd Add sr_dev_acquisition_stop(), factor out SR_ERR_DEV_CLOSED check.
This ensures consistent checks and log messages across all drivers
and reduces the per-driver boilerplate.
2017-07-07 21:51:10 +02:00
Uwe Hermann f200d59ee2 Various Doxygen fixes. 2017-06-12 02:44:28 +02:00
Uwe Hermann 6928c4a928 Add SR_CONF_SIGNAL_GENERATOR. 2017-03-02 15:17:53 +01:00
Uwe Hermann 97c2710b2c hwdriver: Drop unneeded debug message.
The logs already show scan attempts per-driver, no need to also log the
init per-driver, since that's always happening and cannot (normally) fail.
2017-02-26 15:43:35 +01:00
Aurelien Jacobs 841aadc95b libsigrok.h: Add SR_MQ_HARMONIC_RATIO. 2017-01-22 19:03:29 +01:00
Uwe Hermann d9251a2c9f Remove some unneeded double-spaces.
(also perform some other minor whitespace fixes while at it)
2016-08-29 21:51:27 +02:00
Aurelien Jacobs 9ea62f2e0a rigol-ds: add support for getting/setting trigger level. 2016-06-25 18:19:47 +02:00
Uwe Hermann 4d399734b4 config_list: Don't check for sdi->priv != NULL.
If sdi is != NULL, the backend ensures that sdi->priv is also != NULL.
Almost all drivers were relying on this already.
2016-05-17 01:12:56 +02:00
Uwe Hermann 709468baf7 config_get(): Don't check for sdi->priv != NULL.
If sdi is != NULL, the backend ensures that sdi->priv is also != NULL.
Almost all drivers were relying on this already.
2016-05-17 01:12:56 +02:00
Uwe Hermann b0baddef56 config_set(): Don't check for sdi->priv != NULL.
Instead, have the backend check that sdi->priv is not NULL (which
many drivers have been assuming already anyway).
2016-05-17 01:12:56 +02:00
Diego Asanza 20d8ae41f4 Change type of SR_CONF_CONTINUOUS from SR_T_UINT64 to SR_T_BOOL
SR_CONF_CONTINUOUS is used to check if a device supports continuous sampling
or not. As such, the type boolean is better suited.

Signed-off-by: Diego Asanza <f.asanza@gmail.com>
2016-05-16 18:18:58 +02:00
Uwe Hermann 152e7f4d7c hwdriver.c: Add missing SR_MQFLAG_FOUR_WIRE entry. 2016-04-23 17:45:49 +02:00
Benjamin Larsson 2c4600191b memory leak fix: g_variant_print() usage fix
g_variant_print() allocates memory during call. Save the pointer
so that it can be free'd afterwards.

==10048== 16 bytes in 1 blocks are definitely lost in loss record 17 of 37
==10048==    at 0x4C2DEAE: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10048==    by 0x536C85D: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x53877C6: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x5388B60: g_string_append_vprintf (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x5388D83: g_string_append_printf (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x539D034: g_variant_print_string (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x539C92C: g_variant_print (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x4E5F713: log_key (hwdriver.c:597)
==10048==    by 0x4E5FCD5: sr_config_set (hwdriver.c:752)
==10048==    by 0x408C1A: run_session (session.c:661)
==10048==    by 0x404FC5: main (main.c:267)
==10048==
==10048== 16 bytes in 1 blocks are definitely lost in loss record 18 of 37
==10048==    at 0x4C2DEAE: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10048==    by 0x536C85D: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x53877C6: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x5388B60: g_string_append_vprintf (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x5388D83: g_string_append_printf (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x539D034: g_variant_print_string (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x539C92C: g_variant_print (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.1)
==10048==    by 0x4E5F713: log_key (hwdriver.c:597)
==10048==    by 0x4E5FBDD: sr_config_get (hwdriver.c:709)
==10048==    by 0x4080D7: datafeed_in (session.c:196)
==10048==    by 0x4E5D47E: sr_session_send (session.c:1192)
==10048==    by 0x4E62682: std_session_send_df_header (std.c:101)
2016-04-23 17:37:45 +02:00
Alexandru Gagniuc fadb19ac96 hwdriver: Add configuration key for number of powerline cycles
High precision multimeters have a special setting, called "number of
powerline cycles" (NPLC) which determines the integration time of the
ADC in terms of the power line period. Some devices need their NPLC
adjusted from the default value before they can measure at their full
rated precision.
2016-03-30 12:39:25 +02:00
Uwe Hermann 2fe1011f1d Add SR_CONF_UNDER_VOLTAGE_CONDITION* config keys.
Add two new config keys:

 - SR_CONF_UNDER_VOLTAGE_CONDITION

 - SR_CONF_UNDER_VOLTAGE_CONDITION_ACTIVE
2016-02-11 14:42:50 +01:00
Uwe Hermann 8141a0325c Rename sr_driver_scan_options() to sr_driver_scan_options_list(). 2015-12-31 19:04:34 +01:00
Martin Ling cffdc3e63b Make SR_CONF_{SCAN,DEVICE}_OPTIONS into internal constants.
These are no longer needed in the public API as we have new wrapper functions.
They are still used internally by drivers.
2015-12-31 19:00:16 +01:00
Martin Ling 8f3168b89b Add new sr_driver_scan_options() helper function.
This function replaces the pattern of calling config_list() with
SR_CONF_SCAN_OPTIONS to obtain a list of scan options.
2015-12-31 19:00:16 +01:00
Uwe Hermann 9e9dba7b41 Use the ALLZERO macro in more places. 2015-11-27 00:55:09 +01:00
Uwe Hermann 2c24077466 Constify a lot more items.
This fixes various compiler warnings when -Wdiscarded-qualifiers is used.
2015-11-08 19:11:25 +01:00
Uwe Hermann 428d79a810 Drop obsolete SR_CONF_MEASURED_2ND_QUANTITY. 2015-09-13 21:43:17 +02:00
Daniel Elstner 6ec6c43b47 Build: Include <config.h> first in all source files
Since Autoconf places some important feature flags only into the
configuration header, it is necessary to include it globally to
guarantee a consistent build.
2015-09-13 18:54:46 +02:00
Daniel Elstner 6433156c32 Fix log varargs bugs indicated by -Wformat
A few of these were pretty serious, like missing arguments,
passing integers where a string was expected, and so on.
In some places, change the types used by the code rather than
just the format strings.
2015-09-13 02:29:38 +02:00
Bert Vermeulen 661cc2ec46 Convert SR_CONF_MEASURED_QUANTITY to SR_T_MQ. 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
Uwe Hermann ca7dbb5616 Various key lists: Add reminders of what needs updates upon changes. 2015-08-28 16:32:14 +02:00
Uwe Hermann 29ae6f0880 hwdriver.c: Fix key order, add missing items. 2015-08-28 16:29:07 +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
Daniel Elstner c1aae90038 Build: Set local include directories in Makefile.am
Move the include flags for files in the source tree from
configure.ac to Makefile.am where they belong.  Also use
AM_CPPFLAGS instead of CFLAGS/CXXFLAGS to make sure the
files in the build/source tree are always picked up first.

Also, remove the include/libsigrok sub-directory from the
search path, thereby making the <libsigrok/> prefix mandatory
when building libsigrok itself.  This matches the convention
already imposed on users of the library.
2015-08-16 18:28:12 +02:00
Soeren Apel 41812aca43 Fix #442 by renaming sr_dev_driver.priv to .context 2015-07-10 01:22:15 +02:00
Aurelien Jacobs c4b7838922 libsigrok.h: Add SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE. 2015-06-07 20:15:07 +02:00
Aurelien Jacobs daa3901205 Add a modbus communication helper module. 2015-05-12 13:22:34 +02:00
Aurelien Jacobs 7a0b98b544 Rename SR_CONF_OUTPUT_* to SR_CONF_*.
All those options are currently applied only to power-supplies
but they could apply as well to electronic loads, except for the
fact that electronic loads channels are called inputs and not
outputs.
Also when you think about an SMU (or any kind of 4-quadrants
power-supply), their channels can both source and sink current,
so they can be considered as input as much as output.
Those SR_CONF_* are thus renamed so that they can be used in all
those situations.
2015-05-12 13:22:34 +02:00
Alexandru Gagniuc a77585d4ae global: Add configuration key for output frequency target
This will be used to set up the output frequency of AC sources.
2015-05-06 19:41:46 +02:00
Alexandru Gagniuc b94dd07b08 global: Treat SR_CONF_OUTPUT_FREQUENCY as float instead of uint64_t
This makes 'output_frequency' symmetrical with 'output_current' and
'output_voltage'. On a more fundamental level, there's no reason why
frequency should be treated as a discrete quantity, other than
"es51919 used it this way".
2015-05-06 10:25:16 -07:00
Uwe Hermann 032da34b78 sr_driver_list() now takes a context pointer.
This requires sr_hw_cleanup_all() and sanity_check_all_drivers()
to also take a context.

The (runtime) generation of the driver list now happens in sr_init()
and sr_driver_list() always returns that pre-generated list. This fixes
a segfault when (correctly) invoking multiple sr_init() and sr_exit()
calls with different contexts (caught by the unit tests).

This fixes bug #565.
2015-04-07 02:09:56 +02:00
Uwe Hermann dcd438ee35 Simplify a few config_set() callbacks.
Also, extended logging and random whitespace fixes.
2015-03-22 02:15:30 +01:00
Uwe Hermann 1a8639164e Minor cosmetics, cleanups. 2015-03-21 18:28:02 +01:00
Martin Ling 4f840ce965 Pass driver struct pointer to driver callbacks.
This lays the groundwork for subdrivers to share callbacks without
needing a separate wrapper function for each subdriver.
2015-03-21 13:09:40 +01:00
Martin Ling 9e60a31fb9 Construct driver array at runtime, from an array of per-file arrays.
This lays the groundwork for drivers to define their own array of
subdrivers, rather than having to list each subdriver here.
2015-03-21 13:09:39 +01:00
Martin Ling bf622e6d00 Rename SR_CONF_NUM_TIMEBASE to SR_CONF_NUM_HDIV. 2015-03-02 12:24:12 +01:00
Bartosz Golaszewski d3c81725ae SR_CONF_PROBE_FACTOR: New option.
Add new configuration option allowing to modify the probe factor
for oscilloscopes and power-monitors.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2015-02-16 01:20:07 +01:00
Bartosz Golaszewski 9ed444e622 new config options: averaging
Add new config options to libsigrok - 'averaging', which allows to
enable averaging of samples and 'avg_samples' for setting the number
of samples to be averaged over in each cycle.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2015-01-25 18:00:40 +01:00