Merge pull request #62 from lwvmobile/dmrstereopatch

DMR Stereo Patches
This commit is contained in:
lwvmobile
2022-05-20 14:43:32 -04:00
committed by GitHub
13 changed files with 637 additions and 218 deletions

View File

@@ -19,7 +19,7 @@ Use Passive Frame Sync if voice in both slots becomes choppy or skips. Using Pas
### Example Usage and Note! ### Example Usage and Note!
`dsd` or `./dsd` may need to be used in your usage, depending on if you are running it from the build folder, or if you have run make install. You will need to tweak the examples to your particular usage. Users can always check `dsd -h` for help and all command line switches to use. `dsd` or `./dsd` may need to be used in your usage, depending on if you are running it from the build folder, or if you have run make install. You will need to tweak the examples to your particular usage. Users can always check `dsd -h` for help and all command line switches to use.
`dsd` is all you need to run for pulse input, pulse output, and auto detect for DMR, P25P1, D-STAR, and X2-TDMA decoding. To use other decoding methods which cannot be auto detected, please use the following command line switches. `dsd` is all you need to run for pulse input, pulse output, and auto detect for DMR, P25P1, D-STAR, and X2-TDMA decoding. To use other decoding methods which cannot be auto detected, please use the following command line switches. Make sure to route audio into and out of DSD-FME using pavucontrol and virtual sinks as needed.
``` ```
-fi NXDN48 -fi NXDN48
@@ -32,12 +32,14 @@ Use Passive Frame Sync if voice in both slots becomes choppy or skips. Using Pas
``` ```
## Example Usage - New DMR Stereo, Ncurses Terminal, Pulse Input/Output, and Log Console to file ## Example Usage - New DMR Stereo, Ncurses Terminal, Pulse Input/Output, and Log Console to file
`dsd -fr -T -Z -N 2> voice.log` `dsd -fr -T -N 2> voice.log`
and in a second terminal tab, same folder, run and in a second terminal tab, same folder, run
`tail -n 40 -f voice.log` `tail -n 40 -f voice.log`
Then you can open up your pavucontrol "Pulse Audio Volume Control" or "Volume Control" application and route input into DSD-FME from any application and DSD-FME output to the left and right speakers respectively. (unlock the channel in the application stream and adjust left and right independently)
## Example Usage - RTL2832 Dongle Input ## Example Usage - RTL2832 Dongle Input
`dsd -fi -i rtl -c 154.9875M -P -2 -D 1 -G 36 -L 70 -U 6021 -Y 12` `dsd -fi -i rtl -c 154.9875M -P -2 -D 1 -G 36 -L 70 -U 6021 -Y 12`
@@ -54,7 +56,7 @@ and in a second terminal tab, same folder, run
-G set device gain (0-49) (default = 0 Auto Gain) -G set device gain (0-49) (default = 0 Auto Gain)
-L set rtl squelch to 25 (default = 0; off) -L set rtl squelch to 70 (default = 0; off)
-U set UDP port for rtl_fm remote control (default = 6020) -U set UDP port for rtl_fm remote control (default = 6020)
@@ -62,12 +64,14 @@ and in a second terminal tab, same folder, run
``` ```
## Example STDIN UDP from GQRX or SDR++, output to Pulse Audio, and append decoded audio to wav file ## Example STDIN UDP from GQRX or SDR++, output to Pulse Audio, and append decoded audio to wav file
Be sure to first start UDP output sink in GQRX or SDR++ and set VFO appropriately
`socat stdio udp-listen:7355 | dsd -fi -i - -w nxdn.wav` `socat stdio udp-listen:7355 | dsd -fi -i - -w nxdn.wav`
## Example Usage - Extra Information for Academic Study and Logging ## Example Usage - Extra Information for Academic Study and Logging
Be sure to create a folder called MBE first and run Be sure to create a folder called MBE first and run
`dsd -d ./MBE/ -Z -pu 2>> voice.log` `dsd -fa -Z -pu 2>> voice.log`
and in a second terminal tab, same folder, run and in a second terminal tab, same folder, run
@@ -78,7 +82,7 @@ The Current list of objectives include:
1. ~~Random Tinkering~~ More Random Tinkering 1. ~~Random Tinkering~~ More Random Tinkering
2. ~~Implemented Pulse Audio~~ Remove PortAudio, ~~improved Pulse Audio for stereo output and channel/slot separation~~ 2. ~~Implemented Pulse Audio~~ Remove remaining PortAudio code, ~~improved Pulse Audio for stereo output and channel/slot separation~~ and reimplement wav file saving using DMR Stereo method for stereo wav files, or seperate as per call wav files.
3. ~~Improve NXDN and DMR support~~ Continue to improve ~~NXDN and DMR~~ all data and voice decoding. 3. ~~Improve NXDN and DMR support~~ Continue to improve ~~NXDN and DMR~~ all data and voice decoding.

