From 994e728bfb004da9caa5cb9e579c5cc8c5afaec7 Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Thu, 19 May 2022 17:26:45 -0400 Subject: [PATCH] DMR Stereo Payload Printing DMR Stereo Payload Printing --new method to print voice payloads --dump DMR Stereo payloads without needing to use -d ./MBE/ --rework how DMR Stereo voice is handled and add extra features to it --general code cleanup --- include/dsd.h | 26 ++--- src/dmr_bs.c | 247 ++++++++++++++++++++++++++++++++-------- src/dmr_data.c | 11 +- src/dmr_ms.c | 143 ++++++++++++++++------- src/dmr_process_voice.c | 26 ++++- src/dmr_sync.c | 57 ++++++++-- src/dmr_voice.c | 52 ++------- src/dsd_file.c | 40 +++++++ src/dsd_main.c | 9 +- src/dsd_mbe.c | 105 +++++++++++++++-- src/dsd_ncurses.c | 2 +- 11 files changed, 536 insertions(+), 182 deletions(-) diff --git a/include/dsd.h b/include/dsd.h index 4660580..4e0729e 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -17,16 +17,15 @@ * PERFORMANCE OF THIS SOFTWARE. */ - //pretty pretty colors - - #define KNRM "\x1B[0m" - #define KRED "\x1B[31m" - #define KGRN "\x1B[32m" - #define KYEL "\x1B[33m" - #define KBLU "\x1B[34m" - #define KMAG "\x1B[35m" - #define KCYN "\x1B[36m" - #define KWHT "\x1B[37m" +//pretty pretty colors +#define KNRM "\x1B[0m" +#define KRED "\x1B[31m" +#define KGRN "\x1B[32m" +#define KYEL "\x1B[33m" +#define KBLU "\x1B[34m" +#define KMAG "\x1B[35m" +#define KCYN "\x1B[36m" +#define KWHT "\x1B[37m" #include "config.h" #include @@ -78,9 +77,7 @@ //look into making this not required by doing ifdef, make new c file for methods, and CLI case option for ncurses terminal #include //move this stuff to dsd.h #include //move this stuff to dsd.h -// -// static volatile int exitflag; typedef struct @@ -476,6 +473,8 @@ typedef struct int payload_mfidR; int payload_mi; int payload_miR; + int payload_lsfr; + int payload_lsfrR; unsigned long long int K; unsigned int debug_audio_errors; @@ -676,6 +675,7 @@ int get_dibit_and_analog_signal (dsd_opts * opts, dsd_state * state, int * out_a void skipDibit (dsd_opts * opts, dsd_state * state, int count); void saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d); void saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d); +void PrintAMBEData (dsd_opts * opts, dsd_state * state, char *ambe_d); int readImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d); int readAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d); void openMbeInFile (dsd_opts * opts, dsd_state * state); @@ -819,7 +819,7 @@ void ProcessMBCData(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8 void ProcessMBChData(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t syncdata[48], uint8_t SlotType[20]); void ProcessWTFData(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t syncdata[48], uint8_t SlotType[20]); void ProcessUnifiedData(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t syncdata[48], uint8_t SlotType[20]); - +int LSFR(dsd_state * state); void Hamming_7_4_init(); void Hamming_7_4_encode(unsigned char *origBits, unsigned char *encodedBits); diff --git a/src/dmr_bs.c b/src/dmr_bs.c index e05d8e5..1eea018 100644 --- a/src/dmr_bs.c +++ b/src/dmr_bs.c @@ -14,13 +14,13 @@ void dmrBS (dsd_opts * opts, dsd_state * state) char t_ambe_fr2[4][24] = {9}; char t_ambe_fr3[4][24] = {9}; const int *w, *x, *y, *z; - char sync[25]; - char syncdata[48]; + char sync[25] = {0}; + char syncdata[48] = {0}; char cachdata[13] = {0}; int mutecurrentslot; int msMode; char cc[4]; - unsigned char EmbeddedSignalling[16]; + unsigned char EmbeddedSignalling[16] = {0}; int EmbeddedSignallingOk; unsigned int internalcolorcode; int internalslot; @@ -71,10 +71,6 @@ void dmrBS (dsd_opts * opts, dsd_state * state) for(i = 0; i < 12; i++) { dibit = getDibit(opts, state); - if(opts->inverted_dmr == 1) - { - //dibit = (dibit ^ 2); - } cachdata[i] = dibit; state->dmr_stereo_payload[i] = dibit; if(i == 2) @@ -95,10 +91,6 @@ void dmrBS (dsd_opts * opts, dsd_state * state) for(i = 0; i < 36; i++) { dibit = getDibit(opts, state); - if(opts->inverted_dmr == 1) - { - //dibit = (dibit ^ 2); - } state->dmr_stereo_payload[i+12] = dibit; redundancyA[i] = dibit; ambe_fr[*w][*x] = (1 & (dibit >> 1)); // bit 1 @@ -137,10 +129,6 @@ void dmrBS (dsd_opts * opts, dsd_state * state) for(i = 0; i < 18; i++) { dibit = getDibit(opts, state); - if(opts->inverted_dmr == 1) - { - //dibit = (dibit ^ 2); - } state->dmr_stereo_payload[i+48] = dibit; ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1 ambe_fr2[*y][*z] = (1 & dibit); // bit 0 @@ -157,10 +145,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state) for(i = 0; i < 24; i++) { dibit = getDibit(opts, state); - if(opts->inverted_dmr == 1) - { - //dibit = (dibit ^ 2); - } + state->dmr_stereo_payload[i+66] = dibit; syncdata[(2*i)] = (1 & (dibit >> 1)); // bit 1 syncdata[(2*i)+1] = (1 & dibit); // bit 0 @@ -197,7 +182,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state) } internalcolorcode = 69; //set so we know if this value is being set properly - //state->color_code = 69; + if( EmbeddedSignallingOk == 1 ) //don't set on 1? { //state->color_code = (unsigned int)((EmbeddedSignalling[0] << 3) + (EmbeddedSignalling[1] << 2) + (EmbeddedSignalling[2] << 1) + EmbeddedSignalling[3]); @@ -261,10 +246,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state) } //reset vc counters to 1 if new voice sync frame on each slot - //fixed to compensate for inverted signal if ( strcmp (sync, DMR_BS_VOICE_SYNC) == 0) - //if ( ( strcmp (sync, DMR_BS_VOICE_SYNC) == 0 && opts->inverted_dmr == 0 ) || - // ( strcmp (sync, DMR_BS_DATA_SYNC) == 0 && opts->inverted_dmr == 1) ) { if (internalslot == 0) { @@ -277,18 +259,14 @@ void dmrBS (dsd_opts * opts, dsd_state * state) } //check for sync pattern here after collected the rest of the payload, decide what to do with it - //fixed to compensate for inverted signal if ( strcmp (sync, DMR_BS_DATA_SYNC) == 0 ) - //if ( ( strcmp (sync, DMR_BS_DATA_SYNC) == 0 && opts->inverted_dmr == 0) || - // ( strcmp (sync, DMR_BS_VOICE_SYNC) == 0 && opts->inverted_dmr == 1) ) { fprintf (stderr,"%s ", getTime()); if (internalslot == 0) { sprintf(state->slot1light, "[slot1]"); sprintf(state->slot2light, " slot2 "); - //fprintf (stderr,"Sync: +DMR [slot1] slot2 | Color Code=%02d | DMRSTEREO | Data ", state->color_code); - //fprintf (stderr,"Sync: +DMR "); + if (opts->inverted_dmr == 0) { fprintf (stderr,"Sync: +DMR "); @@ -301,8 +279,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state) { sprintf(state->slot2light, "[slot2]"); sprintf(state->slot1light, " slot1 "); - //fprintf (stderr,"Sync: +DMR slot1 [slot2] | Color Code=%02d | DMRSTEREO | Data ", state->color_code); - //fprintf (stderr,"Sync: +DMR "); + if (opts->inverted_dmr == 0) { fprintf (stderr,"Sync: +DMR "); @@ -312,14 +289,19 @@ void dmrBS (dsd_opts * opts, dsd_state * state) vc2 = 1; } processDMRdata (opts, state); - skipcount++; //after 6 data frames, drop back to getFrameSync and process subsequent data with processDMRdata + skipcount++; //after 2 data frames, drop back to getFrameSync and process subsequent data with processDMRdata goto SKIP; } + + //find way to mitigate or correct coming back here after leaving in inverted signal + if ( strcmp (sync, DMR_BS_DATA_SYNC) == 0 && opts->inverted_dmr == 1) + { + skipcount++; + goto SKIP; + } + //only play voice on no data sync - //fixed to compensate for inverted signal if (strcmp (sync, DMR_BS_DATA_SYNC) != 0) - //if( ( strcmp (sync, DMR_BS_DATA_SYNC) != 0 && opts->inverted_dmr == 0) || - // ( strcmp (sync, DMR_BS_VOICE_SYNC) != 0 && opts->inverted_dmr == 1) ) { if (EmbeddedSignallingOk == 0) { @@ -327,26 +309,76 @@ void dmrBS (dsd_opts * opts, dsd_state * state) } skipcount = 0; //reset skip count if processing voice frames fprintf (stderr,"%s ", getTime()); + if (internalslot == 0) { state->dmrburstL = 16; //use 16 for Voice? //fprintf (stderr,"Sync: +DMR [slot1] slot2 | Color Code=%02d | DMRSTEREO | VC%d \n", state->dmr_color_code, vc1); if (opts->inverted_dmr == 0) { - fprintf (stderr,"Sync: +DMR [SLOT1] slot2 | | DMRSTEREO | VC%d \n",vc1); + fprintf (stderr,"Sync: +DMR [SLOT1] slot2 | | DMRSTEREO | VC%d ",vc1); + if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " BPK %lld", state->K); + fprintf (stderr, "%s", KNRM); + } + if (vc1 == 1 && state->payload_keyid != 0 && opts->payload == 1) + { + LSFR(state); + } + fprintf (stderr, "\n"); + } + else + { + fprintf (stderr,"Sync: -DMR [SLOT1] slot2 | | DMRSTEREO | VC%d ",vc1); + if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " BPK %lld", state->K); + fprintf (stderr, "%s", KNRM); + } + if (vc1 == 1 && state->payload_keyid != 0 && opts->payload == 1) + { + LSFR(state); + } + fprintf (stderr, "\n"); } - else fprintf (stderr,"Sync: -DMR [SLOT1] slot2 | | DMRSTEREO | VC%d \n",vc1); } if (internalslot == 1) { state->dmrburstR = 16; //use 16 for Voice? - //fprintf (stderr,"Sync: +DMR slot1 [slot2] | Color Code=%02d | DMRSTEREO | VC%d \n", state->dmr_color_code, vc2); if (opts->inverted_dmr == 0) { - fprintf (stderr,"Sync: +DMR slot1 [SLOT2] | | DMRSTEREO | VC%d \n",vc2); + fprintf (stderr,"Sync: +DMR slot1 [SLOT2] | | DMRSTEREO | VC%d ",vc2); + if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " BPK %lld", state->K); + fprintf (stderr, "%s", KNRM); + } + if (vc2 == 1 && state->payload_keyidR != 0 && opts->payload == 1) + { + LSFR(state); + } + fprintf (stderr, "\n"); + } + else + { + fprintf (stderr,"Sync: -DMR slot1 [SLOT2] | | DMRSTEREO | VC%d ",vc2); + if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " BPK %lld", state->K); + fprintf (stderr, "%s", KNRM); + } + if (vc2 == 1 && state->payload_keyidR != 0 && opts->payload == 1) + { + LSFR(state); + } + fprintf (stderr, "\n"); } - else fprintf (stderr,"Sync: -DMR slot1 [SLOT2] | | DMRSTEREO | VC%d \n",vc2); } if (internalslot == 0 && vc1 == 6) //presumably when full (and no sync issues) { @@ -425,9 +457,10 @@ void dmrBS (dsd_opts * opts, dsd_state * state) state->dmr_stereo = 0; state->errs2R = 0; state->errs2 = 0; + } -//Only process 2nd half voice payload (3rd frame) and then jump to full BS decoding +//Process buffered half frame and 2nd half and then jump to full BS decoding void dmrBSBootstrap (dsd_opts * opts, dsd_state * state) { int i, j, k, l, dibit; @@ -462,8 +495,102 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state) return curr; } - //skip the 18 dibits of the 2nd frame, since we can't play only half a frame - skipDibit (opts, state, 18); + //payload buffer + //CACH + First Half Payload + Sync = 12 + 54 + 24 + dibit_p = state->dibit_buf_p - 90; //this seems to work okay for both + //dibit_p = state->dmr_payload_p - 90; + for (i = 0; i < 90; i++) //90 + { + dibit = *dibit_p; + dibit_p++; + if(opts->inverted_dmr == 1) + { + dibit = (dibit ^ 2); + } + state->dmr_stereo_payload[i] = dibit; + } + + for(i = 0; i < 12; i++) + { + dibit = state->dmr_stereo_payload[i]; + cachdata[i] = dibit; + if(i == 2) + { + state->currentslot = (1 & (dibit >> 1)); + } + } + + //Setup for first AMBE Frame + + //Interleave Schedule + w = rW; + x = rX; + y = rY; + z = rZ; + + //First AMBE Frame, Full 36 + for(i = 0; i < 36; i++) + { + dibit = state->dmr_stereo_payload[i+12]; + ambe_fr[*w][*x] = (1 & (dibit >> 1)); // bit 1 + ambe_fr[*y][*z] = (1 & dibit); // bit 0 + + w++; + x++; + y++; + z++; + + } + + //Setup for Second AMBE Frame + + //Interleave Schedule + w = rW; + x = rX; + y = rY; + z = rZ; + + //Second AMBE Frame, First Half 18 dibits just before Sync or EmbeddedSignalling + for(i = 0; i < 18; i++) + { + dibit = state->dmr_stereo_payload[i+48]; + ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1 + ambe_fr2[*y][*z] = (1 & dibit); // bit 0 + + w++; + x++; + y++; + z++; + + } + + // signaling data or sync, just redo it + for(i = 0; i < 24; i++) + { + dibit = state->dmr_stereo_payload[i+66]; + sync[i] = (dibit | 1) + 48; + } + sync[24] = 0; + //this method seems to work to make sure we aren't in a data sync especially when inverted signal + //consider only testing this when inverted signal if this causes issues with sync later on + if ( strcmp (sync, DMR_BS_VOICE_SYNC) != 0) + { + goto END; + } + + //Continue Second AMBE Frame, 18 after Sync or EmbeddedSignalling + for(i = 0; i < 18; i++) + { + dibit = getDibit(opts, state); + ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1 + ambe_fr2[*y][*z] = (1 & dibit); // bit 0 + + w++; + x++; + y++; + z++; + + } //Setup for Third AMBE Frame @@ -477,10 +604,6 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state) for(i = 0; i < 36; i++) { dibit = getDibit(opts, state); - if(opts->inverted_dmr == 1) - { - //dibit = (dibit ^ 2); - } ambe_fr3[*w][*x] = (1 & (dibit >> 1)); // bit 1 ambe_fr3[*y][*z] = (1 & dibit); // bit 0 @@ -491,15 +614,39 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state) } - //fprintf (stderr,"\n%s ", getTime()); fprintf (stderr,"%s ", getTime()); if (opts->inverted_dmr == 0) { - fprintf (stderr,"Sync: +DMR | Frame Sync | DMRSTEREO | VC1 FS \n"); + fprintf (stderr,"Sync: +DMR | Frame Sync | DMRSTEREO | VC1 "); + if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) || + (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) ) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " BPK %lld", state->K); + fprintf (stderr, "%s", KNRM); + //state->currentslot = 0; //slot now set from cach data from buffer + } + fprintf (stderr, "\n"); } - else fprintf (stderr,"Sync: -DMR | Frame Sync | DMRSTEREO | VC1 FS \n"); - //fprintf (stderr,"Sync: +DMR | Frame Sync | DMRSTEREO | VC1 FS \n"); + else + { + fprintf (stderr,"Sync: -DMR | Frame Sync | DMRSTEREO | VC1 "); + if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) || + (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) ) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " BPK %lld", state->K); + fprintf (stderr, "%s", KNRM); + //state->currentslot = 0; //slot now set from cach data from buffer + } + fprintf (stderr, "\n"); + } + + //these ambe_fr values are set correctly now! + processMbeFrame (opts, state, NULL, ambe_fr, NULL); + processMbeFrame (opts, state, NULL, ambe_fr2, NULL); processMbeFrame (opts, state, NULL, ambe_fr3, NULL); dmrBS (opts, state); //bootstrap into full TDMA frame for BS mode + END: } diff --git a/src/dmr_data.c b/src/dmr_data.c index 7decf4b..f8429c1 100644 --- a/src/dmr_data.c +++ b/src/dmr_data.c @@ -57,7 +57,6 @@ processDMRdata (dsd_opts * opts, dsd_state * state) dibit_p = state->dmr_payload_p - 90; } - // CACH for (i = 0; i < 12; i++) { @@ -93,15 +92,7 @@ processDMRdata (dsd_opts * opts, dsd_state * state) state->slot1light[0] = ' '; state->slot1light[6] = ' '; } - //method to only see data from one slot or the other when data occupies both slots or gets cooked by sync - state->hardslot = 9; //0 to only listen to slot 0 voice, 1 for slot 1, 9 for both - if(state->hardslot != 9 && state->hardslot != state->currentslot) - //if(1==1) - { - //fprintf (stderr, " Current Slot = %d", state->currentslot + 1); - //fprintf (stderr, "\n"); //line break after breaking out of jail - //goto JUMP; - } + } } cachdata[12] = 0; diff --git a/src/dmr_ms.c b/src/dmr_ms.c index bb67bcd..c207d42 100644 --- a/src/dmr_ms.c +++ b/src/dmr_ms.c @@ -269,7 +269,8 @@ void dmrMS (dsd_opts * opts, dsd_state * state) //if ( (strcmp (sync, DMR_MS_VOICE_SYNC) == 0) ) //fixed to compensate for inverted signal - if ( ((strcmp (sync, DMR_MS_VOICE_SYNC) == 0) && opts->inverted_dmr == 0) || ((strcmp (sync, DMR_MS_DATA_SYNC) == 0) && opts->inverted_dmr == 1) ) + if ( ((strcmp (sync, DMR_MS_VOICE_SYNC) == 0) && opts->inverted_dmr == 0) || + ((strcmp (sync, DMR_MS_DATA_SYNC) == 0) && opts->inverted_dmr == 1) ) { if (internalslot == 0) @@ -380,21 +381,65 @@ void dmrMS (dsd_opts * opts, dsd_state * state) fprintf (stderr,"%s ", getTime()); if (internalslot == 0 && opts->inverted_dmr == 0) { - fprintf (stderr,"Sync: +DMR MS MODE | Color Code=%02d | DMRSTEREO | VC%d \n", state->color_code, vc1); + fprintf (stderr,"Sync: +DMR MS MODE | Color Code=%02d | DMRSTEREO | VC%d ", state->color_code, vc1); + if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " BPK %lld", state->K); + fprintf (stderr, "%s", KNRM); + } + if (vc1 == 6 && state->payload_keyid != 0 && opts->payload == 1) + { + LSFR(state); + } + fprintf (stderr, "\n"); } if (internalslot == 0 && opts->inverted_dmr == 1) { - fprintf (stderr,"Sync: -DMR MS MODE | Color Code=%02d | DMRSTEREO | VC%d \n", state->color_code, vc1); + fprintf (stderr,"Sync: -DMR MS MODE | Color Code=%02d | DMRSTEREO | VC%d ", state->color_code, vc1); + if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " BPK %lld", state->K); + fprintf (stderr, "%s", KNRM); + } + if (vc1 == 6 && state->payload_keyid != 0 && opts->payload == 1) + { + LSFR(state); + } + fprintf (stderr, "\n"); } if (internalslot == 1 && opts->inverted_dmr == 0) { - fprintf (stderr,"Sync: +DMR MS MODE | Color Code=%02d | DMRSTEREO | VC%d \n", state->color_code, vc2); + fprintf (stderr,"Sync: +DMR MS MODE | Color Code=%02d | DMRSTEREO | VC%d ", state->color_code, vc2); + if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " BPK %lld", state->K); + fprintf (stderr, "%s", KNRM); + } + if (vc2 == 6 && state->payload_keyidR != 0 && opts->payload == 1) + { + LSFR(state); + } + fprintf (stderr, "\n"); } if (internalslot == 1 && opts->inverted_dmr == 1) { - fprintf (stderr,"Sync: -DMR MS MODE | Color Code=%02d | DMRSTEREO | VC%d \n", state->color_code, vc2); + fprintf (stderr,"Sync: -DMR MS MODE | Color Code=%02d | DMRSTEREO | VC%d ", state->color_code, vc2); + if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " BPK %lld", state->K); + fprintf (stderr, "%s", KNRM); + } + if (vc2 == 6 && state->payload_keyidR != 0 && opts->payload == 1) + { + LSFR(state); + } + fprintf (stderr, "\n"); } if (internalslot == 0 && vc1 == 6) //presumably when full (and no sync issues) { @@ -429,7 +474,7 @@ void dmrMS (dsd_opts * opts, dsd_state * state) } SKIP: - skipDibit (opts, state, 144); //skip to next slot? + skipDibit (opts, state, 144); //skip to next tdma channel state->dmr_ms_rc = 0; //since we are in a repetitive loop, run ncursesPrinter here @@ -452,7 +497,7 @@ void dmrMS (dsd_opts * opts, dsd_state * state) dibit = (dibit ^ 2); } state->dmr_stereo_payload[i] = dibit; - //fprintf(stderr, "%X", state->dmr_stereo_payload[i]); + } state->dmr_stereo = 0; @@ -461,7 +506,7 @@ void dmrMS (dsd_opts * opts, dsd_state * state) } -//Only process 2nd half voice payload (3rd frame) and then jump to full MS Voice decoding. +//collect buffered 1st half and get 2nd half voice payload and then jump to full MS Voice decoding. void dmrMSBootstrap (dsd_opts * opts, dsd_state * state) { int i, j, k, l, dibit; @@ -499,12 +544,10 @@ void dmrMSBootstrap (dsd_opts * opts, dsd_state * state) dibit_p = state->dmr_payload_p - 90; //payload buffer tests //CACH + First Half Payload + Sync = 12 + 54 + 24 - //fprintf(stderr, "\n Full DMR Stereo Dump Dibits 90 From Buffer\n"); for (i = 0; i < 90; i++) //90 { state->dmr_stereo_payload[i] = *dibit_p; dibit_p++; - //fprintf(stderr, "%X", state->dmr_stereo_payload[i]); } //end payload buffer test @@ -614,15 +657,39 @@ void dmrMSBootstrap (dsd_opts * opts, dsd_state * state) z++; } + //work around to set erroneous PI header values to 0 if K is active + if (state->K > 0) + { + state->payload_keyid = 0; //just for testing + state->payload_keyidR = 0; //just for testing + } - //fprintf (stderr, "MS MODE "); fprintf (stderr,"%s ", getTime()); - //fprintf (stderr,"Sync: +DMR | Frame Sync | DMRSTEREO | VC1 FS \n"); + if (opts->inverted_dmr == 0) { - fprintf (stderr,"Sync: +DMR MS MODE | Frame Sync | DMRSTEREO | VC1 FS \n"); + fprintf (stderr,"Sync: +DMR MS MODE | Frame Sync | DMRSTEREO | VC1 "); + if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) || + (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) ) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " BPK %lld", state->K); + fprintf (stderr, "%s", KNRM); + } + fprintf (stderr, "\n"); + } + else + { + fprintf (stderr,"Sync: -DMR MS MODE | Frame Sync | DMRSTEREO | VC1 "); + if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) || + (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) ) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " BPK %lld", state->K); + fprintf (stderr, "%s", KNRM); + } + fprintf (stderr, "\n"); } - else fprintf (stderr,"Sync: -DMR MS MODE | Frame Sync | DMRSTEREO | VC1 FS \n"); processMbeFrame (opts, state, NULL, ambe_fr, NULL); processMbeFrame (opts, state, NULL, ambe_fr2, NULL); processMbeFrame (opts, state, NULL, ambe_fr3, NULL); @@ -656,44 +723,49 @@ void dmrMSData (dsd_opts * opts, dsd_state * state) } //CACH + First Half Payload + Sync = 12 + 54 + 24 - //fprintf(stderr, "\n Full DMR Stereo Dump Dibits 90 From Buffer\n"); + //dibit_p = state->dibit_buf_p - 90; + dibit_p = state->dmr_payload_p - 90; for (i = 0; i < 90; i++) //90 { - //fprintf(stderr, "%X", state->dmr_stereo_payload[i]); + dibit = *dibit_p; + dibit_p++; + if(opts->inverted_dmr == 1) + { + dibit = (dibit ^ 2); + } + state->dmr_stereo_payload[i] = dibit; } for (i = 0; i < 54; i++) { dibit = getDibit(opts, state); - if (opts->inverted_dmr == 1) - { - dibit = (dibit ^ 2); - } state->dmr_stereo_payload[i+90] = dibit; } - //fprintf(stderr, "\n"); - //print nice pretty lines - //fprintf (stderr, "MS MODE "); - fprintf (stderr, "%s ", getTime()); - //fprintf (stderr, "Sync: +MS DATA | Color Code=XX | DMRSTEREO | Data "); - if (opts->inverted_dmr == 0) + //hide behind payload due to errs in data in MS mode + if (opts->payload == 1) { - fprintf (stderr,"Sync: +DMR MS MODE "); + fprintf (stderr, "%s ", getTime()); + if (opts->inverted_dmr == 0) + { + fprintf (stderr,"Sync: +DMR MS MODE "); + } + else fprintf (stderr,"Sync: -DMR MS MODE "); } - else fprintf (stderr,"Sync: -DMR MS MODE "); - //fprintf (stderr, "\n "); - //sprintf for slot 1, doesn't matter, just makes print out of data look uniform setting ahead of time - //sprintf(state->slot1light, "[slot1]"); - //sprintf(state->slot2light, " slot2 "); + sprintf(state->slot1light, ""); sprintf(state->slot2light, ""); //process data state->dmr_stereo = 1; state->dmr_ms_mode = 1; - processDMRdata (opts, state); + //only run if payload is set to 1 due to errors with MS data + if (opts->payload == 1) + { + processDMRdata (opts, state); + } + state->dmr_stereo = 0; state->dmr_ms_mode = 0; @@ -703,12 +775,7 @@ void dmrMSData (dsd_opts * opts, dsd_state * state) for (i = 0; i < 66; i++) //66 { dibit = getDibit(opts, state); - if (opts->inverted_dmr == 1) - { - dibit = (dibit ^ 2); - } state->dmr_stereo_payload[i] = dibit; - //fprintf(stderr, "%X", state->dmr_stereo_payload[i]); } } diff --git a/src/dmr_process_voice.c b/src/dmr_process_voice.c index 36bc56d..8cfd8d6 100644 --- a/src/dmr_process_voice.c +++ b/src/dmr_process_voice.c @@ -81,6 +81,7 @@ if (state->currentslot == 0 && state->K > 0 && state->dmr_so & 0x40 && state->pa fprintf (stderr, "%s", KNRM); k = BP[state->K]; k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k ); + //fprintf (stderr, "\nK=0x%X\n", k); for(Frame = 0; Frame < 6; Frame++) { for(i = 0; i < 3; i++) @@ -101,6 +102,7 @@ if (state->currentslot == 1 && state->K > 0 && state->dmr_soR & 0x40 && state->p fprintf (stderr, "%s", KNRM); k = BP[state->K]; k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k ); + //fprintf (stderr, "\nK=0x%X\n", k); for(Frame = 0; Frame < 6; Frame++) { for(i = 0; i < 3; i++) @@ -140,7 +142,18 @@ if (state->currentslot == 0) } state->debug_audio_errors += *errs2; - + // + //fprintf (stderr, "%X", TSVoiceSupFrameL->TimeSlotDeinterleavedVoiceFrame[Frame].DeInterleavedVoiceSample[i] ); //this set up right? + // + /* + fprintf (stderr, "\nInt RVD "); + for (short o = 0; o < 36; o++) + { + fprintf (stderr, "%X", TSVoiceSupFrameL->TimeSlotDeinterleavedVoiceFrame[Frame].DeInterleavedVoiceSample[i][o] ); + } + */ + //wny do I have this running twice for? + //processAudio(opts, state); processAudio(opts, state); //playSynthesizedVoice (opts, state); @@ -184,7 +197,16 @@ if (state->currentslot == 0) } state->debug_audio_errors += *errs2; - + // + //fprintf (stderr, "%X", TSVoiceSupFrameR->TimeSlotDeinterleavedVoiceFrame[Frame].DeInterleavedVoiceSample[i] ); //this set up right? + // + /* + fprintf (stderr, "\nInt RVD "); + for (short o = 0; o < 36; o++) + { + fprintf (stderr, "%X", TSVoiceSupFrameR->TimeSlotDeinterleavedVoiceFrame[Frame].DeInterleavedVoiceSample[i][o] ); + } + */ processAudio(opts, state); //playSynthesizedVoice (opts, state); diff --git a/src/dmr_sync.c b/src/dmr_sync.c index d8d6d50..75b024b 100644 --- a/src/dmr_sync.c +++ b/src/dmr_sync.c @@ -1860,8 +1860,8 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19 } /* Print the destination ID (TG) and the source ID */ fprintf (stderr, "%s ", KGRN); - fprintf(stderr, "\n TG=%u Src=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); - fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); + fprintf(stderr, "\n TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); + //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); //state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress; //state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress; //state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID; @@ -2095,8 +2095,8 @@ void ProcessDmrTerminaisonLC(dsd_opts * opts, dsd_state * state, uint8_t info[19 { fprintf (stderr, "%s \n", KRED); fprintf (stderr, " SLOT %d", state->currentslot+1); - fprintf(stderr, " TG=%u Src=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); - fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); + fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); + //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); fprintf (stderr, "%s ", KNRM); //fprintf(stderr, "(CRC OK ) "); if (TSVoiceSupFrame->FullLC.FullLinkControlOpcode == 0) //other opcodes may convey callsigns, names, etc. @@ -2138,8 +2138,8 @@ void ProcessDmrTerminaisonLC(dsd_opts * opts, dsd_state * state, uint8_t info[19 { fprintf (stderr, "%s \n", KRED); fprintf (stderr, " SLOT %d", state->currentslot+1); - fprintf(stderr, " TG=%u Src=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); - fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); + fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); + //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); fprintf(stderr, "RAS (FEC OK/CRC ERR)"); //tlc fprintf (stderr, "%s ", KNRM); if (TSVoiceSupFrame->FullLC.FullLinkControlOpcode == 0) //other opcodes may convey callsigns, names, etc. @@ -2414,8 +2414,8 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state) fprintf(stderr, "\n"); } fprintf (stderr, " SLOT %d", state->currentslot+1); - fprintf(stderr, " TG=%u Src=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); - fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); + fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); + //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); fprintf (stderr, "%s ", KNRM); //fprintf(stderr, "(CRC OK ) "); if (state->currentslot == 0) @@ -2458,8 +2458,8 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state) fprintf(stderr, "\n"); } fprintf (stderr, " SLOT %d", state->currentslot+1); - fprintf(stderr, " TG=%u Src=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); - fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); + fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); + //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); fprintf (stderr, "%s ", KRED); fprintf(stderr, "RAS (FEC OK/CRC ERR) "); fprintf (stderr, "%s ", KNRM); @@ -2537,7 +2537,44 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state) } /* End ProcessVoiceBurstSync() */ +int LSFR(dsd_state * state) +{ + int lfsr = 0; + if (state->currentslot == 0) + { + lfsr = state->payload_mi; + } + else lfsr = state->payload_miR; + uint8_t cnt = 0; + //fprintf(stderr, "\nInitial Value:- 0x%08x\n", lfsr); + + for(cnt=0;cnt<32;cnt++) + { + // Polynomial is C(x) = x^32 + x^4 + x^2 + 1 + int bit = ((lfsr >> 31) ^ (lfsr >> 3) ^ (lfsr >> 1)) & 0x1; + lfsr = (lfsr << 1) | (bit); + //fprintf(stderr, "\nshift #%i, 0x%08x\n", (cnt+1), lfsr); + } + if (state->currentslot == 0) + { + fprintf (stderr, "%s", KYEL); + fprintf (stderr, "\n Slot 1"); + fprintf (stderr, " DMR PI Continuation ALG ID: 0x%02X KEY ID: 0x%02X", state->payload_algid, state->payload_keyid); + fprintf(stderr, " Next MI: 0x%08X", lfsr); + fprintf (stderr, "%s", KNRM); + state->payload_mi = lfsr; + } + else + { + fprintf (stderr, "%s", KYEL); + fprintf (stderr, "\n Slot 2"); + fprintf (stderr, " DMR PI Continuation ALG ID: 0x%02X KEY ID: 0x%02X", state->payload_algidR, state->payload_keyidR); + fprintf(stderr, " Next MI: 0x%08X", lfsr); + fprintf (stderr, "%s", KNRM); + state->payload_miR = lfsr; + } +} /* * @brief : This function compute the CRC-CCITT of the DMR data * by using the polynomial x^16 + x^12 + x^5 + 1 diff --git a/src/dmr_voice.c b/src/dmr_voice.c index c44598d..a7e4ecc 100644 --- a/src/dmr_voice.c +++ b/src/dmr_voice.c @@ -36,12 +36,6 @@ void processDMRvoice (dsd_opts * opts, dsd_state * state) unsigned char EmbeddedSignalling[16]; unsigned int EmbeddedSignallingOk; - /* Remove warning compiler */ - //UNUSED_VARIABLE(ambe_fr[0][0]); - //UNUSED_VARIABLE(ambe_fr2[0][0]); - //UNUSED_VARIABLE(ambe_fr3[0][0]); - //UNUSED_VARIABLE(cachdata[0]); - #ifdef DMR_DUMP int k; char syncbits[49]; @@ -115,16 +109,7 @@ void processDMRvoice (dsd_opts * opts, dsd_state * state) state->slot1light[0] = ' '; state->slot1light[6] = ' '; } - //method to only listen to a chosen slot when voices occupy both slots simultaneously - //method supersceeded by DMRSTEREO - //state->hardslot = 9; //0 to only listen to slot 0 voice, 1 for slot 1, 9 for both - //if(state->hardslot != 9 && state->hardslot != state->currentslot) - //if(1==1) - //{ - //fprintf (stderr, " Current Slot = %d", state->currentslot + 1); - //fprintf (stderr, "\n"); //line break after breaking out of jail - //goto JUMP; - //} + } } cachdata[12] = 0; @@ -389,30 +374,6 @@ void processDMRvoice (dsd_opts * opts, dsd_state * state) sprintf(state->slot2light, "[sLoT2]"); } - //Comment out Below Lines, or switch if/else if if these cause issues. - /* - else if((strcmp (sync, DMR_MS_VOICE_SYNC) == 0) || (strcmp (sync, DMR_MS_DATA_SYNC) == 0)) - { - msMode = 1; - if strcmp (sync, DMR_MS_VOICE_SYNC) == 0) - { - //quickDMRVoice (opts, state); //or make handler for msvoice seperate - //goto JUMP; //quit early when returned here - } - } - else if((strcmp (sync, DMR_BS_VOICE_SYNC) == 0) - { - //quickDMRVoice (opts, state); //or make handler for msvoice seperate - //goto JUMP; //quit early when returned here - } - */ - -// TODO : To be removed -// if((j == 0) && (opts->errorbars == 1)) -// { -// fprintf(stderr, "%s %s VOICE e:", state->slot1light, state->slot2light); -// } - #ifdef DMR_DUMP k = 0; for(i = 0; i < 24; i++) @@ -675,7 +636,6 @@ void processDMRvoice (dsd_opts * opts, dsd_state * state) fprintf (stderr, "%s", KNRM); } - //fprintf(stderr, " VOICE e: \n"); fprintf(stderr, " VOICE "); } @@ -685,9 +645,13 @@ void processDMRvoice (dsd_opts * opts, dsd_state * state) /* Perform the DMR voice decoding */ ProcessDMR(opts, state); - /* Print DMR frame (if needed) */ - //DMRVoiceFrameProcess(opts, state); //HERE HERE, was enabled, disabled so I could build - //JUMP: + //LSFR if required + if ( (state->currentslot == 0 && state->payload_keyid != 0 && opts->payload == 1) || + (state->currentslot == 1 && state->payload_keyidR != 0 && opts->payload == 1) ) + { + LSFR(state); + } + if(opts->errorbars == 1) { fprintf(stderr, "\n"); diff --git a/src/dsd_file.c b/src/dsd_file.c index de168b0..df76440 100644 --- a/src/dsd_file.c +++ b/src/dsd_file.c @@ -102,6 +102,46 @@ saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d) fflush (opts->mbe_out_f); } +void +PrintAMBEData (dsd_opts * opts, dsd_state * state, char *ambe_d) //For DMR Stereo, may use this for NXDN too +{ + int i, j, k; + unsigned char b; + unsigned char err; + + err = (unsigned char) state->errs2; + k = 0; + if (opts->payload == 1 && opts->dmr_stereo == 1) //print AMBE info from DMR Stereo method + { + fprintf(stderr, " AMBE "); + } + for (i = 0; i < 7; i++) //using 7 seems to break older amb files where it was 6, need to test 7 on 7 some more + { + b = 0; + for (j = 0; j < 8; j++) + { + b = b << 1; + b = b + ambe_d[k]; + k++; + } + if (opts->payload == 1 && i < 6) //make opt variable later on to toggle this + { + fprintf (stderr, "%02X", b); + } + if (opts->payload == 1 && i == 6) //7th octet should only contain 1 bit, value will be either 0x00 or 0x80? + { + fprintf (stderr, "%02X", b & 0x80); //7th octet should only contain 1 bit + } + } + if (state->currentslot == 0) + { + fprintf(stderr, " err = [%X] [%X] ", state->errs, state->errs2); + } + else fprintf(stderr, " err = [%X] [%X] ", state->errsR, state->errs2R); + b = ambe_d[48]; + fprintf (stderr, "\n"); +} + int readImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d) { diff --git a/src/dsd_main.c b/src/dsd_main.c index df02d8d..a51e86c 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -46,7 +46,7 @@ int pretty_colors() short int butt = 1; char * FM_banner[9] = { - " CTRL + C twice to exit", + " 2022 Dove Award Winner CTRL + C twice to exit", " ██████╗ ██████╗██████╗    ███████╗███╗ ███╗███████╗", " ██╔══██╗██╔════╝██╔══██╗   ██╔════╝████╗ ████║██╔════╝", " ██║ ██║╚█████╗ ██║ ██║   █████╗ ██╔████╔██║█████╗ ", @@ -420,7 +420,8 @@ initState (dsd_state * state) void usage () { - printf ( "Github Build Version: %s \n", GIT_TAG); + //printf ( "Github Build Version: %s \n", GIT_TAG); + //printf ( "2022 Dove Award Recipient"); //Thanks, Scott printf ("\n"); printf ("Usage: dsd [options] Live scanner mode\n"); printf (" or: dsd [options] -r Read/Play saved mbe data from file(s)\n"); @@ -878,12 +879,12 @@ main (int argc, char **argv) break; case 'T': - opts.dmr_stereo = 1; //just the end user option + opts.dmr_stereo = 1; //this value is the end user option state.dmr_stereo = 1; //this values toggles on and off depending on voice or data handling opts.pulse_digi_rate_out = 24000; opts.pulse_digi_out_channels = 2; fprintf (stderr, "%s", KRED); - fprintf (stderr,"Experimental DMR Stereo Sync and Functionality. WIP!\n"); + fprintf (stderr,"DMR Stereo Sync and Functionality Enabled.\n"); fprintf (stderr,"DMR Stereo will disable WAV and MBE file saving!\n"); fprintf (stderr,"Also consider using -F if playback is too choppy!\n"); fprintf (stderr, "%s", KNRM); diff --git a/src/dsd_mbe.c b/src/dsd_mbe.c index 0c64119..28d23f0 100644 --- a/src/dsd_mbe.c +++ b/src/dsd_mbe.c @@ -17,7 +17,7 @@ #include "dsd.h" -static void DecipherData(char * Input, char * KeyStream, char * Output, int NbData); +//static void DecipherData(char * Input, char * KeyStream, char * Output, int NbData); void playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv) @@ -77,21 +77,64 @@ playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv) void processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char ambe_fr[4][24], char imbe7100_fr[7][24]) { + //is this the best placement for this array? + // + int BP[256] = { + 0x0000, 0x1F00, 0xE300, 0xFC00, 0x2503, 0x3A03, 0xC603, 0xD903, + 0x4A05, 0x5505, 0xA905, 0xB605, 0x6F06, 0x7006, 0x8C06, 0x9306, + 0x2618, 0x3918, 0xC518, 0xDA18, 0x031B, 0x1C1B, 0xE01B, 0xFF1B, + 0x6C1D, 0x731D, 0x8F1D, 0x901D, 0x491E, 0x561E, 0xAA1E, 0xB51E, //31 + 0x4B28, 0x5428, 0xA828, 0xB728, 0x6E2B, 0x712B, 0x8D2B, 0x922B, + 0x012D, 0x1E2D, 0xE22D, 0xFD2D, 0x242E, 0x3B2E, 0xC72E, 0xD82E, + 0x6D30, 0x7230, 0x8E30, 0x9130, 0x4833, 0x5733, 0xAB33, 0xB433, + 0x2735, 0x3835, 0xC435, 0xDB35, 0x0236, 0x1D36, 0xE136, 0xFE36, //63 + 0x2B49, 0x3449, 0xC849, 0xD749, 0x0E4A, 0x114A, 0xED4A, 0xF24A, + 0x614C, 0xAE4C, 0x824C, 0x9D4C, 0x444F, 0x5B4F, 0xA74F, 0xB84F, + 0x0D51, 0x1251, 0xEE51, 0xF151, 0x2852, 0x3752, 0xCB52, 0xD452, + 0x4754, 0x5854, 0xA454, 0xBB54, 0x6257, 0x7D57, 0x8157, 0x9E57, //95 + 0x6061, 0x7F61, 0x8361, 0x9C61, 0x4562, 0x5A62, 0xA662, 0xB962, + 0x2A64, 0x3564, 0xC964, 0xD664, 0x0F67, 0x1067, 0xEC67, 0xF367, + 0x4679, 0x5979, 0xA579, 0xBA79, 0x637A, 0x7C7A, 0x807A, 0x9F7A, + 0x0C7C, 0x137C, 0xEF7C, 0xF07C, 0x297F, 0x367F, 0xCA7F, 0xD57F, //127 + 0x4D89, 0x5289, 0xAE89, 0xB189, 0x688A, 0x778A, 0x8B8A, 0x948A, + 0x078C, 0x188C, 0xE48C, 0xFB8C, 0x228F, 0x3D8F, 0xC18F, 0xDE8F, + 0x6B91, 0x7491, 0x8891, 0x9791, 0x4E92, 0x5192, 0xAD92, 0xB292, + 0x2194, 0x3E94, 0xC294, 0xDD94, 0x0497, 0x1B97, 0xE797, 0xF897, //159 + 0x06A1, 0x19A1, 0xE5A1, 0xFAA1, 0x23A2, 0x3CA2, 0xC0A2, 0xDFA2, + 0x4CA4, 0x53A4, 0xAFA4, 0xB0A4, 0x69A7, 0x76A7, 0x8AA7, 0x95A7, + 0x20B9, 0x3FB9, 0xC3B9, 0xDCB9, 0x05BA, 0x1ABA, 0xE6BA, 0xF9BA, + 0x6ABC, 0x75BC, 0x89BC, 0x96BC, 0x4FBF, 0x50BF, 0xACBF, 0xB3BF, //191 + 0x66C0, 0x79C0, 0x85C0, 0x9AC0, 0x43C3, 0x5CC3, 0xA0C3, 0xBFC3, + 0x2CC5, 0x33C5, 0xCFC5, 0xD0C5, 0x09C6, 0x16C6, 0xEAC6, 0xF5C6, + 0x84D0, 0x85DF, 0x8AD3, 0x8BDC, 0xB6D5, 0xB7DA, 0xB8D6, 0xB9D9, + 0xD0DA, 0xD1D5, 0xDED9, 0xDFD6, 0xE2DF, 0xE3D0, 0xECDC, 0xEDD3, //223 + 0x2DE8, 0x32E8, 0xCEE8, 0xD1E8, 0x08EB, 0x17EB, 0xEBEB, 0xF4EB, + 0x67ED, 0x78ED, 0x84ED, 0x9BED, 0x42EE, 0x5DEE, 0xA1EE, 0xBEEE, + 0x0BF0, 0x14F0, 0xE8F0, 0xF7F0, 0x2EF3, 0x31F3, 0xCDF3, 0xD2F3, + 0x41F5, 0x5EF5, 0xA2F5, 0xBDF5, 0x64F6, 0x7BF6, 0x87F6, 0x98F6 //255 + }; + // + //comment out line below should return print back to normal //strncpy (state->err_buf, state->err_str, sizeof(state->err_str)); //right at the very top before err_str gets returned? int i; char imbe_d[88]; char ambe_d[49]; char ambe_d_str[50]; -#ifdef AMBE_PACKET_OUT + unsigned long long int k; + int x; -#endif for (i = 0; i < 88; i++) { imbe_d[i] = 0; } + for (i = 0; i < 49; i++) + { + ambe_d[i] = 0; + } + if ((state->synctype == 0) || (state->synctype == 1)) { @@ -109,8 +152,6 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a else if ((state->synctype == 14) || (state->synctype == 15)) { mbe_processImbe7100x4400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, imbe7100_fr, imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); - //mbe_processImbe7100x4400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, imbe7100_fr, processed_block, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); - if (opts->mbe_out_f != NULL) { saveImbe4400Data (opts, state, imbe_d); @@ -129,18 +170,60 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a //stereo slots and slot 0 (left slot) if (state->currentslot == 0 && opts->dmr_stereo == 1) { - mbe_processAmbe3600x2450Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_fr, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); + //seperate the ecc, demodulation, slip in xor, and processdata instead? + state->errs = mbe_eccAmbe3600x2450C0 (ambe_fr); + state->errs2 = state->errs; + mbe_demodulateAmbe3600x2450Data (ambe_fr); + state->errs2 += mbe_eccAmbe3600x2450Data (ambe_fr, ambe_d); + if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) // + { + k = BP[state->K]; + k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k ); + for (short int j = 0; j < 49; j++) + { + x = ( ((k << j) & 0x800000000000) >> 47 ); + ambe_d[j] ^= x; + } + } + mbe_processAmbe2450Dataf (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, + ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); + + //old method for this step below + //mbe_processAmbe3600x2450Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_fr, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); + if (opts->payload == 1) + { + PrintAMBEData (opts, state, ambe_d); + } } //stereo slots and slot 1 (right slot) if (state->currentslot == 1 && opts->dmr_stereo == 1) { - mbe_processAmbe3600x2450Framef (state->audio_out_temp_bufR, &state->errsR, &state->errs2R, state->err_strR, ambe_fr, ambe_d, state->cur_mp2, state->prev_mp2, state->prev_mp_enhanced2, opts->uvquality); - //just put this in here for troubleshooting for now - if (opts->mbe_out_f != NULL) + //seperate the ecc, demodulation, slip in xor, and processdata instead? + state->errsR = mbe_eccAmbe3600x2450C0 (ambe_fr); + state->errs2R = state->errsR; + mbe_demodulateAmbe3600x2450Data (ambe_fr); + state->errs2R += mbe_eccAmbe3600x2450Data (ambe_fr, ambe_d); + if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) // { - saveAmbe2450Data (opts, state, ambe_d); + k = BP[state->K]; + k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k ); + for (short int j = 0; j < 49; j++) + { + x = ( ((k << j) & 0x800000000000) >> 47 ); + ambe_d[j] ^= x; + } + } + mbe_processAmbe2450Dataf (state->audio_out_temp_bufR, &state->errsR, &state->errs2R, state->err_strR, + ambe_d, state->cur_mp2, state->prev_mp2, state->prev_mp_enhanced2, opts->uvquality); + + //old method for this step below + //mbe_processAmbe3600x2450Framef (state->audio_out_temp_bufR, &state->errsR, &state->errs2R, state->err_strR, ambe_fr, ambe_d, state->cur_mp2, state->prev_mp2, state->prev_mp_enhanced2, opts->uvquality); + if (opts->payload == 1) + { + PrintAMBEData (opts, state, ambe_d); } } + //if using older DMR method, dPMR, etc if (opts->dmr_stereo == 0) { mbe_processAmbe3600x2450Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_fr, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); @@ -201,6 +284,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a } /* This function decipher data */ +/* //does anything even call this function? static void DecipherData(char * Input, char * KeyStream, char * Output, int NbData) { int i; @@ -210,3 +294,4 @@ static void DecipherData(char * Input, char * KeyStream, char * Output, int NbDa Output[i] = Input[i] ^ KeyStream[i]; } } +*/ diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index 733c829..16dcc69 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -45,7 +45,7 @@ char versionstr[25]; unsigned long long int call_matrix[33][6]; char * FM_bannerN[9] = { - " CTRL + C twice to exit", + " 2022 Dove Award Winner CTRL + C twice to exit", " ██████╗ ██████╗██████╗    ███████╗███╗ ███╗███████╗", " ██╔══██╗██╔════╝██╔══██╗   ██╔════╝████╗ ████║██╔════╝", " ██║ ██║╚█████╗ ██║ ██║   █████╗ ██╔████╔██║█████╗ ",