From: Gerhard Sittig Date: Thu, 16 Mar 2023 04:21:51 +0000 (+0100) Subject: rdtech-tc: send analog values in frames not samples X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=15ceaf9da051f1eb2bcefdfda8630cdfd8b32e79;p=libsigrok.git rdtech-tc: send analog values in frames not samples 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 --- diff --git a/src/hardware/rdtech-tc/api.c b/src/hardware/rdtech-tc/api.c index 5dd277ae..3b5f1c71 100644 --- a/src/hardware/rdtech-tc/api.c +++ b/src/hardware/rdtech-tc/api.c @@ -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, diff --git a/src/hardware/rdtech-tc/protocol.c b/src/hardware/rdtech-tc/protocol.c index 32ada461..fd392884 100644 --- a/src/hardware/rdtech-tc/protocol.c +++ b/src/hardware/rdtech-tc/protocol.c @@ -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)