]> sigrok.org Git - libsigrok.git/commitdiff
rdtech-tc: send analog values in frames not samples
authorGerhard Sittig <redacted>
Thu, 16 Mar 2023 04:21:51 +0000 (05:21 +0100)
committerGerhard Sittig <redacted>
Thu, 16 Mar 2023 13:29:30 +0000 (14:29 +0100)
The RDTech TC 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-tc:conn=/dev/ttyACM0 --show
  $ sigrok-cli -d rdtech-tc:conn=/dev/ttyACM0 --frames 5

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

index 5dd277ae16b8c0023f39e5171e30509cf78e69fa..3b5f1c71e2dac4e8f1d497ff8aacebd9cb755044 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_tc_scan(struct sr_dev_driver *di,
@@ -139,6 +139,18 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        return rdtech_tc_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)
 {
@@ -182,7 +194,7 @@ static struct sr_dev_driver rdtech_tc_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 32ada461dc6f770b331a9fcc1de4677cea67b8e8..fd392884735885c4fc1ffa90d1cd250d2071c3c8 100644 (file)
@@ -216,21 +216,24 @@ static int handle_poll_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 < devc->channel_count; ch_idx++) {
                pch = &devc->channels[ch_idx];
                ret = bv_get_value(&v, &pch->spec, poll_pkt, TC_POLL_LEN);
                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 recv_poll_data(struct sr_dev_inst *sdi, struct sr_serial_dev_inst *serial)