From 478c6bfca3a1c6f56e26530c24e7283d99a6b974 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 13 Apr 2018 23:03:46 +0000 Subject: [PATCH] horus_demod compiles without warning, but not tested and debugged yet git-svn-id: https://svn.code.sf.net/p/freetel/code@3481 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/CMakeLists.txt | 4 ++++ codec2-dev/src/horus_api.c | 10 +++++++--- codec2-dev/src/horus_demod.c | 6 +++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/codec2-dev/src/CMakeLists.txt b/codec2-dev/src/CMakeLists.txt index 2cb6fc79..bd3dcd93 100644 --- a/codec2-dev/src/CMakeLists.txt +++ b/codec2-dev/src/CMakeLists.txt @@ -379,6 +379,10 @@ target_link_libraries(drs232 ${CMAKE_REQUIRED_LIBRARIES}) add_executable(drs232_ldpc drs232_ldpc.c mpdecode_core.c) target_link_libraries(drs232_ldpc ${CMAKE_REQUIRED_LIBRARIES}) +add_definitions(-DHORUS_L2_RX -DINTERLEAVER -DSCRAMBLER) +add_executable(horus_demod horus_demod.c horus_api.c horus_l2.c fsk.c kiss_fft.c) +target_link_libraries(horus_demod ${CMAKE_REQUIRED_LIBRARIES}) + install(TARGETS codec2 EXPORT codec2-config LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/codec2-dev/src/horus_api.c b/codec2-dev/src/horus_api.c index d6f2851f..037eac2b 100644 --- a/codec2-dev/src/horus_api.c +++ b/codec2-dev/src/horus_api.c @@ -152,7 +152,7 @@ int horus_find_uw(struct horus *hstates) { corr = 0; for(j=0; juw_len; j++) { - corr += hstates->rx_bits[i+j]*hstates->uw[j]; + corr += rx_bits_mapped[i+j]*hstates->uw[j]; } /* peak pick maximum */ @@ -208,7 +208,7 @@ int extract_horus_rtty(struct horus *hstates, char ascii_out[], int uw_loc) { if (!endpacket && (char_dec == 42)) { endpacket = 1; - rx_crc = horus_l2_gen_crc16(ascii_out, nout); + rx_crc = horus_l2_gen_crc16((uint8_t*)ascii_out, nout); ptx_crc = pout + 2; /* start of tx CRC */ } @@ -284,7 +284,8 @@ int horus_rx(struct horus *hstates, char ascii_out[], short demod_in[]) { int i, j, uw_loc, valid_packet; assert(hstates != NULL); - + valid_packet = 0; + /* shift buffer of bits to make room for new bits */ int Nbits = hstates->fsk->Nbits; @@ -345,12 +346,15 @@ int horus_get_max_demod_in(struct horus *hstates) { } int horus_get_max_ascii_out_len(struct horus *hstates) { + assert(hstates != NULL); if (hstates->mode == HORUS_MODE_RTTY) { return hstates->max_packet_len/10; /* 7 bit ASCII, plus 3 sync bits */ } if (hstates->mode == HORUS_MODE_BINARY) { return HORUS_BINARY_NUM_PAYLOAD_BYTES; } + assert(0); /* should never get here */ + return 0; } void horus_get_modem_stats(struct horus *hstates, int *sync, float *snr_est) { diff --git a/codec2-dev/src/horus_demod.c b/codec2-dev/src/horus_demod.c index 65216d42..9fe95d96 100644 --- a/codec2-dev/src/horus_demod.c +++ b/codec2-dev/src/horus_demod.c @@ -49,7 +49,8 @@ int main(int argc, char *argv[]) { stats_loop = 0; stats_rate = 8; - + mode = -1; + int o = 0; int opt_idx = 0; while ( o != -1 ) { @@ -64,14 +65,13 @@ int main(int argc, char *argv[]) { switch(o) { case 'm': - mode = -1; if ((strcmp(optarg, "RTTY") == 0) || (strcmp(optarg, "rtty") == 0)) { mode = HORUS_MODE_RTTY; } if ((strcmp(optarg, "BINARY") == 0) || (strcmp(optarg, "binary") == 0)) { mode = HORUS_MODE_BINARY; } - if (mode = -1) { + if (mode == -1) { fprintf(stderr, "use --mode RTTY or --mode binary\n"); exit(1); } -- 2.25.1