Formatted ST24 test code

This commit is contained in:
Lorenz Meier
2014-10-07 09:54:20 +02:00
parent 7921184e40
commit 7e5910bdbf
+11 -12
View File
@@ -7,11 +7,13 @@
#include <rc/st24.h> #include <rc/st24.h>
#include "../../src/systemcmds/tests/tests.h" #include "../../src/systemcmds/tests/tests.h"
int main(int argc, char *argv[]) { int main(int argc, char *argv[])
{
warnx("ST24 test started"); warnx("ST24 test started");
if (argc < 2) if (argc < 2) {
errx(1, "Need a filename for the input file"); errx(1, "Need a filename for the input file");
}
warnx("loading data from: %s", argv[1]); warnx("loading data from: %s", argv[1]);
@@ -19,8 +21,9 @@ int main(int argc, char *argv[]) {
fp = fopen(argv[1], "rt"); fp = fopen(argv[1], "rt");
if (!fp) if (!fp) {
errx(1, "failed opening file"); errx(1, "failed opening file");
}
float f; float f;
unsigned x; unsigned x;
@@ -49,27 +52,23 @@ int main(int argc, char *argv[]) {
uint8_t rssi; uint8_t rssi;
uint8_t rx_count; uint8_t rx_count;
uint16_t channel_count; uint16_t channel_count;
int16_t channels[20]; uint16_t channels[20];
if (!st24_decode(b, &rssi, &rx_count, &channel_count, channels, sizeof(channels) / sizeof(channels[0]))) if (!st24_decode(b, &rssi, &rx_count, &channel_count, channels, sizeof(channels) / sizeof(channels[0]))) {
{ warnx("decoded: %u channels (converted to PPM range)", (unsigned)channel_count);
//warnx("decoded: %u channels", (unsigned)channel_count);
for (unsigned i = 0; i < channel_count; i++) { for (unsigned i = 0; i < channel_count; i++) {
int16_t val = channels[i]; int16_t val = channels[i];
// if (i == 6)
warnx("channel %u: %d 0x%03X", i, static_cast<int>(val), static_cast<int>(val)); warnx("channel %u: %d 0x%03X", i, static_cast<int>(val), static_cast<int>(val));
} }
// unsigned chan = 1;
// warnx("channel %u: %d", chan, static_cast<int>(channels[chan]));
} }
//warnx("%f: 0x%02x >> RSSI: %u #: %u", (double)f, x, static_cast<unsigned>(rssi), static_cast<unsigned>(rx_count));
} }
if (ret == EOF) { if (ret == EOF) {
warnx("Test finished, reached end of file"); warnx("Test finished, reached end of file");
} else { } else {
warnx("Test aborted, errno: %d", ret); warnx("Test aborted, errno: %d", ret);
} }