]> sigrok.org Git - libsigrok.git/blobdiff - include/libsigrok/libsigrok.h
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / include / libsigrok / libsigrok.h
index ed6fd42471f4029fa7c8a43b101e31f7d2bf29ed..6c5dea08ab0d3ca3eeaa7fe45f1761876f1da353 100644 (file)
@@ -80,6 +80,13 @@ enum sr_error_code {
        /* Update sr_strerror()/sr_strerror_name() (error.c) upon changes! */
 };
 
+/** Ternary return type for DMM/LCR/etc packet parser validity checks. */
+enum sr_valid_code {
+       SR_PACKET_INVALID = -1, /**< Certainly invalid. */
+       SR_PACKET_VALID = 0,    /**< Certainly valid. */
+       SR_PACKET_NEED_RX = +1, /**< Need more RX data. */
+};
+
 #define SR_MAX_CHANNELNAME_LEN 32
 
 /* Handy little macros */
@@ -146,6 +153,7 @@ enum sr_datatype {
        SR_T_DOUBLE_RANGE,
        SR_T_INT32,
        SR_T_MQ,
+       SR_T_UINT32,
 
        /* Update sr_variant_type_get() (hwdriver.c) upon changes! */
 };
@@ -233,6 +241,10 @@ enum sr_mq {
        SR_MQ_MASS,
        /** Harmonic ratio */
        SR_MQ_HARMONIC_RATIO,
+       /** Energy. */
+       SR_MQ_ENERGY,
+       /** Electric charge. */
+       SR_MQ_ELECTRIC_CHARGE,
 
        /* Update sr_key_info_mq[] (hwdriver.c) upon changes! */
 };
