From 7b85ba8d4fb34e76d34a2d581e89e856aa471cf5 Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 21 Dec 2020 16:26:57 +0100 Subject: Move fw into direct subdir --- fw/hid-dials/tools/e2e_test.c | 111 ------------------------------------------ 1 file changed, 111 deletions(-) delete mode 100644 fw/hid-dials/tools/e2e_test.c (limited to 'fw/hid-dials/tools/e2e_test.c') diff --git a/fw/hid-dials/tools/e2e_test.c b/fw/hid-dials/tools/e2e_test.c deleted file mode 100644 index 935f70d..0000000 --- a/fw/hid-dials/tools/e2e_test.c +++ /dev/null @@ -1,111 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "freq_meas.h" -#include "dsss_demod.h" - -typedef uint16_t adc_data_t; - -void handle_dsss_received(uint8_t data[static TRANSMISSION_SYMBOLS]) { - printf("data sequence received: [ "); - for (size_t i=0; i>1)); - if (i+1 < TRANSMISSION_SYMBOLS) - printf(", "); - } - printf(" ]\n"); -} - -void print_usage(void); -void print_usage() { - fprintf(stderr, "Usage: e2e_test [emulated_adc_data.bin]\n"); -} - -int main(int argc, char **argv) { - if (argc != 2) { - fprintf(stderr, "Error: Invalid arguments.\n"); - print_usage(); - return 1; - } - - int fd = open(argv[1], O_RDONLY); - struct stat st; - if (fstat(fd, &st)) { - fprintf(stderr, "Error querying test data file size: %s\n", strerror(errno)); - return 2; - } - - if (st.st_size < 0 || st.st_size > 100000000) { - fprintf(stderr, "Error reading test data: too much test data (size=%zd)\n", st.st_size); - return 2; - } - - if (st.st_size % sizeof(adc_data_t) != 0) { - fprintf(stderr, "Error reading test data: file size is not divisible by %zd (size=%zd)\n", sizeof(adc_data_t), st.st_size); - return 2; - } - - char *buf = malloc(st.st_size); - if (!buf) { - fprintf(stderr, "Error allocating memory"); - return 2; - } - - const size_t n_samples = st.st_size / sizeof(adc_data_t); - fprintf(stderr, "Reading %zd samples test data...", n_samples); - ssize_t nread = 0; - while (nread < st.st_size) { - ssize_t rc = read(fd, buf + nread, st.st_size - nread); - - if (rc == -EINTR || rc == -EAGAIN) - continue; - - if (rc < 0) { - fprintf(stderr, "\nError reading test data: %s\n", strerror(errno)); - return 2; - } - - if (rc == 0) { - fprintf(stderr, "\nError reading test data: Unexpected end of file\n"); - return 2; - } - - nread += rc; - } - fprintf(stderr, " done. Read %zd bytes.\n", nread); - - adc_data_t *buf_d = (adc_data_t *)buf; - - struct dsss_demod_state demod; - dsss_demod_init(&demod); - - fprintf(stderr, "Starting simulation.\n"); - size_t iterations = (n_samples-FMEAS_FFT_LEN)/(FMEAS_FFT_LEN/2); - for (size_t i=0; i