]> sigrok.org Git - libsigrok.git/commitdiff
SR_DF_ANALOG2 and sr_datafeed_analog2 renames.
authorUwe Hermann <redacted>
Tue, 29 Sep 2015 16:34:55 +0000 (18:34 +0200)
committerUwe Hermann <redacted>
Tue, 20 Oct 2015 21:32:45 +0000 (23:32 +0200)
Rename SR_DF_ANALOG2 to SR_DF_ANALOG, and 'struct sr_datafeed_analog2'
to 'struct sr_datafeed_analog'.

12 files changed:
include/libsigrok/libsigrok.h
include/libsigrok/proto.h
src/analog.c
src/hardware/mic-985xx/protocol.c
src/hardware/victor-dmm/protocol.c
src/libsigrok-internal.h
src/output/analog.c
src/output/csv.c
src/output/wav.c
src/session.c
src/transform/invert.c
src/transform/scale.c

index a497e8cffbb702ac37f65e4f967b24e9ff650e4f..69d88d19d7b8505bbc660dbdb904b68e4b8daf19 100644 (file)
@@ -168,13 +168,13 @@ enum sr_packettype {
        SR_DF_FRAME_BEGIN,
        /** End of frame. No payload. */
        SR_DF_FRAME_END,
-       /** Payload is struct sr_datafeed_analog2. */
-       SR_DF_ANALOG2,
+       /** Payload is struct sr_datafeed_analog. */
+       SR_DF_ANALOG,
 
        /* Update datafeed_dump() (session.c) upon changes! */
 };
 
