diff options
author | NosDE <marco@wtns.de> | 2015-03-06 22:26:32 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2015-03-07 11:39:00 +0100 |
commit | 04f4206371a76d9a3f4ed448e212f878d7fc1b09 (patch) | |
tree | 85511dc3baf1631e14ca5aec548fe3301ccd78e5 /unittests/sumd_test.cpp | |
parent | 332d42b105e58e65c3e1b7eca086b75c21acabeb (diff) | |
download | px4-firmware-04f4206371a76d9a3f4ed448e212f878d7fc1b09.tar.gz px4-firmware-04f4206371a76d9a3f4ed448e212f878d7fc1b09.tar.bz2 px4-firmware-04f4206371a76d9a3f4ed448e212f878d7fc1b09.zip |
Graupner HoTT SUMD/SUMH Receiver Protocol added
Diffstat (limited to 'unittests/sumd_test.cpp')
-rw-r--r-- | unittests/sumd_test.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/unittests/sumd_test.cpp b/unittests/sumd_test.cpp new file mode 100644 index 000000000..a919de31b --- /dev/null +++ b/unittests/sumd_test.cpp @@ -0,0 +1,63 @@ +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <systemlib/err.h> +#include <drivers/drv_hrt.h> +#include <rc/sumd.h> +#include "../../src/systemcmds/tests/tests.h" + +#include "gtest/gtest.h" + +TEST(SUMDTest, SUMD) { + const char* filepath = "testdata/sumd_data.txt"; + + warnx("loading data from: %s", filepath); + + FILE *fp; + + fp = fopen(filepath, "rt"); + //ASSERT_TRUE(fp); + + float f; + unsigned x; + int ret; + + // Trash the first 20 lines + for (unsigned i = 0; i < 20; i++) { + char buf[200]; + (void)fgets(buf, sizeof(buf), fp); + } + + float last_time = 0; + + while (EOF != (ret = fscanf(fp, "%f,%x,,", &f, &x))) { + if (((f - last_time) * 1000 * 1000) > 3000) { + // warnx("FRAME RESET\n\n"); + } + + uint8_t b = static_cast<uint8_t>(x); + + last_time = f; + + // Pipe the data into the parser + hrt_abstime now = hrt_absolute_time(); + + uint8_t rssi; + uint8_t rx_count; + uint16_t channel_count; + uint16_t channels[32]; + + + if (!sumd_decode(b, &rssi, &rx_count, &channel_count, channels, 32)) { + //warnx("decoded: %u channels (converted to PPM range)", (unsigned)channel_count); + + for (unsigned i = 0; i < channel_count; i++) { + + int16_t val = channels[i]; + //warnx("channel %u: %d 0x%03X", i, static_cast<int>(val), static_cast<int>(val)); + } + } + } + + ASSERT_EQ(EOF, ret); +} |