struct dev_context *devc;
struct sr_dev_inst *sdi;
size_t ch_idx;
- const char *name;
+ const struct rdtech_um_channel_desc *pch;
+ struct sr_channel *ch;
+ struct feed_queue_analog *feed;
serial = sr_serial_dev_inst_new(conn, serialcomm);
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
+ devc->feeds = g_malloc0(p->channel_count * sizeof(devc->feeds[0]));
for (ch_idx = 0; ch_idx < p->channel_count; ch_idx++) {
- name = p->channels[ch_idx].name;
- sr_channel_new(sdi, ch_idx, SR_CHANNEL_ANALOG, TRUE, name);
+ pch = &p->channels[ch_idx];
+ ch = sr_channel_new(sdi, ch_idx,
+ SR_CHANNEL_ANALOG, TRUE, pch->name);
+ feed = feed_queue_analog_alloc(sdi, 1, pch->digits, ch);
+ feed_queue_analog_mq_unit(feed, pch->mq, 0, pch->unit);
+ feed_queue_analog_scale_offset(feed, &pch->scale, NULL);
+ devc->feeds[ch_idx] = feed;
}
devices = g_slist_append(NULL, sdi);
return NULL;
}
+static void clear_helper(struct dev_context *devc)
+{
+ const struct rdtech_um_profile *p;
+ size_t ch_idx;
+
+ if (!devc)
+ return;
+
+ p = devc->profile;
+ if (p && devc->feeds) {
+ for (ch_idx = 0; ch_idx < p->channel_count; ch_idx++)
+ feed_queue_analog_free(devc->feeds[ch_idx]);
+ g_free(devc->feeds);
+ }
+}
+
+static int dev_clear(const struct sr_dev_driver *di)
+{
+ return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
+}
+
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
const char *conn;
.cleanup = std_cleanup,
.scan = scan,
.dev_list = std_dev_list,
- .dev_clear = std_dev_clear,
+ .dev_clear = dev_clear,
.config_get = NULL,
.config_set = config_set,
.config_list = config_list,
/* Command code to request another poll response. */
#define UM_CMD_POLL 0xf0
-static const struct binary_analog_channel default_channels[] = {
- { "V", { 2, BVT_BE_UINT16, 0.01, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
- { "I", { 4, BVT_BE_UINT16, 0.001, }, 3, SR_MQ_CURRENT, SR_UNIT_AMPERE },
- { "D+", { 96, BVT_BE_UINT16, 0.01, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
- { "D-", { 98, BVT_BE_UINT16, 0.01, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
- { "T", { 10, BVT_BE_UINT16, 1.0, }, 0, SR_MQ_TEMPERATURE, SR_UNIT_CELSIUS },
+static const struct rdtech_um_channel_desc default_channels[] = {
+ { "V", { 2, BVT_BE_UINT16, 1, }, { 10, 1e3, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
+ { "I", { 4, BVT_BE_UINT16, 1, }, { 1, 1e3, }, 3, SR_MQ_CURRENT, SR_UNIT_AMPERE },
+ { "D+", { 96, BVT_BE_UINT16, 1, }, { 10, 1e3, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
+ { "D-", { 98, BVT_BE_UINT16, 1, }, { 10, 1e3, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
+ { "T", { 10, BVT_BE_UINT16, 1, }, { 1, 1, }, 0, SR_MQ_TEMPERATURE, SR_UNIT_CELSIUS },
/* Threshold-based recording (mWh) */
- { "E", { 106, BVT_BE_UINT32, 0.001, }, 3, SR_MQ_ENERGY, SR_UNIT_WATT_HOUR },
+ { "E", { 106, BVT_BE_UINT32, 1, }, { 1, 1e3, }, 3, SR_MQ_ENERGY, SR_UNIT_WATT_HOUR },
};
-static const struct binary_analog_channel um25c_channels[] = {
- { "V", { 2, BVT_BE_UINT16, 0.001, }, 3, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
- { "I", { 4, BVT_BE_UINT16, 0.0001, }, 4, SR_MQ_CURRENT, SR_UNIT_AMPERE },
- { "D+", { 96, BVT_BE_UINT16, 0.01, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
- { "D-", { 98, BVT_BE_UINT16, 0.01, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
- { "T", { 10, BVT_BE_UINT16, 1.0, }, 0, SR_MQ_TEMPERATURE, SR_UNIT_CELSIUS },
+static const struct rdtech_um_channel_desc um25c_channels[] = {
+ { "V", { 2, BVT_BE_UINT16, 1, }, { 1, 1e3, }, 3, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
+ { "I", { 4, BVT_BE_UINT16, 1, }, { 100, 1e6, }, 4, SR_MQ_CURRENT, SR_UNIT_AMPERE },
+ { "D+", { 96, BVT_BE_UINT16, 1, }, { 10, 1e3, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
+ { "D-", { 98, BVT_BE_UINT16, 1, }, { 10, 1e3, }, 2, SR_MQ_VOLTAGE, SR_UNIT_VOLT },
+ { "T", { 10, BVT_BE_UINT16, 1, }, { 1, 1, }, 0, SR_MQ_TEMPERATURE, SR_UNIT_CELSIUS },
/* Threshold-based recording (mWh) */
- { "E", { 106, BVT_BE_UINT32, 0.001, }, 3, SR_MQ_ENERGY, SR_UNIT_WATT_HOUR },
+ { "E", { 106, BVT_BE_UINT32, 1, }, { 1, 1e3, }, 3, SR_MQ_ENERGY, SR_UNIT_WATT_HOUR },
};
static gboolean csum_ok_fff1(const uint8_t *buf, size_t len)
struct dev_context *devc;
const struct rdtech_um_profile *p;
size_t ch_idx;
- GSList *ch;
+ float v;
int ret;
devc = sdi->priv;
return SR_ERR_DATA;
}
- ch_idx = 0;
- for (ch = sdi->channels; ch; ch = g_slist_next(ch)) {
- ret = bv_send_analog_channel(sdi, ch->data,
- &devc->profile->channels[ch_idx],
- data, dlen);
- ch_idx++;
+ 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;
+ ret = feed_queue_analog_submit(devc->feeds[ch_idx], v, 1);
if (ret != SR_OK)
return ret;
}