View File

@@ -17,16 +17,15 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
//pretty pretty colors //pretty pretty colors
#define KNRM "\x1B[0m"
#define KNRM "\x1B[0m" #define KRED "\x1B[31m"
#define KRED "\x1B[31m" #define KGRN "\x1B[32m"
#define KGRN "\x1B[32m" #define KYEL "\x1B[33m"
#define KYEL "\x1B[33m" #define KBLU "\x1B[34m"
#define KBLU "\x1B[34m" #define KMAG "\x1B[35m"
#define KMAG "\x1B[35m" #define KCYN "\x1B[36m"
#define KCYN "\x1B[36m" #define KWHT "\x1B[37m"
#define KWHT "\x1B[37m"
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
@@ -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 //look into making this not required by doing ifdef, make new c file for methods, and CLI case option for ncurses terminal
#include <locale.h> //move this stuff to dsd.h #include <locale.h> //move this stuff to dsd.h
#include <ncurses.h> //move this stuff to dsd.h #include <ncurses.h> //move this stuff to dsd.h
//
//
static volatile int exitflag; static volatile int exitflag;
typedef struct typedef struct
@@ -476,6 +473,8 @@ typedef struct
int payload_mfidR; int payload_mfidR;
int payload_mi; int payload_mi;
int payload_miR; int payload_miR;
int payload_lsfr;
int payload_lsfrR;
unsigned long long int K; unsigned long long int K;
unsigned int debug_audio_errors; unsigned int debug_audio_errors;
@@ -676,6 +675,8 @@ 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 skipDibit (dsd_opts * opts, dsd_state * state, int count);
void saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d); void saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d);
void saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d); void saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d);
void PrintAMBEData (dsd_opts * opts, dsd_state * state, char *ambe_d);
void PrintIMBEData (dsd_opts * opts, dsd_state * state, char *imbe_d);
int readImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d); int readImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d);
int readAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d); int readAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d);
void openMbeInFile (dsd_opts * opts, dsd_state * state); void openMbeInFile (dsd_opts * opts, dsd_state * state);
@@ -819,7 +820,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 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 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]); 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_init();
void Hamming_7_4_encode(unsigned char *origBits, unsigned char *encodedBits); void Hamming_7_4_encode(unsigned char *origBits, unsigned char *encodedBits);

View File

