]> sigrok.org Git - libsigrok.git/commitdiff
rdtech-um: send analog values in frames not samples
authorGerhard Sittig <redacted>
Thu, 16 Mar 2023 12:00:34 +0000 (13:00 +0100)
committerGerhard Sittig <redacted>
Thu, 16 Mar 2023 13:29:30 +0000 (14:29 +0100)
The RDTech UM energy meter provides six analog channels, the values of
which are taken at the same time from one consistent raw data image.
Send these values in frames, so applications can tell they are related.

This drops support for --samples specifications. And allows to read back
previously specified time limits.

Tested by means of:
  $ sigrok-cli -d rdtech-um:conn=bt/rfcomm/$MAC --show
  $ sigrok-cli -d rdtech-um:conn=bt/rfcomm/$MAC --frames 4

src/hardware/rdtech-um/api.c
src/hardware/rdtech-um/protocol.c

index 363dfe55c53bf63907d4a3bdd24ddf076da5dc7b..67ff37d87b6b675cc20ea826f73f4271c099080f 100644 (file)
@@ -42,8 +42,8 @@ static const uint32_t drvopts[] = {
 
 static const uint32_t devopts[] = {
        SR_CONF_CONTINUOUS,
-       SR_CONF_LIMIT_SAMPLES | SR_CONF_SET,
-       SR_CONF_LIMIT_MSEC | SR_CONF_SET,
+       SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET,
+       SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
 };
 
 static GSList *rdtech_um_scan(struct sr_dev_driver *di,
@@ -143,6 +143,18 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        return rdtech_um_scan(di, conn, serialcomm);
 }
 
+static int config_get(uint32_t key, GVariant **data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
+{
+       struct dev_context *devc;
+
+       (void)cg;
+
+       devc = sdi->priv;
+
+       return sr_sw_limits_config_get(&devc->limits, key, data);
+}
+
 static int config_set(uint32_t key, GVariant *data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
@@ -186,7 +198,7 @@ static struct sr_dev_driver rdtech_um_driver_info = {
        .scan = scan,
        .dev_list = std_dev_list,
        .dev_clear = dev_clear,
-       .config_get = NULL,
+       .config_get = config_get,
        .config_set = config_set,
        .config_list = config_list,
        .dev_open = std_serial_dev_open,
index 25de9ec41ea5d91d9a828eecd604ebf34a304624..6508742760798d70a5712e571063af261793f131 100644 (file)
@@ -208,20 +208,23 @@ static int process_data(struct sr_dev_inst *sdi,
                return SR_ERR_DATA;
        }
 
+       ret = SR_OK;
+       std_session_send_df_frame_begin(sdi);
        for (ch_idx = 0; ch_idx < p->channel_count; ch_idx++) {
                ret = bv_get_value(&v, &p->channels[ch_idx].spec, data, dlen);
                if (ret != SR_OK)
-                       return ret;
+                       break;
                ret = feed_queue_analog_submit(devc->feeds[ch_idx], v, 1);
                if (ret != SR_OK)
-                       return ret;
+                       break;
        }
+       std_session_send_df_frame_end(sdi);
 
-       sr_sw_limits_update_samples_read(&devc->limits, 1);
+       sr_sw_limits_update_frames_read(&devc->limits, 1);
        if (sr_sw_limits_check(&devc->limits))
                sr_dev_acquisition_stop(sdi);
 
-       return SR_OK;
+       return ret;
 }
 
 static int accum_data(struct sr_dev_inst *sdi, struct sr_serial_dev_inst *serial)