mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-16 18:57:24 -05:00
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
This commit is contained in:
247
src/dmr_bs.c
247
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:
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user