@@ -14,13 +14,13 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
char t_ambe_fr2[4][24] = {9}; char t_ambe_fr2[4][24] = {9};
char t_ambe_fr3[4][24] = {9}; char t_ambe_fr3[4][24] = {9};
const int *w, *x, *y, *z; const int *w, *x, *y, *z;
char sync[25]; char sync[25] = {0};
char syncdata[48]; char syncdata[48] = {0};
char cachdata[13] = {0}; char cachdata[13] = {0};
int mutecurrentslot; int mutecurrentslot;
int msMode; int msMode;
char cc[4]; char cc[4];
unsigned char EmbeddedSignalling[16]; unsigned char EmbeddedSignalling[16] = {0};
int EmbeddedSignallingOk; int EmbeddedSignallingOk;
unsigned int internalcolorcode; unsigned int internalcolorcode;
int internalslot; int internalslot;
@@ -71,10 +71,6 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
for(i = 0; i < 12; i++) for(i = 0; i < 12; i++)
{ {
dibit = getDibit(opts, state); dibit = getDibit(opts, state);
if(opts->inverted_dmr == 1)
{
//dibit = (dibit ^ 2);
}
cachdata[i] = dibit; cachdata[i] = dibit;
state->dmr_stereo_payload[i] = dibit; state->dmr_stereo_payload[i] = dibit;
if(i == 2) if(i == 2)
@@ -95,10 +91,6 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
for(i = 0; i < 36; i++) for(i = 0; i < 36; i++)
{ {
dibit = getDibit(opts, state); dibit = getDibit(opts, state);
if(opts->inverted_dmr == 1)
{
//dibit = (dibit ^ 2);
}
state->dmr_stereo_payload[i+12] = dibit; state->dmr_stereo_payload[i+12] = dibit;
redundancyA[i] = dibit; redundancyA[i] = dibit;
ambe_fr[*w][*x] = (1 & (dibit >> 1)); // bit 1 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++) for(i = 0; i < 18; i++)
{ {
dibit = getDibit(opts, state); dibit = getDibit(opts, state);
if(opts->inverted_dmr == 1)
{
//dibit = (dibit ^ 2);
}
state->dmr_stereo_payload[i+48] = dibit; state->dmr_stereo_payload[i+48] = dibit;
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1 ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
ambe_fr2[*y][*z] = (1 & dibit); // bit 0 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++) for(i = 0; i < 24; i++)
{ {
dibit = getDibit(opts, state); dibit = getDibit(opts, state);
if(opts->inverted_dmr == 1)
{
//dibit = (dibit ^ 2);
}
state->dmr_stereo_payload[i+66] = dibit; state->dmr_stereo_payload[i+66] = dibit;
syncdata[(2*i)] = (1 & (dibit >> 1)); // bit 1 syncdata[(2*i)] = (1 & (dibit >> 1)); // bit 1
syncdata[(2*i)+1] = (1 & dibit); // bit 0 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 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? if( EmbeddedSignallingOk == 1 ) //don't set on 1?
{ {
//state->color_code = (unsigned int)((EmbeddedSignalling[0] << 3) + (EmbeddedSignalling[1] << 2) + (EmbeddedSignalling[2] << 1) + EmbeddedSignalling[3]); //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 //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)
//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) 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 //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 )
//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()); fprintf (stderr,"%s ", getTime());
if (internalslot == 0) if (internalslot == 0)
{ {
sprintf(state->slot1light, "[slot1]"); sprintf(state->slot1light, "[slot1]");
sprintf(state->slot2light, " slot2 "); 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) if (opts->inverted_dmr == 0)
{ {
fprintf (stderr,"Sync: +DMR "); fprintf (stderr,"Sync: +DMR ");
@@ -301,8 +279,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
{ {
sprintf(state->slot2light, "[slot2]"); sprintf(state->slot2light, "[slot2]");
sprintf(state->slot1light, " slot1 "); 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) if (opts->inverted_dmr == 0)
{ {
fprintf (stderr,"Sync: +DMR "); fprintf (stderr,"Sync: +DMR ");
@@ -312,14 +289,19 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
vc2 = 1; vc2 = 1;
} }
processDMRdata (opts, state); 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; 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 //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)
//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) if (EmbeddedSignallingOk == 0)
{ {
@@ -327,26 +309,76 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
} }
skipcount = 0; //reset skip count if processing voice frames skipcount = 0; //reset skip count if processing voice frames
fprintf (stderr,"%s ", getTime()); fprintf (stderr,"%s ", getTime());
if (internalslot == 0) if (internalslot == 0)
{ {
state->dmrburstL = 16; //use 16 for Voice? 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); //fprintf (stderr,"Sync: +DMR [slot1] slot2 | Color Code=%02d | DMRSTEREO | VC%d \n", state->dmr_color_code, vc1);
if (opts->inverted_dmr == 0) 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) if (internalslot == 1)
{ {
state->dmrburstR = 16; //use 16 for Voice? 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) 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) 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->dmr_stereo = 0;
state->errs2R = 0; state->errs2R = 0;
state->errs2 = 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) void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
{ {
int i, j, k, l, dibit; int i, j, k, l, dibit;
@@ -462,8 +495,102 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
return curr; return curr;
} }
//skip the 18 dibits of the 2nd frame, since we can't play only half a frame //payload buffer
skipDibit (opts, state, 18); //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 //Setup for Third AMBE Frame
@@ -477,10 +604,6 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
for(i = 0; i < 36; i++) for(i = 0; i < 36; i++)
{ {
dibit = getDibit(opts, state); dibit = getDibit(opts, state);
if(opts->inverted_dmr == 1)
{
//dibit = (dibit ^ 2);
}
ambe_fr3[*w][*x] = (1 & (dibit >> 1)); // bit 1 ambe_fr3[*w][*x] = (1 & (dibit >> 1)); // bit 1
ambe_fr3[*y][*z] = (1 & dibit); // bit 0 ambe_fr3[*y][*z] = (1 & dibit); // bit 0
@@ -491,15 +614,44 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
} }
//fprintf (stderr,"\n%s ", getTime());
fprintf (stderr,"%s ", getTime()); fprintf (stderr,"%s ", getTime());
if (opts->inverted_dmr == 0) 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"); else
//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");
}
//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); processMbeFrame (opts, state, NULL, ambe_fr3, NULL);
dmrBS (opts, state); //bootstrap into full TDMA frame for BS mode dmrBS (opts, state); //bootstrap into full TDMA frame for BS mode
END:
//placing this below to fix compiler error, it will never run but compiler needs something there
if (0 == 1)
{
fprintf (stderr, "this is a dumb thing to have to fix");
}
} }

View File

@@ -57,7 +57,6 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
dibit_p = state->dmr_payload_p - 90; dibit_p = state->dmr_payload_p - 90;
} }
// CACH // CACH
for (i = 0; i < 12; i++) for (i = 0; i < 12; i++)
{ {
@@ -93,15 +92,7 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
state->slot1light[0] = ' '; state->slot1light[0] = ' ';
state->slot1light[6] = ' '; 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; cachdata[12] = 0;

View File

@@ -269,7 +269,8 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
//if ( (strcmp (sync, DMR_MS_VOICE_SYNC) == 0) ) //if ( (strcmp (sync, DMR_MS_VOICE_SYNC) == 0) )
//fixed to compensate for inverted signal //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) if (internalslot == 0)
@@ -380,21 +381,65 @@ void dmrMS (dsd_opts * opts, dsd_state * state)
fprintf (stderr,"%s ", getTime()); fprintf (stderr,"%s ", getTime());
if (internalslot == 0 && opts->inverted_dmr == 0) 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) 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) 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) 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) 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: SKIP:
skipDibit (opts, state, 144); //skip to next slot? skipDibit (opts, state, 144); //skip to next tdma channel
state->dmr_ms_rc = 0; state->dmr_ms_rc = 0;
//since we are in a repetitive loop, run ncursesPrinter here //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); dibit = (dibit ^ 2);
} }
state->dmr_stereo_payload[i] = dibit; state->dmr_stereo_payload[i] = dibit;
//fprintf(stderr, "%X", state->dmr_stereo_payload[i]);
} }
state->dmr_stereo = 0; 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) void dmrMSBootstrap (dsd_opts * opts, dsd_state * state)
{ {
int i, j, k, l, dibit; 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; dibit_p = state->dmr_payload_p - 90;
//payload buffer tests //payload buffer tests
//CACH + First Half Payload + Sync = 12 + 54 + 24 //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 for (i = 0; i < 90; i++) //90
{ {
state->dmr_stereo_payload[i] = *dibit_p; state->dmr_stereo_payload[i] = *dibit_p;
dibit_p++; dibit_p++;
//fprintf(stderr, "%X", state->dmr_stereo_payload[i]);
} }
//end payload buffer test //end payload buffer test
@@ -614,15 +657,39 @@ void dmrMSBootstrap (dsd_opts * opts, dsd_state * state)
z++; 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,"%s ", getTime());
//fprintf (stderr,"Sync: +DMR | Frame Sync | DMRSTEREO | VC1 FS \n");
if (opts->inverted_dmr == 0) 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_fr, NULL);
processMbeFrame (opts, state, NULL, ambe_fr2, NULL); processMbeFrame (opts, state, NULL, ambe_fr2, NULL);
processMbeFrame (opts, state, NULL, ambe_fr3, 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 //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 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++) for (i = 0; i < 54; i++)
{ {
dibit = getDibit(opts, state); dibit = getDibit(opts, state);
if (opts->inverted_dmr == 1)
{
dibit = (dibit ^ 2);
}
state->dmr_stereo_payload[i+90] = dibit; state->dmr_stereo_payload[i+90] = dibit;
} }
//fprintf(stderr, "\n"); //hide behind payload due to errs in data in MS mode
//print nice pretty lines if (opts->payload == 1)
//fprintf (stderr, "MS MODE ");
fprintf (stderr, "%s ", getTime());
//fprintf (stderr, "Sync: +MS DATA | Color Code=XX | DMRSTEREO | Data ");
if (opts->inverted_dmr == 0)
{ {
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->slot1light, "");
sprintf(state->slot2light, ""); sprintf(state->slot2light, "");
//process data //process data
state->dmr_stereo = 1; state->dmr_stereo = 1;
state->dmr_ms_mode = 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_stereo = 0;
state->dmr_ms_mode = 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 for (i = 0; i < 66; i++) //66
{ {
dibit = getDibit(opts, state); dibit = getDibit(opts, state);
if (opts->inverted_dmr == 1)
{
dibit = (dibit ^ 2);
}
state->dmr_stereo_payload[i] = dibit; state->dmr_stereo_payload[i] = dibit;
//fprintf(stderr, "%X", state->dmr_stereo_payload[i]);
} }
} }

View File

@@ -81,6 +81,7 @@ if (state->currentslot == 0 && state->K > 0 && state->dmr_so & 0x40 && state->pa
fprintf (stderr, "%s", KNRM); fprintf (stderr, "%s", KNRM);
k = BP[state->K]; k = BP[state->K];
k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k ); k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k );
//fprintf (stderr, "\nK=0x%X\n", k);
for(Frame = 0; Frame < 6; Frame++) for(Frame = 0; Frame < 6; Frame++)
{ {
for(i = 0; i < 3; i++) 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); fprintf (stderr, "%s", KNRM);
k = BP[state->K]; k = BP[state->K];
k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k ); k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k );
//fprintf (stderr, "\nK=0x%X\n", k);
for(Frame = 0; Frame < 6; Frame++) for(Frame = 0; Frame < 6; Frame++)
{ {
for(i = 0; i < 3; i++) for(i = 0; i < 3; i++)
@@ -116,6 +118,10 @@ if (state->currentslot == 1 && state->K > 0 && state->dmr_soR & 0x40 && state->p
// //
if (state->currentslot == 0) if (state->currentslot == 0)
{ {
if (opts->payload == 1)
{
fprintf(stderr, "\n"); //line break for AMBE printer
}
for(Frame = 0; Frame < 6; Frame++) //6 for(Frame = 0; Frame < 6; Frame++) //6
{ {
/* 1 DMR frame contains 3 AMBE voice samples */ /* 1 DMR frame contains 3 AMBE voice samples */
@@ -130,19 +136,19 @@ if (state->currentslot == 0)
TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i], TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i],
state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
if (opts->payload == 1)
{
PrintAMBEData(opts, state, TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i]);
}
if (opts->mbe_out_f != NULL) if (opts->mbe_out_f != NULL)
{ {
saveAmbe2450Data (opts, state, TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i]); saveAmbe2450Data (opts, state, TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i]);
} }
if (opts->errorbars == 1)
{
//fprintf(stderr, "%s", state->err_str);
}
state->debug_audio_errors += *errs2; state->debug_audio_errors += *errs2;
processAudio(opts, state); processAudio(opts, state);
//playSynthesizedVoice (opts, state);
if (opts->wav_out_f != NULL) if (opts->wav_out_f != NULL)
{ {
@@ -160,6 +166,10 @@ if (state->currentslot == 0)
if (state->currentslot == 1) if (state->currentslot == 1)
{ {
if (opts->payload == 1)
{
fprintf(stderr, "\n"); //line break for AMBE printer
}
for(Frame = 0; Frame < 6; Frame++) for(Frame = 0; Frame < 6; Frame++)
{ {
/* 1 DMR frame contains 3 AMBE voice samples */ /* 1 DMR frame contains 3 AMBE voice samples */
@@ -174,19 +184,20 @@ if (state->currentslot == 0)
TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i], TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i],
state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
if (opts->payload == 1)
{
PrintAMBEData(opts, state, TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i]);
}
if (opts->mbe_out_f != NULL) if (opts->mbe_out_f != NULL)
{ {
saveAmbe2450Data (opts, state, TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i]); saveAmbe2450Data (opts, state, TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i]);
} }
if (opts->errorbars == 1)
{
//fprintf(stderr, "%s", state->err_str);
}
state->debug_audio_errors += *errs2; state->debug_audio_errors += *errs2;
processAudio(opts, state); processAudio(opts, state);
//playSynthesizedVoice (opts, state);
if (opts->wav_out_f != NULL) if (opts->wav_out_f != NULL)
{ {

View File

@@ -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 */ /* Print the destination ID (TG) and the source ID */
fprintf (stderr, "%s ", KGRN); fprintf (stderr, "%s ", KGRN);
fprintf(stderr, "\n TG=%u Src=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); fprintf(stderr, "\n TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID);
//state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress; //state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress;
//state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress; //state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress;
//state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID; //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, "%s \n", KRED);
fprintf (stderr, " SLOT %d", state->currentslot+1); fprintf (stderr, " SLOT %d", state->currentslot+1);
fprintf(stderr, " TG=%u Src=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID);
fprintf (stderr, "%s ", KNRM); fprintf (stderr, "%s ", KNRM);
//fprintf(stderr, "(CRC OK ) "); //fprintf(stderr, "(CRC OK ) ");
if (TSVoiceSupFrame->FullLC.FullLinkControlOpcode == 0) //other opcodes may convey callsigns, names, etc. 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, "%s \n", KRED);
fprintf (stderr, " SLOT %d", state->currentslot+1); fprintf (stderr, " SLOT %d", state->currentslot+1);
fprintf(stderr, " TG=%u Src=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID);
fprintf(stderr, "RAS (FEC OK/CRC ERR)"); //tlc fprintf(stderr, "RAS (FEC OK/CRC ERR)"); //tlc
fprintf (stderr, "%s ", KNRM); fprintf (stderr, "%s ", KNRM);
if (TSVoiceSupFrame->FullLC.FullLinkControlOpcode == 0) //other opcodes may convey callsigns, names, etc. 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, "\n");
} }
fprintf (stderr, " SLOT %d", state->currentslot+1); fprintf (stderr, " SLOT %d", state->currentslot+1);
fprintf(stderr, " TG=%u Src=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID);
fprintf (stderr, "%s ", KNRM); fprintf (stderr, "%s ", KNRM);
//fprintf(stderr, "(CRC OK ) "); //fprintf(stderr, "(CRC OK ) ");
if (state->currentslot == 0) if (state->currentslot == 0)
@@ -2458,8 +2458,8 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state)
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
fprintf (stderr, " SLOT %d", state->currentslot+1); fprintf (stderr, " SLOT %d", state->currentslot+1);
fprintf(stderr, " TG=%u Src=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress);
fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID);
fprintf (stderr, "%s ", KRED); fprintf (stderr, "%s ", KRED);
fprintf(stderr, "RAS (FEC OK/CRC ERR) "); fprintf(stderr, "RAS (FEC OK/CRC ERR) ");
fprintf (stderr, "%s ", KNRM); fprintf (stderr, "%s ", KNRM);
@@ -2537,7 +2537,44 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state)
} /* End ProcessVoiceBurstSync() */ } /* 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 * @brief : This function compute the CRC-CCITT of the DMR data
* by using the polynomial x^16 + x^12 + x^5 + 1 * by using the polynomial x^16 + x^12 + x^5 + 1

View File

@@ -36,12 +36,6 @@ void processDMRvoice (dsd_opts * opts, dsd_state * state)
unsigned char EmbeddedSignalling[16]; unsigned char EmbeddedSignalling[16];
unsigned int EmbeddedSignallingOk; 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 #ifdef DMR_DUMP
int k; int k;
char syncbits[49]; char syncbits[49];
@@ -115,16 +109,7 @@ void processDMRvoice (dsd_opts * opts, dsd_state * state)
state->slot1light[0] = ' '; state->slot1light[0] = ' ';
state->slot1light[6] = ' '; 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; cachdata[12] = 0;
@@ -389,30 +374,6 @@ void processDMRvoice (dsd_opts * opts, dsd_state * state)
sprintf(state->slot2light, "[sLoT2]"); 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 #ifdef DMR_DUMP
k = 0; k = 0;
for(i = 0; i < 24; i++) for(i = 0; i < 24; i++)
@@ -675,7 +636,6 @@ void processDMRvoice (dsd_opts * opts, dsd_state * state)
fprintf (stderr, "%s", KNRM); fprintf (stderr, "%s", KNRM);
} }
//fprintf(stderr, " VOICE e: \n");
fprintf(stderr, " VOICE "); fprintf(stderr, " VOICE ");
} }
@@ -685,9 +645,13 @@ void processDMRvoice (dsd_opts * opts, dsd_state * state)
/* Perform the DMR voice decoding */ /* Perform the DMR voice decoding */
ProcessDMR(opts, state); ProcessDMR(opts, state);
/* Print DMR frame (if needed) */ //LSFR if required
//DMRVoiceFrameProcess(opts, state); //HERE HERE, was enabled, disabled so I could build if ( (state->currentslot == 0 && state->payload_keyid != 0 && opts->payload == 1) ||
//JUMP: (state->currentslot == 1 && state->payload_keyidR != 0 && opts->payload == 1) )
{
LSFR(state);
}
if(opts->errorbars == 1) if(opts->errorbars == 1)
{ {
fprintf(stderr, "\n"); fprintf(stderr, "\n");

View File

@@ -30,8 +30,7 @@ saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d)
k = 0; k = 0;
if (opts->payload == 1) //make opt variable later on to toggle this if (opts->payload == 1) //make opt variable later on to toggle this
{ {
fprintf(stderr, "\n IMBE "); //fprintf(stderr, "\n IMBE ");
//fprintf(stderr, "ALGID=%X KEYID=%X\n", state->payload_algid, state->payload_keyid);
} }
for (i = 0; i < 11; i++) for (i = 0; i < 11; i++)
@@ -46,13 +45,13 @@ saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d)
} }
if (opts->payload == 1) //make opt variable later on to toggle this if (opts->payload == 1) //make opt variable later on to toggle this
{ {
fprintf (stderr, "%02X", b); //fprintf (stderr, "%02X", b);
} }
fputc (b, opts->mbe_out_f); fputc (b, opts->mbe_out_f);
} }
if (opts->payload == 1) if (opts->payload == 1)
{ {
fprintf(stderr, " err = [%X] [%X] ", state->errs, state->errs2); //fprintf(stderr, " err = [%X] [%X] ", state->errs, state->errs2);
} }
fflush (opts->mbe_out_f); fflush (opts->mbe_out_f);
} }
@@ -70,7 +69,7 @@ saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d)
k = 0; k = 0;
if (opts->payload == 1) //make opt variable later on to toggle this if (opts->payload == 1) //make opt variable later on to toggle this
{ {
fprintf(stderr, "\n AMBE "); //fprintf(stderr, "\n AMBE ");
} }
//for (i = 0; i < 6; i++) //for (i = 0; i < 6; i++)
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 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
@@ -84,24 +83,109 @@ saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d)
} }
if (opts->payload == 1 && i < 6) //make opt variable later on to toggle this if (opts->payload == 1 && i < 6) //make opt variable later on to toggle this
{ {
fprintf (stderr, "%02X", b); //fprintf (stderr, "%02X", b);
} }
if (opts->payload == 1 && i == 6) //7th octet should only contain 1 bit? value will be either 0x00 or 0x80? 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? //fprintf (stderr, "%02X", b & 0x80); //7th octet should only contain 1 bit?
} }
fputc (b, opts->mbe_out_f); fputc (b, opts->mbe_out_f);
} }
if (opts->payload == 1) if (opts->payload == 1)
{ {
fprintf(stderr, " err = [%X] [%X] ", state->errs, state->errs2); //fprintf(stderr, " err = [%X] [%X] ", state->errs, state->errs2);
} }
b = ambe_d[48]; b = ambe_d[48];
fputc (b, opts->mbe_out_f); fputc (b, opts->mbe_out_f);
fflush (opts->mbe_out_f); fflush (opts->mbe_out_f);
} }
void
PrintIMBEData (dsd_opts * opts, dsd_state * state, char *imbe_d) //for P25P1 and ProVoice
{
int i, j, k;
unsigned char b;
unsigned char err;
err = (unsigned char) state->errs2;
k = 0;
if (opts->payload == 1) //print IMBE info
{
fprintf(stderr, "\n IMBE ");
}
for (i = 0; i < 11; i++)
{
b = 0;
for (j = 0; j < 8; j++)
{
b = b << 1;
b = b + imbe_d[k];
k++;
}
if (opts->payload == 1)
{
fprintf (stderr, "%02X", b);
}
}
if (opts->payload == 1)
{
fprintf(stderr, " err = [%X] [%X] ", state->errs, state->errs2);
}
//fprintf (stderr, "\n");
}
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->dmr_stereo == 0)
{
fprintf (stderr, "\n");
}
if (opts->payload == 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];
if (opts->dmr_stereo == 1)
{
fprintf (stderr, "\n");
}
}
int int
readImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d) readImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d)
{ {

View File

@@ -46,7 +46,7 @@ int pretty_colors()
short int butt = 1; short int butt = 1;
char * FM_banner[9] = { char * FM_banner[9] = {
" CTRL + C twice to exit", " 2022 Dove Award Winner CTRL + C twice to exit",
" ██████╗ ██████╗██████╗    ███████╗███╗ ███╗███████╗", " ██████╗ ██████╗██████╗    ███████╗███╗ ███╗███████╗",
" ██╔══██╗██╔════╝██╔══██╗   ██╔════╝████╗ ████║██╔════╝", " ██╔══██╗██╔════╝██╔══██╗   ██╔════╝████╗ ████║██╔════╝",
" ██║ ██║╚█████╗ ██║ ██║   █████╗ ██╔████╔██║█████╗ ", " ██║ ██║╚█████╗ ██║ ██║   █████╗ ██╔████╔██║█████╗ ",
@@ -225,7 +225,10 @@ initOpts (dsd_opts * opts)
opts->inverted_dpmr = 0; opts->inverted_dpmr = 0;
opts->dmr_stereo = 0; opts->dmr_stereo = 0;
opts->aggressive_framesync = 1; //more aggressive to combat wonk wonk voice decoding opts->aggressive_framesync = 1; //more aggressive to combat wonk wonk voice decoding
//opts->audio_in_type = 0; //see if initializing these values causes issues elsewhere, if so, then disable.
opts->audio_in_type = 0; //this was never initialized, causes issues on rPI 64 (bullseye) if not initialized
opts->audio_out_type = 0; //this was never initialized, causes issues on rPI 64 (bullseye) if not initialized
} }
void void
@@ -420,7 +423,8 @@ initState (dsd_state * state)
void void
usage () 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 ("\n");
printf ("Usage: dsd [options] Live scanner mode\n"); printf ("Usage: dsd [options] Live scanner mode\n");
printf (" or: dsd [options] -r <files> Read/Play saved mbe data from file(s)\n"); printf (" or: dsd [options] -r <files> Read/Play saved mbe data from file(s)\n");
@@ -562,10 +566,12 @@ if (opts->audio_in_type == 1)
open_rtlsdr_stream(opts); open_rtlsdr_stream(opts);
} }
#endif #endif
if (opts->audio_in_type == 0){ if (opts->audio_in_type == 0)
{
openPulseInput(opts); openPulseInput(opts);
} }
if (opts->audio_out_type == 0){ if (opts->audio_out_type == 0)
{
openPulseOutput(opts); openPulseOutput(opts);
} }
@@ -878,12 +884,12 @@ main (int argc, char **argv)
break; break;
case 'T': 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 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_rate_out = 24000;
opts.pulse_digi_out_channels = 2; opts.pulse_digi_out_channels = 2;
fprintf (stderr, "%s", KRED); 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,"DMR Stereo will disable WAV and MBE file saving!\n");
fprintf (stderr,"Also consider using -F if playback is too choppy!\n"); fprintf (stderr,"Also consider using -F if playback is too choppy!\n");
fprintf (stderr, "%s", KNRM); fprintf (stderr, "%s", KNRM);

