]> sigrok.org Git - libsigrok.git/commitdiff
transform/invert: Support SR_DF_ANALOG2.
authorMartin Ling <redacted>
Wed, 9 Sep 2015 22:57:18 +0000 (23:57 +0100)
committerUwe Hermann <redacted>
Tue, 20 Oct 2015 21:32:45 +0000 (23:32 +0200)
src/transform/invert.c

index 14a92fb76e30791dd2a3278cfeef10803c5ef5d6..98d2240ed961376bdc8ef577fc5a3a52355f66e2 100644 (file)
@@ -31,12 +31,14 @@ static int receive(const struct sr_transform *t,
 {
        const struct sr_datafeed_logic *logic;
        const struct sr_datafeed_analog *analog;
+       const struct sr_datafeed_analog2 *analog2;
        struct sr_channel *ch;
        GSList *l;
        float *fdata, *f;
        int si, num_channels, c;
        uint8_t *b;
-       uint64_t i, j;
+       int64_t p;
+       uint64_t i, j, q;
 
        if (!t || !t->sdi || !packet_in || !packet_out)
                return SR_ERR_ARG;
@@ -66,6 +68,15 @@ 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;
+               if (q > INT64_MAX)
+                       return SR_ERR;
+               analog2->encoding->scale.p = (p < 0) ? -q : q;
+               analog2->encoding->scale.q = (p < 0) ? -p : p;
+               break;
        default:
                sr_spew("Unsupported packet type %d, ignoring.", packet_in->type);
                break;