summaryrefslogtreecommitdiff
path: root/controller/fw/tools/dsss_demod_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'controller/fw/tools/dsss_demod_test.c')
-rw-r--r--controller/fw/tools/dsss_demod_test.c25
1 files changed, 19 insertions, 6 deletions
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<n_samples; i++) {
//fprintf(stderr, "Iteration %zd/%zd\n", i, n_samples);
- dsss_demod_step(&demod, buf_f[i], i);
+ dsss_demod_step(&demod, buf_f[i], i, record_channel);
}
return 0;