View File

@@ -17,7 +17,7 @@
#include "dsd.h" #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 void
playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv) 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 void
processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char ambe_fr[4][24], char imbe7100_fr[7][24]) 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 //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? //strncpy (state->err_buf, state->err_str, sizeof(state->err_str)); //right at the very top before err_str gets returned?
int i; int i;
char imbe_d[88]; char imbe_d[88];
char ambe_d[49]; char ambe_d[49];
char ambe_d_str[50]; char ambe_d_str[50];
#ifdef AMBE_PACKET_OUT unsigned long long int k;
int x;
#endif
for (i = 0; i < 88; i++) for (i = 0; i < 88; i++)
{ {
imbe_d[i] = 0; imbe_d[i] = 0;
} }
for (i = 0; i < 49; i++)
{
ambe_d[i] = 0;
}
if ((state->synctype == 0) || (state->synctype == 1)) if ((state->synctype == 0) || (state->synctype == 1))
{ {
@@ -99,52 +142,105 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
// 1 -P25p1 // 1 -P25p1
mbe_processImbe7200x4400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, imbe_fr, imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); mbe_processImbe7200x4400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, imbe_fr, imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
//mbe_processImbe7200x4400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, imbe_fr, processed_block, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); if (opts->payload == 1)
{
PrintIMBEData (opts, state, imbe_d);
}
if (opts->mbe_out_f != NULL) if (opts->mbe_out_f != NULL)
{ {
saveImbe4400Data (opts, state, imbe_d); saveImbe4400Data (opts, state, imbe_d);
} }
} }
else if ((state->synctype == 14) || (state->synctype == 15)) 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, 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->payload == 1)
{
PrintIMBEData (opts, state, imbe_d);
}
if (opts->mbe_out_f != NULL) if (opts->mbe_out_f != NULL)
{ {
saveImbe4400Data (opts, state, imbe_d); saveImbe4400Data (opts, state, imbe_d);
} }
} }
else if ((state->synctype == 6) || (state->synctype == 7)) else if ((state->synctype == 6) || (state->synctype == 7))
{ {
mbe_processAmbe3600x2400Framef (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); mbe_processAmbe3600x2400Framef (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);
}
if (opts->mbe_out_f != NULL) if (opts->mbe_out_f != NULL)
{ {
saveAmbe2450Data (opts, state, ambe_d); saveAmbe2450Data (opts, state, ambe_d);
} }
} }
else else
{ {
//stereo slots and slot 0 (left slot) //stereo slots and slot 0 (left slot)
if (state->currentslot == 0 && opts->dmr_stereo == 1) 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) //stereo slots and slot 1 (right slot)
if (state->currentslot == 1 && opts->dmr_stereo == 1) 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); //seperate the ecc, demodulation, slip in xor, and processdata instead?
//just put this in here for troubleshooting for now state->errsR = mbe_eccAmbe3600x2450C0 (ambe_fr);
if (opts->mbe_out_f != NULL) 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, NXDN?
if (opts->dmr_stereo == 0) 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); 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);
}
if (opts->mbe_out_f != NULL) if (opts->mbe_out_f != NULL)
{ {
saveAmbe2450Data (opts, state, ambe_d); saveAmbe2450Data (opts, state, ambe_d);
@@ -201,6 +297,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
} }
/* This function decipher data */ /* This function decipher data */
/* //does anything even call this function?
static void DecipherData(char * Input, char * KeyStream, char * Output, int NbData) static void DecipherData(char * Input, char * KeyStream, char * Output, int NbData)
{ {
int i; int i;
@@ -210,3 +307,4 @@ static void DecipherData(char * Input, char * KeyStream, char * Output, int NbDa
Output[i] = Input[i] ^ KeyStream[i]; Output[i] = Input[i] ^ KeyStream[i];
} }
} }
*/