-/** Measured quantity, sr_datafeed_analog.mq. */
+/** Measured quantity, sr_analog_meaning.mq. */
 enum sr_mq {
        SR_MQ_VOLTAGE = 10000,
        SR_MQ_CURRENT,
@@ -237,7 +237,7 @@ enum sr_mq {
        /* Update sr_key_info_mq[] (hwdriver.c) upon changes! */
 };
 
-/** Unit of measured quantity, sr_datafeed_analog.unit. */
+/** Unit of measured quantity, sr_analog_meaning.unit. */
 enum sr_unit {
        /** Volt */
        SR_UNIT_VOLT = 10000,
@@ -331,7 +331,7 @@ enum sr_unit {
         */
 };
 
-/** Values for sr_datafeed_analog.flags. */
+/** Values for sr_analog_meaning.mqflags. */
 enum sr_mqflag {
        /** Voltage measurement is alternating current (AC). */
        SR_MQFLAG_AC = 0x01,
@@ -512,8 +512,8 @@ struct sr_datafeed_analog_old {
        float *data;
 };
 
-/** Analog datafeed payload for type SR_DF_ANALOG2. */
-struct sr_datafeed_analog2 {
+/** Analog datafeed payload for type SR_DF_ANALOG. */
+struct sr_datafeed_analog {
        void *data;
        uint32_t num_samples;
        struct sr_analog_encoding *encoding;
index d42967fcbd66cfa73b1f9797220c4e6aee7ea0bb..1b5eec7a73979aec4952b994989c782b72fef304 100644 (file)
 
 /*--- analog.c --------------------------------------------------------------*/
 
-SR_API int sr_analog_to_float(const struct sr_datafeed_analog2 *analog,
+SR_API int sr_analog_to_float(const struct sr_datafeed_analog *analog,
                float *buf);
 SR_API int sr_analog_float_to_string(float value, int digits, char **result);
-SR_API int sr_analog_unit_to_string(const struct sr_datafeed_analog2 *analog,
+SR_API int sr_analog_unit_to_string(const struct sr_datafeed_analog *analog,
                char **result);
 SR_API void sr_rational_set(struct sr_rational *r, int64_t p, uint64_t q);
 
index dd23d4b48cf5f5f53fe95575159c871c6c34b3a9..39bf2fce8d4b1a6eaea1491edd11517076cda4bc 100644 (file)
@@ -117,7 +117,7 @@ static struct unit_mq_string mq_strings[] = {
        ALL_ZERO
 };
 
-SR_PRIV int sr_analog_init(struct sr_datafeed_analog2 *analog,
+SR_PRIV int sr_analog_init(struct sr_datafeed_analog *analog,
                struct sr_analog_encoding *encoding,
                struct sr_analog_meaning *meaning,
                struct sr_analog_spec *spec,
@@ -151,7 +151,7 @@ SR_PRIV int sr_analog_init(struct sr_datafeed_analog2 *analog,
        return SR_OK;
 }
 
-SR_API int sr_analog_to_float(const struct sr_datafeed_analog2 *analog,
+SR_API int sr_analog_to_float(const struct sr_datafeed_analog *analog,
                float *outbuf)
 {
        float offset;
@@ -245,7 +245,7 @@ SR_API int sr_analog_float_to_string(float value, int digits, char **result)
  *
  * @since 0.4.0
  */
-SR_API int sr_analog_unit_to_string(const struct sr_datafeed_analog2 *analog,
+SR_API int sr_analog_unit_to_string(const struct sr_datafeed_analog *analog,
                char **result)
 {
        int i;
index d7c69d0e315c9e49ae6e85fcc736e34886941a26..4ee11b70c8e3ce2e626570487e82db5298db0d9f 100644 (file)
@@ -95,7 +95,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
 {
        float temperature, humidity;
        struct sr_datafeed_packet packet;
-       struct sr_datafeed_analog2 analog;
+       struct sr_datafeed_analog analog;
        struct sr_analog_encoding encoding;
        struct sr_analog_meaning meaning;
        struct sr_analog_spec spec;
@@ -116,7 +116,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
        sr_analog_init(&analog, &encoding, &meaning, &spec, 3);
 
        /* Common values for both channels. */
-       packet.type = SR_DF_ANALOG2;
+       packet.type = SR_DF_ANALOG;
        packet.payload = &analog;
        analog.num_samples = 1;
 
index d8d2b51d8a6e24fdd1df1bc60b3fa1ab9c581a0f..b0eb384ad24d306f0b917bab8ae17799e25feb64 100644 (file)
@@ -44,7 +44,7 @@ static uint8_t decode_digit(uint8_t in)
 static void decode_buf(struct sr_dev_inst *sdi, unsigned char *data)
 {
        struct sr_datafeed_packet packet;
-       struct sr_datafeed_analog2 analog;
+       struct sr_datafeed_analog analog;
        struct sr_analog_encoding encoding;
        struct sr_analog_meaning meaning;
        struct sr_analog_spec spec;
@@ -260,7 +260,7 @@ static void decode_buf(struct sr_dev_inst *sdi, unsigned char *data)
        analog.data = &fvalue;
        analog.num_samples = 1;
 
-       packet.type = SR_DF_ANALOG2;
+       packet.type = SR_DF_ANALOG;
        packet.payload = &analog;
        sr_session_send(devc->cb_data, &packet);
 
index 89ff993f3d5129e02a41b1c75fc3c51e76d14c5e..d35669e06005324d0fb993a99d1d78ac7ffd62bf 100644 (file)
@@ -759,7 +759,7 @@ SR_PRIV GKeyFile *sr_sessionfile_read_metadata(struct zip *archive,
 
 /*--- analog.c --------------------------------------------------------------*/
 
-SR_PRIV int sr_analog_init(struct sr_datafeed_analog2 *analog,
+SR_PRIV int sr_analog_init(struct sr_datafeed_analog *analog,
                            struct sr_analog_encoding *encoding,
                            struct sr_analog_meaning *meaning,
                            struct sr_analog_spec *spec,
index e2667fd84fec9a82b8d75ef7141d5359570bc63b..4535ed5ca76267ef75cd07829b2bbc381ad78a8a 100644 (file)
@@ -279,7 +279,7 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
 {
        struct context *ctx;
        const struct sr_datafeed_analog_old *analog_old;
-       const struct sr_datafeed_analog2 *analog2;
+       const struct sr_datafeed_analog *analog;
        struct sr_channel *ch;
        GSList *l;
        float *fdata;
@@ -313,27 +313,27 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
                        }
                }
                break;
-       case SR_DF_ANALOG2:
-               analog2 = packet->payload;
-               num_channels = g_slist_length(analog2->meaning->channels);
+       case SR_DF_ANALOG:
+               analog = packet->payload;
+               num_channels = g_slist_length(analog->meaning->channels);
                if (!(fdata = g_try_malloc(
-                                               analog2->num_samples * num_channels * sizeof(float))))
+                                               analog->num_samples * num_channels * sizeof(float))))
                        return SR_ERR_MALLOC;
-               if ((ret = sr_analog_to_float(analog2, fdata)) != SR_OK)
+               if ((ret = sr_analog_to_float(analog, fdata)) != SR_OK)
                        return ret;
                *out = g_string_sized_new(512);
-               if (analog2->encoding->is_digits_decimal) {
+               if (analog->encoding->is_digits_decimal) {
                        if (ctx->digits == DIGITS_ALL)
-                               digits = analog2->encoding->digits;
+                               digits = analog->encoding->digits;
                        else
-                               digits = analog2->spec->spec_digits;
+                               digits = analog->spec->spec_digits;
                } else {
                        /* TODO we don't know how to print by number of bits yet. */
                        digits = 6;
                }
-               sr_analog_unit_to_string(analog2, &suffix);
-               for (i = 0; i < analog2->num_samples; i++) {
-                       for (l = analog2->meaning->channels, c = 0; l; l = l->next, c++) {
+               sr_analog_unit_to_string(analog, &suffix);
+               for (i = 0; i < analog->num_samples; i++) {
+                       for (l = analog->meaning->channels, c = 0; l; l = l->next, c++) {
                                ch = l->data;
                                g_string_append_printf(*out, "%s: ", ch->name);
                                sr_analog_float_to_string(fdata[i * num_channels + c],
index 250e6cf475ce693f1a1e01cbcf4c1df78f76e991..db023a476050c59ffdb88ef144c8a84377413442 100644 (file)
@@ -193,7 +193,7 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
        const struct sr_datafeed_meta *meta;
        const struct sr_datafeed_logic *logic;
        const struct sr_datafeed_analog_old *analog_old;
-       const struct sr_datafeed_analog2 *analog2;
+       const struct sr_datafeed_analog *analog;
        const struct sr_config *src;
        unsigned int num_samples;
        float *data;
@@ -269,9 +269,9 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
                }
                break;
        case SR_DF_ANALOG_OLD:
-       case SR_DF_ANALOG2:
+       case SR_DF_ANALOG:
                analog_old = packet->payload;
-               analog2 = packet->payload;
+               analog = packet->payload;
 
                if (packet->type == SR_DF_ANALOG_OLD) {
                        channels = analog_old->channels;
@@ -279,11 +279,11 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
                        num_samples = analog_old->num_samples;
                        data = analog_old->data;
                } else {
-                       channels = analog2->meaning->channels;
+                       channels = analog->meaning->channels;
                        numch = g_slist_length(channels);
-                       num_samples = analog2->num_samples;
+                       num_samples = analog->num_samples;
                        data = g_malloc(sizeof(float) * num_samples * numch);
-                       ret = sr_analog_to_float(analog2, data);
+                       ret = sr_analog_to_float(analog, data);
                        if (ret != SR_OK)
                                return ret;
                }
index 212574da5abb8fb45009d85ec29794b0dcbb0328..507e0e77b53700ad2e9ac71cac01b3730a008e34 100644 (file)
@@ -237,7 +237,7 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
        struct out_context *outc;
        const struct sr_datafeed_meta *meta;
        const struct sr_datafeed_analog_old *analog_old;
-       const struct sr_datafeed_analog2 *analog2;
+       const struct sr_datafeed_analog *analog;
        const struct sr_config *src;
        struct sr_channel *ch;
        GSList *l;
@@ -262,7 +262,7 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
                }
                break;
        case SR_DF_ANALOG_OLD:
-       case SR_DF_ANALOG2:
+       case SR_DF_ANALOG:
                if (!outc->header_done) {
                        *out = gen_header(o);
                        outc->header_done = TRUE;
@@ -270,7 +270,7 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
                        *out = g_string_sized_new(512);
 
                analog_old = packet->payload;
-               analog2 = packet->payload;
+               analog = packet->payload;
 
                if (packet->type == SR_DF_ANALOG_OLD) {
                        num_samples = analog_old->num_samples;
@@ -278,11 +278,11 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
                        num_channels = g_slist_length(analog_old->channels);
                        data = analog_old->data;
                } else {
-                       num_samples = analog2->num_samples;
-                       channels = analog2->meaning->channels;
-                       num_channels = g_slist_length(analog2->meaning->channels);
+                       num_samples = analog->num_samples;
+                       channels = analog->meaning->channels;
+                       num_channels = g_slist_length(analog->meaning->channels);
                        data = g_malloc(sizeof(float) * num_samples * num_channels);
-                       ret = sr_analog_to_float(analog2, data);
+                       ret = sr_analog_to_float(analog, data);
                        if (ret != SR_OK)
                                return ret;
                }
index 4b3379f38623ecbb513069d591c3ac63674de3f8..c84edcbfdb27ed0c9119727dbf00ba2c5db40b07 100644 (file)
@@ -1001,7 +1001,7 @@ static void datafeed_dump(const struct sr_datafeed_packet *packet)
 {
        const struct sr_datafeed_logic *logic;
        const struct sr_datafeed_analog_old *analog_old;
-       const struct sr_datafeed_analog2 *analog2;
+       const struct sr_datafeed_analog *analog;
 
        /* Please use the same order as in libsigrok.h. */
        switch (packet->type) {
@@ -1033,10 +1033,10 @@ static void datafeed_dump(const struct sr_datafeed_packet *packet)
        case SR_DF_FRAME_END:
                sr_dbg("bus: Received SR_DF_FRAME_END packet.");
                break;
-       case SR_DF_ANALOG2:
-               analog2 = packet->payload;
-               sr_dbg("bus: Received SR_DF_ANALOG2 packet (%d samples).",
-                      analog2->num_samples);
+       case SR_DF_ANALOG:
+               analog = packet->payload;
+               sr_dbg("bus: Received SR_DF_ANALOG packet (%d samples).",
+                      analog->num_samples);
                break;
        default:
                sr_dbg("bus: Received unknown packet type: %d.", packet->type);
@@ -1082,20 +1082,20 @@ SR_PRIV int sr_session_send(const struct sr_dev_inst *sdi,
        }
 
        if (packet->type == SR_DF_ANALOG_OLD) {
-               /* Convert to SR_DF_ANALOG2. */
+               /* Convert to SR_DF_ANALOG. */
                const struct sr_datafeed_analog_old *analog_old = packet->payload;
                struct sr_analog_encoding encoding;
                struct sr_analog_meaning meaning;
                struct sr_analog_spec spec;
-               struct sr_datafeed_analog2 analog2;
-               struct sr_datafeed_packet a2_packet;
-               a2_packet.type = SR_DF_ANALOG2;
-               a2_packet.payload = &analog2;
-               analog2.data = analog_old->data;
-               analog2.num_samples = analog_old->num_samples;
-               analog2.encoding = &encoding;
-               analog2.meaning = &meaning;
-               analog2.spec = &spec;
+               struct sr_datafeed_analog analog;
+               struct sr_datafeed_packet new_packet;
+               new_packet.type = SR_DF_ANALOG;
+               new_packet.payload = &analog;
+               analog.data = analog_old->data;
+               analog.num_samples = analog_old->num_samples;
+               analog.encoding = &encoding;
+               analog.meaning = &meaning;
+               analog.spec = &spec;
                encoding.unitsize = sizeof(float);
                encoding.is_signed = TRUE;
                encoding.is_float = TRUE;
@@ -1115,7 +1115,7 @@ SR_PRIV int sr_session_send(const struct sr_dev_inst *sdi,
                meaning.mqflags = analog_old->mqflags;
                meaning.channels = analog_old->channels;
                spec.spec_digits = 0;
-               return sr_session_send(sdi, &a2_packet);
+               return sr_session_send(sdi, &new_packet);
        }
 
        /*
@@ -1468,8 +1468,8 @@ SR_PRIV int sr_packet_copy(const struct sr_datafeed_packet *packet,
        struct sr_datafeed_logic *logic_copy;
        const struct sr_datafeed_analog_old *analog_old;
        struct sr_datafeed_analog_old *analog_old_copy;
-       const struct sr_datafeed_analog2 *analog2;
-       struct sr_datafeed_analog2 *analog2_copy;
+       const struct sr_datafeed_analog *analog;
+       struct sr_datafeed_analog *analog_copy;
        uint8_t *payload;
 
        *copy = g_malloc0(sizeof(struct sr_datafeed_packet));
@@ -1512,23 +1512,23 @@ SR_PRIV int sr_packet_copy(const struct sr_datafeed_packet *packet,
                                analog_old->num_samples * sizeof(float));
                (*copy)->payload = analog_old_copy;
                break;
-       case SR_DF_ANALOG2:
-               analog2 = packet->payload;
-               analog2_copy = g_malloc(sizeof(analog2));
-               analog2_copy->data = g_malloc(
-                               analog2->encoding->unitsize * analog2->num_samples);
-               memcpy(analog2_copy->data, analog2->data,
-                               analog2->encoding->unitsize * analog2->num_samples);
-               analog2_copy->num_samples = analog2->num_samples;
-               analog2_copy->encoding = g_memdup(analog2->encoding,
+       case SR_DF_ANALOG:
+               analog = packet->payload;
+               analog_copy = g_malloc(sizeof(analog));
+               analog_copy->data = g_malloc(
+                               analog->encoding->unitsize * analog->num_samples);
+               memcpy(analog_copy->data, analog->data,
+                               analog->encoding->unitsize * analog->num_samples);
+               analog_copy->num_samples = analog->num_samples;
+               analog_copy->encoding = g_memdup(analog->encoding,
                                sizeof(struct sr_analog_encoding));
-               analog2_copy->meaning = g_memdup(analog2->meaning,
+               analog_copy->meaning = g_memdup(analog->meaning,
                                sizeof(struct sr_analog_meaning));
-               analog2_copy->meaning->channels = g_slist_copy(
-                               analog2->meaning->channels);
-               analog2_copy->spec = g_memdup(analog2->spec,
+               analog_copy->meaning->channels = g_slist_copy(
+                               analog->meaning->channels);
+               analog_copy->spec = g_memdup(analog->spec,
                                sizeof(struct sr_analog_spec));
-               (*copy)->payload = analog2_copy;
+               (*copy)->payload = analog_copy;
                break;
        default:
                sr_err("Unknown packet type %d", packet->type);
@@ -1543,7 +1543,7 @@ void sr_packet_free(struct sr_datafeed_packet *packet)
        const struct sr_datafeed_meta *meta;
        const struct sr_datafeed_logic *logic;
        const struct sr_datafeed_analog_old *analog_old;
-       const struct sr_datafeed_analog2 *analog2;
+       const struct sr_datafeed_analog *analog;
        struct sr_config *src;
        GSList *l;
 
@@ -1577,13 +1577,13 @@ void sr_packet_free(struct sr_datafeed_packet *packet)
                g_free(analog_old->data);
                g_free((void *)packet->payload);
                break;
-       case SR_DF_ANALOG2:
-               analog2 = packet->payload;
-               g_free(analog2->data);
-               g_free(analog2->encoding);
-               g_slist_free(analog2->meaning->channels);
-               g_free(analog2->meaning);
-               g_free(analog2->spec);
+       case SR_DF_ANALOG:
+               analog = packet->payload;
+               g_free(analog->data);
+               g_free(analog->encoding);
+               g_slist_free(analog->meaning->channels);
+               g_free(analog->meaning);
+               g_free(analog->spec);
                g_free((void *)packet->payload);
                break;
        default:
index c1941d1a6d50edf7a413d5c23728f59b1cea564f..cb7f15d1e108193826fd3d668e1bddb38ed3efc5 100644 (file)
@@ -31,7 +31,7 @@ static int receive(const struct sr_transform *t,
 {
        const struct sr_datafeed_logic *logic;
        const struct sr_datafeed_analog_old *analog_old;
-       const struct sr_datafeed_analog2 *analog2;
+       const struct sr_datafeed_analog *analog;
        struct sr_channel *ch;
        GSList *l;
        float *fdata, *f;
@@ -68,14 +68,14 @@ static int receive(const struct sr_transform *t,
                        }
                }
                break;
-       case SR_DF_ANALOG2:
-               analog2 = packet_in->payload;
-               p = analog2->encoding->scale.p;
-               q = analog2->encoding->scale.q;
+       case SR_DF_ANALOG:
+               analog = packet_in->payload;
+               p = analog->encoding->scale.p;
+               q = analog->encoding->scale.q;
                if (q > INT64_MAX)
                        return SR_ERR;
-               analog2->encoding->scale.p = (p < 0) ? -q : q;
-               analog2->encoding->scale.q = (p < 0) ? -p : p;
+               analog->encoding->scale.p = (p < 0) ? -q : q;
+               analog->encoding->scale.q = (p < 0) ? -p : p;
                break;
        default:
                sr_spew("Unsupported packet type %d, ignoring.", packet_in->type);
index 47937be9e8985dfa5a84f5431e8da453cce88e4b..ae82ee3f2a43d1857f6c8f3055bd8a1c6ccb9c19 100644 (file)
@@ -50,7 +50,7 @@ static int receive(const struct sr_transform *t,
 {
        struct context *ctx;
        const struct sr_datafeed_analog_old *analog_old;
-       const struct sr_datafeed_analog2 *analog2;
+       const struct sr_datafeed_analog *analog;
        struct sr_channel *ch;
        GSList *l;
        float *fdata;
@@ -76,10 +76,10 @@ static int receive(const struct sr_transform *t,
                        }
                }
                break;
-       case SR_DF_ANALOG2:
-               analog2 = packet_in->payload;
-               analog2->encoding->scale.p *= ctx->factor.p;
-               analog2->encoding->scale.q *= ctx->factor.q;
+       case SR_DF_ANALOG:
+               analog = packet_in->payload;
+               analog->encoding->scale.p *= ctx->factor.p;
+               analog->encoding->scale.q *= ctx->factor.q;
                break;
        default:
                sr_spew("Unsupported packet type %d, ignoring.", packet_in->type);