From 50998fcfb916ae251309bd4b464f2c122e8cb30d Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 9 Apr 2021 18:38:02 +0200 Subject: Repo re-org --- controller/fw/tools/freq_meas_test.c | 106 ----------------------------------- 1 file changed, 106 deletions(-) delete mode 100644 controller/fw/tools/freq_meas_test.c (limited to 'controller/fw/tools/freq_meas_test.c') diff --git a/controller/fw/tools/freq_meas_test.c b/controller/fw/tools/freq_meas_test.c deleted file mode 100644 index e2900ad..0000000 --- a/controller/fw/tools/freq_meas_test.c +++ /dev/null @@ -1,106 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "freq_meas.h" - -void print_usage(void); - -void print_usage() { - fprintf(stderr, "Usage: freq_meas_test [test_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 > 1000000) { - fprintf(stderr, "Error reading test data: too much test data (size=%zd)\n", st.st_size); - return 2; - } - - if (st.st_size % sizeof(float) != 0) { - fprintf(stderr, "Error reading test data: file size is not divisible by %zd (size=%zd)\n", sizeof(float), st.st_size); - return 2; - } - - char *buf = malloc(st.st_size); - if (!buf) { - fprintf(stderr, "Error allocating memory"); - return 2; - } - - fprintf(stderr, "Reading %zd samples test data...", st.st_size/sizeof(float)); - 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.\n"); - - const size_t n_samples = st.st_size / sizeof(float); - float *buf_f = (float *)buf; - - int16_t *sim_adc_buf = calloc(sizeof(int16_t), n_samples); - if (!sim_adc_buf) { - fprintf(stderr, "Error allocating memory\n"); - return 2; - } - - fprintf(stderr, "Converting and truncating test data..."); - for (size_t i=0; i