]> sigrok.org Git - libsigrok.git/commitdiff
sr_analog_to_float: Fix byte reordering.
authorMartin Ling <redacted>
Thu, 17 Sep 2015 01:04:19 +0000 (02:04 +0100)
committerUwe Hermann <redacted>
Sun, 20 Sep 2015 22:32:25 +0000 (00:32 +0200)
src/analog.c

index 61f1f733aaa8bdc7bd9433d42c4cc5ff7df5429f..6266379dcd603dd5f0e02ec940e7dde6fdfe6944 100644 (file)
@@ -179,9 +179,11 @@ SR_API int sr_analog_to_float(const struct sr_datafeed_analog2 *analog,
                for (i = 0; i < analog->num_samples; i += analog->encoding->unitsize) {
                        for (b = 0; b < analog->encoding->unitsize; b++) {
                                if (analog->encoding->is_bigendian == bigendian)
-                                       outbuf[i + b] = ((float *)analog->data)[i * analog->encoding->unitsize + b];
+                                       ((uint8_t *)outbuf)[i + b] =
+                                               ((uint8_t *)analog->data)[i * analog->encoding->unitsize + b];
                                else
-                                       outbuf[i + (analog->encoding->unitsize - b)] = ((float *)analog->data)[i * analog->encoding->unitsize + b];
+                                       ((uint8_t *)outbuf)[i + (analog->encoding->unitsize - b)] =
+                                               ((uint8_t *)analog->data)[i * analog->encoding->unitsize + b];
                        }
                        if (analog->encoding->scale.p != analog->encoding->scale.q)
                                outbuf[i] = (outbuf[i] * analog->encoding->scale.p) / analog->encoding->scale.q;