arachnid-labs-re-load-pro: Convert to SR_DF_ANALOG.

This commit is contained in:
Uwe Hermann 2016-02-08 08:24:48 +01:00
parent 803db07a1a
commit 6e68da5140
1 changed files with 17 additions and 12 deletions

View File

@ -133,7 +133,10 @@ static void handle_packet(const struct sr_dev_inst *sdi)
{ {
float voltage, current; float voltage, current;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_datafeed_analog_old analog; struct sr_datafeed_analog analog;
struct sr_analog_encoding encoding;
struct sr_analog_meaning meaning;
struct sr_analog_spec spec;
struct dev_context *devc; struct dev_context *devc;
char **tokens; char **tokens;
GSList *l; GSList *l;
@ -156,23 +159,24 @@ static void handle_packet(const struct sr_dev_inst *sdi)
current = g_ascii_strtod(tokens[1], NULL) / 1000; current = g_ascii_strtod(tokens[1], NULL) / 1000;
g_strfreev(tokens); g_strfreev(tokens);
memset(&analog, 0, sizeof(struct sr_datafeed_analog_old));
/* Begin frame. */ /* Begin frame. */
packet.type = SR_DF_FRAME_BEGIN; packet.type = SR_DF_FRAME_BEGIN;
packet.payload = NULL;
sr_session_send(sdi, &packet); sr_session_send(sdi, &packet);
packet.type = SR_DF_ANALOG_OLD; sr_analog_init(&analog, &encoding, &meaning, &spec, 4);
packet.type = SR_DF_ANALOG;
packet.payload = &analog; packet.payload = &analog;
analog.num_samples = 1; analog.num_samples = 1;
/* Voltage */ /* Voltage */
l = g_slist_copy(sdi->channels); l = g_slist_copy(sdi->channels);
l = g_slist_remove_link(l, g_slist_nth(l, 1)); l = g_slist_remove_link(l, g_slist_nth(l, 1));
analog.channels = l; meaning.channels = l;
analog.mq = SR_MQ_VOLTAGE; meaning.mq = SR_MQ_VOLTAGE;
analog.mqflags = SR_MQFLAG_DC; meaning.mqflags = SR_MQFLAG_DC;
analog.unit = SR_UNIT_VOLT; meaning.unit = SR_UNIT_VOLT;
analog.data = &voltage; analog.data = &voltage;
sr_session_send(sdi, &packet); sr_session_send(sdi, &packet);
g_slist_free(l); g_slist_free(l);
@ -180,16 +184,17 @@ static void handle_packet(const struct sr_dev_inst *sdi)
/* Current */ /* Current */
l = g_slist_copy(sdi->channels); l = g_slist_copy(sdi->channels);
l = g_slist_remove_link(l, g_slist_nth(l, 0)); l = g_slist_remove_link(l, g_slist_nth(l, 0));
analog.channels = l; meaning.channels = l;
analog.mq = SR_MQ_CURRENT; meaning.mq = SR_MQ_CURRENT;
analog.mqflags = SR_MQFLAG_DC; meaning.mqflags = SR_MQFLAG_DC;
analog.unit = SR_UNIT_AMPERE; meaning.unit = SR_UNIT_AMPERE;
analog.data = &current; analog.data = &current;
sr_session_send(sdi, &packet); sr_session_send(sdi, &packet);
g_slist_free(l); g_slist_free(l);
/* End frame. */ /* End frame. */
packet.type = SR_DF_FRAME_END; packet.type = SR_DF_FRAME_END;
packet.payload = NULL;
sr_session_send(sdi, &packet); sr_session_send(sdi, &packet);
devc->num_samples++; devc->num_samples++;