View File

@@ -45,7 +45,7 @@ char versionstr[25];
unsigned long long int call_matrix[33][6]; unsigned long long int call_matrix[33][6];
char * FM_bannerN[9] = { char * FM_bannerN[9] = {
" CTRL + C twice to exit", " 2022 Dove Award Winner CTRL + C twice to exit",
" ██████╗ ██████╗██████╗    ███████╗███╗ ███╗███████╗", " ██████╗ ██████╗██████╗    ███████╗███╗ ███╗███████╗",
" ██╔══██╗██╔════╝██╔══██╗   ██╔════╝████╗ ████║██╔════╝", " ██╔══██╗██╔════╝██╔══██╗   ██╔════╝████╗ ████║██╔════╝",
" ██║ ██║╚█████╗ ██║ ██║   █████╗ ██╔████╔██║█████╗ ", " ██║ ██║╚█████╗ ██║ ██║   █████╗ ██╔████╔██║█████╗ ",

View File

@@ -143,6 +143,10 @@ void processNXDNVoice (dsd_opts * opts, dsd_state * state)
y++; y++;
z++; z++;
} }
if (opts->payload == 1)
{
//fprintf(stderr, "\n");
}
processMbeFrame (opts, state, NULL, ambe_fr, NULL); processMbeFrame (opts, state, NULL, ambe_fr, NULL);
} /* End for (j = 0; j < 4; j++) */ } /* End for (j = 0; j < 4; j++) */