From d7b36f32c08f3cf55d6c7cdea08a42c9e5329ae8 Mon Sep 17 00:00:00 2001 From: EdFuentetaja Date: Sat, 1 Mar 2014 20:35:46 +0800 Subject: [PATCH] Parity errors in NIC are now ignored. Clean up the code to make it easier to understand. Now the logic to error correct the NIC makes more sense. --- check_nid.cpp | 109 -------------------------------------------- check_nid.h | 14 ------ dsd.h | 1 + dsd_frame.c | 29 +++++++----- dsd_main.c | 2 + p25p1_check_nid.cpp | 92 +++++++++++++++++++++++++++++++++++++ p25p1_check_nid.h | 24 ++++++++++ 7 files changed, 137 insertions(+), 134 deletions(-) delete mode 100644 check_nid.cpp delete mode 100644 check_nid.h create mode 100644 p25p1_check_nid.cpp create mode 100644 p25p1_check_nid.h diff --git a/check_nid.cpp b/check_nid.cpp deleted file mode 100644 index 299563b..0000000 --- a/check_nid.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include - -#include "check_nid.h" - - - -using namespace itpp; - -// Ideas taken from http://op25.osmocom.org/trac/wiki.png/browser/op25/gr-op25/lib/decoder_ff_impl.cc -// See also p25_training_guide.pdf page 48. -// See also tia-102-baaa-a-project_25-fdma-common_air_interface.pdf page 40. -// BCH encoder/decoder implementation from IT++. GNU GPL 3 license. - -itpp::BCH bch(63, 16, 11, "6 3 3 1 1 4 1 3 6 7 2 3 5 4 5 3", true); - -/** Convenience class to calculate the parity of the DUID values. Keeps a table with the expected outcomes - * for fast lookup. - */ -class ParityTable -{ -private: - unsigned char table[16]; - - unsigned char get_index(unsigned char x, unsigned char y) - { - return (x<<2) + y; - } - -public: - ParityTable() - { - for (unsigned int i=0; inac = strtol (nac, NULL, 2); - // DUID, 4 bits + // Read the DUID, 4 bits for (i = 0; i < 2; i++) { dibit = getDibit (opts, state); @@ -279,8 +279,7 @@ processFrame (dsd_opts * opts, dsd_state * state) index_bch_code++; } - // Now processing NID - index_bch_code = 0; + // Read the BCH data for error correction of NAC and DUID for (i = 0; i < 3; i++) { dibit = getDibit (opts, state); @@ -301,7 +300,7 @@ processFrame (dsd_opts * opts, dsd_state * state) index_bch_code++; } - // last bit is the parity bit + // Read the parity bit dibit = getDibit (opts, state); bch_code[index_bch_code] = 1 & (dibit >> 1); // bit 1 parity = (1 & dibit); // bit 0 @@ -316,15 +315,17 @@ processFrame (dsd_opts * opts, dsd_state * state) } if (strcmp(new_duid, duid) != 0) { // DUID fixed by error correction + //printf("Fixing DUID %s -> %s\n", duid, new_duid); duid[0] = new_duid[0]; duid[1] = new_duid[1]; state->debug_header_errors++; } } else { // Check of NID failed and unable to recover its value + //printf("NID error\n"); duid[0] = 'E'; duid[1] = 'E'; - state->debug_header_errors += 10; + state->debug_header_critical_errors ++; } } @@ -505,7 +506,9 @@ processFrame (dsd_opts * opts, dsd_state * state) openMbeOutFile (opts, state); } } - state->lastp25type = 0; + //state->lastp25type = 0; + // Guess that the state is LDU2 + state->lastp25type = 2; sprintf (state->fsubtype, "(LDU2) "); state->numtdulc = 0; processLDU2 (opts, state); @@ -524,7 +527,9 @@ processFrame (dsd_opts * opts, dsd_state * state) openMbeOutFile (opts, state); } } - state->lastp25type = 0; + //state->lastp25type = 0; + // Guess that the state is LDU1 + state->lastp25type = 1; sprintf (state->fsubtype, "(LDU1) "); state->numtdulc = 0; processLDU1 (opts, state); @@ -536,7 +541,9 @@ processFrame (dsd_opts * opts, dsd_state * state) printFrameInfo (opts, state); printf (" (TSDU)\n"); } - state->lastp25type = 0; + //state->lastp25type = 0; + // Guess that the state is TSDU + state->lastp25type = 3; sprintf (state->fsubtype, "(TSDU) "); // Now processing NID diff --git a/dsd_main.c b/dsd_main.c index c1d141b..d59704c 100644 --- a/dsd_main.c +++ b/dsd_main.c @@ -223,6 +223,7 @@ initState (dsd_state * state) state->debug_audio_errors = 0; state->debug_header_errors = 0; + state->debug_header_critical_errors = 0; } void @@ -325,6 +326,7 @@ cleanupAndExit (dsd_opts * opts, dsd_state * state) printf("\n"); printf("Total audio errors: %i\n", state->debug_audio_errors); printf("Total header errors: %i\n", state->debug_header_errors); + printf("Total irrecoverable header errors: %i\n", state->debug_header_critical_errors); printf ("Exiting.\n"); exit (0); diff --git a/p25p1_check_nid.cpp b/p25p1_check_nid.cpp new file mode 100644 index 0000000..9a4e305 --- /dev/null +++ b/p25p1_check_nid.cpp @@ -0,0 +1,92 @@ +#include + +#include "p25p1_check_nid.h" + + + +using namespace itpp; + +// Ideas taken from http://op25.osmocom.org/trac/wiki.png/browser/op25/gr-op25/lib/decoder_ff_impl.cc +// See also p25_training_guide.pdf page 48. +// See also tia-102-baaa-a-project_25-fdma-common_air_interface.pdf page 40. +// BCH encoder/decoder implementation from IT++. GNU GPL 3 license. + +itpp::BCH bch(63, 16, 11, "6 3 3 1 1 4 1 3 6 7 2 3 5 4 5 3", true); + +/** Convenience class to calculate the parity of the DUID values. Keeps a table with the expected outcomes + * for fast lookup. + */ +class ParityTable +{ +private: + unsigned char table[16]; + + unsigned char get_index(unsigned char x, unsigned char y) + { + return (x<<2) + y; + } + +public: + ParityTable() + { + for (unsigned int i=0; i