@@ -290,7 +302,7 @@ enum sr_unit {
        SR_UNIT_VOLT_AMPERE,
        /** Real power [W]. */
        SR_UNIT_WATT,
-       /** Consumption [Wh]. */
+       /** Energy (consumption) in watt hour [Wh]. */
        SR_UNIT_WATT_HOUR,
        /** Wind speed in meters per second. */
        SR_UNIT_METER_SECOND,
@@ -324,6 +336,12 @@ enum sr_unit {
        SR_UNIT_TOLA,
        /** Pieces (number of items). */
        SR_UNIT_PIECE,
+       /** Energy in joule. */
+       SR_UNIT_JOULE,
+       /** Electric charge in coulomb. */
+       SR_UNIT_COULOMB,
+       /** Electric charge in ampere hour [Ah]. */
+       SR_UNIT_AMPERE_HOUR,
 
        /*
         * Update unit_strings[] (analog.c) and fancyprint() (output/analog.c)
@@ -511,9 +529,22 @@ struct sr_analog_encoding {
        gboolean is_float;
        gboolean is_bigendian;
        /**
-        * Number of significant digits after the decimal point if positive,
-        * or number of non-significant digits before the decimal point if
-        * negative (refers to the value we actually read on the wire).
+        * Number of significant digits after the decimal point, if positive.
+        * When negative, exponent with reversed polarity that is necessary to
+        * express the value with all digits without a decimal point.
+        * Refers to the value we actually read on the wire.
+        *
+        * Examples:
+        *
+        * | Disp. value | Exp. notation       | Exp. not. normalized | digits |
+        * |-------------|---------------------|----------------------|--------|
+        * |  12.34 MOhm |  1.234 * 10^7   Ohm |    1234 * 10^4   Ohm |     -4 |
+        * | 1.2345 MOhm | 1.2345 * 10^6   Ohm |   12345 * 10^2   Ohm |     -2 |
+        * |  123.4 kOhm |  1.234 * 10^5   Ohm |    1234 * 10^2   Ohm |     -2 |
+        * |   1234  Ohm |  1.234 * 10^3   Ohm |    1234 * 10^0   Ohm |      0 |
+        * |  12.34  Ohm |  1.234 * 10^1   Ohm |    1234 * 10^-2  Ohm |      2 |
+        * | 0.0123  Ohm |   1.23 * 10^-2  Ohm |     123 * 10^-4  Ohm |      4 |
+        * |  1.234 pF   |  1.234 * 10^-12 F   |    1234 * 10^-15 F   |     15 |
         */
        int8_t digits;
        gboolean is_digits_decimal;
@@ -530,10 +561,22 @@ struct sr_analog_meaning {
 
 struct sr_analog_spec {
        /**
-        * Number of significant digits after the decimal point if positive,
-        * or number of non-significant digits before the decimal point if
-        * negative (refers to vendor specifications/datasheet or actual
-        * device display).
+        * Number of significant digits after the decimal point, if positive.
+        * When negative, exponent with reversed polarity that is necessary to
+        * express the value with all digits without a decimal point.
+        * Refers to vendor specifications/datasheet or actual device display.
+        *
+        * Examples:
+        *
+        * | On the wire | Exp. notation       | Exp. not. normalized | spec_digits |
+        * |-------------|---------------------|----------------------|-------------|
+        * |  12.34 MOhm |  1.234 * 10^7   Ohm |    1234 * 10^4   Ohm |          -4 |
+        * | 1.2345 MOhm | 1.2345 * 10^6   Ohm |   12345 * 10^2   Ohm |          -2 |
+        * |  123.4 kOhm |  1.234 * 10^5   Ohm |    1234 * 10^2   Ohm |          -2 |
+        * |   1234  Ohm |  1.234 * 10^3   Ohm |    1234 * 10^0   Ohm |           0 |
+        * |  12.34  Ohm |  1.234 * 10^1   Ohm |    1234 * 10^-2  Ohm |           2 |
+        * | 0.0123  Ohm |   1.23 * 10^-2  Ohm |     123 * 10^-4  Ohm |           4 |
+        * |  1.234 pF   |  1.234 * 10^-12 F   |    1234 * 10^-15 F   |          15 |
         */
        int8_t spec_digits;
 };
@@ -706,6 +749,12 @@ enum sr_configkey {
        /** The device can measure power. */
        SR_CONF_POWERMETER,
 
+       /**
+        * The device can switch between multiple sources, e.g. a relay actuator
+        * or multiplexer.
+        */
+       SR_CONF_MULTIPLEXER,
+
        /* Update sr_key_info_config[] (hwdriver.c) upon changes! */
 
        /*--- Driver scan options -------------------------------------------*/
@@ -751,6 +800,36 @@ enum sr_configkey {
         */
        SR_CONF_MODBUSADDR,
 
+       /**
+        * User specified forced driver attachment to unknown devices.
+        *
+        * By design the interpretation of the string depends on the
+        * specific driver. It typically would be either a replacement
+        * '*IDN?' response value, or a sub-driver name. But could also
+        * be anything else and totally arbitrary.
+        */
+       SR_CONF_FORCE_DETECT,
+
+       /**
+        * Override builtin probe names from user specs.
+        *
+        * Users may want to override the names which are assigned to
+        * probes during scan (these usually match the vendor's labels
+        * on the device). This avoids the interactive tedium of
+        * changing channel names after device creation and before
+        * protocol decoder attachment. Think of IEEE488 recorders or
+        * parallel computer bus loggers. The scan option eliminates
+        * the issue of looking up previously assigned names before
+        * renaming a channel (see sigrok-cli -C), which depends on
+        * the device as well as the application, and is undesirable.
+        * The scan option is limited to those drivers which implement
+        * support for it, but works identically across those drivers.
+        *
+        * The value is a string, either a comma separated list of
+        * probe names, or an alias for a typical set of names.
+        */
+       SR_CONF_PROBE_NAMES,
+
        /* Update sr_key_info_config[] (hwdriver.c) upon changes! */
 
        /*--- Device (or channel group) configuration -----------------------*/
@@ -770,9 +849,6 @@ enum sr_configkey {
        /** The device supports setting trigger slope. */
        SR_CONF_TRIGGER_SLOPE,
 
-       /** The device supports setting a pattern for the logic trigger. */
-       SR_CONF_TRIGGER_PATTERN,
-
        /** The device supports averaging. */
        SR_CONF_AVERAGING,
 
@@ -833,12 +909,6 @@ enum sr_configkey {
        /** Logic low-high threshold range. */
        SR_CONF_VOLTAGE_THRESHOLD,
 
-       /** Logic threshold: predefined levels (TTL, ECL, CMOS, etc). */
-       SR_CONF_LOGIC_THRESHOLD,
-
-       /** Logic threshold: custom numerical value. */
-       SR_CONF_LOGIC_THRESHOLD_CUSTOM,
-
        /** The device supports using an external clock. */
        SR_CONF_EXTERNAL_CLOCK,
 
@@ -1009,6 +1079,64 @@ enum sr_configkey {
        /** Offset of a source without strictly-defined MQ. */
        SR_CONF_OFFSET,
 
+       /** The device supports setting a pattern for the logic trigger. */
+       SR_CONF_TRIGGER_PATTERN,
+
+       /** High resolution mode. */
+       SR_CONF_HIGH_RESOLUTION,
+
+       /** Peak detection. */
+       SR_CONF_PEAK_DETECTION,
+
+       /** Logic threshold: predefined levels (TTL, ECL, CMOS, etc). */
+       SR_CONF_LOGIC_THRESHOLD,
+
+       /** Logic threshold: custom numerical value. */
+       SR_CONF_LOGIC_THRESHOLD_CUSTOM,
+
+       /** The measurement range of a DMM or the output range of a power supply. */
+       SR_CONF_RANGE,
+
+       /** The number of digits (e.g. for a DMM). */
+       SR_CONF_DIGITS,
+
+       /** Phase of a source signal. */
+       SR_CONF_PHASE,
+
+       /** Duty cycle of a source signal. */
+       SR_CONF_DUTY_CYCLE,
+
+       /**
+        * Current power.
+        * @arg type: double
+        * @arg get: get measured power
+        */
+       SR_CONF_POWER,
+
+       /**
+        * Power target.
+        * @arg type: double
+        * @arg get: get power target
+        * @arg set: change power target
+        */
+       SR_CONF_POWER_TARGET,
+
+       /**
+        * Resistance target.
+        * @arg type: double
+        * @arg get: get resistance target
+        * @arg set: change resistance target
+        */
+       SR_CONF_RESISTANCE_TARGET,
+
+       /**
+        * Over-current protection (OCP) delay
+        * @arg type: double (time)
+        * @arg get: get current delay
+        * @arg set: set new delay
+        */
+       SR_CONF_OVER_CURRENT_PROTECTION_DELAY,
+
        /* Update sr_key_info_config[] (hwdriver.c) upon changes! */
 
        /*--- Special stuff -------------------------------------------------*/