From 55ebbcbdbc6d9513012a60a143c92eddb90f631d Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 6 Mar 2020 12:39:21 +0100 Subject: Finish DSSS demodulation stage 1 --- controller/fw/tools/dsss_demod_test.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'controller/fw/tools') diff --git a/controller/fw/tools/dsss_demod_test.c b/controller/fw/tools/dsss_demod_test.c index 51742b1..4370f80 100644 --- a/controller/fw/tools/dsss_demod_test.c +++ b/controller/fw/tools/dsss_demod_test.c @@ -13,11 +13,11 @@ #include "dsss_demod.h" void print_usage() { - fprintf(stderr, "Usage: dsss_demod_test [test_data.bin]\n"); + fprintf(stderr, "Usage: dsss_demod_test [test_data.bin] [optional recording channel number]\n"); } int main(int argc, char **argv) { - if (argc != 2) { + if (argc != 2 && argc != 3) { fprintf(stderr, "Error: Invalid arguments.\n"); print_usage(); return 1; @@ -46,7 +46,18 @@ int main(int argc, char **argv) { return 2; } - fprintf(stderr, "Reading %zd samples test data...", st.st_size/sizeof(float)); + int record_channel = -1; + if (argc == 3) { + char *endptr; + record_channel = strtoul(argv[2], &endptr, 10); + if (!endptr || *endptr != '\0') { + fprintf(stderr, "Invalid channel number \"%s\"\n", argv[2]); + return 1; + } + } + + if (record_channel != -1) + fprintf(stderr, "Reading %zd samples test data...", st.st_size/sizeof(float)); size_t nread = 0; while (nread < st.st_size) { ssize_t rc = read(fd, buf, st.st_size - nread); @@ -66,18 +77,20 @@ int main(int argc, char **argv) { nread += rc; } - fprintf(stderr, " done.\n"); + if (record_channel != -1) + fprintf(stderr, " done.\n"); const size_t n_samples = st.st_size / sizeof(float); float *buf_f = (float *)buf; - fprintf(stderr, "Starting simulation.\n"); + if (record_channel != -1) + fprintf(stderr, "Starting simulation.\n"); struct dsss_demod_state demod; memset(&demod, 0, sizeof(demod)); for (size_t i=0; i