summaryrefslogtreecommitdiff
path: root/controller/fw/tools
diff options
context:
space:
mode:
authorjaseg <git-bigdata-wsl-arch@jaseg.de>2020-03-06 12:39:21 +0100
committerjaseg <git-bigdata-wsl-arch@jaseg.de>2020-03-06 12:39:21 +0100
commit55ebbcbdbc6d9513012a60a143c92eddb90f631d (patch)
tree3a561fc6c1858eeee93ad2a086a774587b9ab0a3 /controller/fw/tools
parente4693349cf862f8c609a0a7586b24d703486fff9 (diff)
downloadmaster-thesis-55ebbcbdbc6d9513012a60a143c92eddb90f631d.tar.gz
master-thesis-55ebbcbdbc6d9513012a60a143c92eddb90f631d.tar.bz2
master-thesis-55ebbcbdbc6d9513012a60a143c92eddb90f631d.zip
Finish DSSS demodulation stage 1
Diffstat (limited to 'controller/fw/tools')
-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;