diff --git a/blocks/Makefile b/blocks/Makefile index d13cbad..93137ac 100644 --- a/blocks/Makefile +++ b/blocks/Makefile @@ -1,4 +1,4 @@ -all: .depends costas-beacon-sync.o fft-beacon-finder.o +all: .depends test CXX=clang++ CXXFLAGS=-Wall @@ -10,6 +10,9 @@ LDFLAGS=-lliquid %.o : %.cpp $(CXX) $(CFLAGS) -c $< -o $@ +test: test.o costas-beacon-sync.o fft-beacon-finder.o + $(CXX) $(LDFLAGS) -o $@ $? + clean: rm *.o diff --git a/blocks/fft-beacon-finder.cpp b/blocks/fft-beacon-finder.cpp index d4f710f..f826952 100644 --- a/blocks/fft-beacon-finder.cpp +++ b/blocks/fft-beacon-finder.cpp @@ -34,7 +34,6 @@ std::complex FFTBeaconFinder::work(std::complex in) { int center_idx = spectral_bin_to_fft_idx(bin); float center_val = std::abs(fft_out[center_idx]) / fft_max; if (center_val > 0.25) { - printf("Found peak candidate at %d\n", bin); int left_idx = spectral_bin_to_fft_idx(bin - 127); int right_idx = spectral_bin_to_fft_idx(bin + 127); float left_val = std::abs(fft_out[left_idx]) / fft_max; @@ -49,7 +48,6 @@ std::complex FFTBeaconFinder::work(std::complex in) { if (max_levels > 0.0) { float center_freq = max_center * samplingrate / FFT_LEN; - printf("Found center at %f\n", center_freq); nco_crcf_set_frequency( coarse_correction, -(2 * M_PI * center_freq) / samplingrate); diff --git a/blocks/test.cpp b/blocks/test.cpp new file mode 100644 index 0000000..fdf6240 --- /dev/null +++ b/blocks/test.cpp @@ -0,0 +1,29 @@ +#include + +#include + +#include "fft-beacon-finder.h" +#include "costas-beacon-sync.h" + +int main(int argc, char const *argv[]) { + + FILE* output = fopen("output.raw", "w"); + FILE* input = fopen("input.raw", "r"); + + FFTBeaconFinder finder(1000000); + CostasBeaconSync sync(1e-3f, 0.3, -1.0, 1.0); + + std::complex in; + while(fread(&in, sizeof(std::complex), 1, input) == 1) { + std::complex coarse_synced = finder.work(in); + std::complex sync_correction = sync.work(coarse_synced); + std::complex out = coarse_synced * sync_correction; + + fwrite(&out, sizeof(std::complex), 1, output); + }; + + fclose(input); + fclose(output); + + return 0; +}