From: Gerhard Sittig Date: Thu, 16 Mar 2023 12:00:34 +0000 (+0100) Subject: rdtech-um: send analog values in frames not samples X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d6ca362d3a1eab2b5e1426a423d44455c6a32205;p=libsigrok.git rdtech-um: send analog values in frames not samples 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 --- diff --git a/src/hardware/rdtech-um/api.c b/src/hardware/rdtech-um/api.c index 363dfe55..67ff37d8 100644 --- a/src/hardware/rdtech-um/api.c +++ b/src/hardware/rdtech-um/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_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, diff --git a/src/hardware/rdtech-um/protocol.c b/src/hardware/rdtech-um/protocol.c index 25de9ec4..65087427 100644 --- a/src/hardware/rdtech-um/protocol.c +++ b/src/hardware/rdtech-um/protocol.c @@ -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)