Merge pull request #53 from lwvmobile/pulse-raw2

Fix Raw Audio Monitoring
This commit is contained in:
lwvmobile
2022-04-03 06:21:25 -04:00
committed by GitHub
15 changed files with 450 additions and 499 deletions

View File

@@ -241,6 +241,7 @@ typedef struct
unsigned int errs1[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4]; /* 8 x errors #1 computed when demodulate the AMBE voice bit of the frame */ unsigned int errs1[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4]; /* 8 x errors #1 computed when demodulate the AMBE voice bit of the frame */
unsigned int errs2[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4]; /* 8 x errors #2 computed when demodulate the AMBE voice bit of the frame */ unsigned int errs2[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4]; /* 8 x errors #2 computed when demodulate the AMBE voice bit of the frame */
unsigned char AmbeBit[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4][49]; /* 8 x 49 bit of AMBE voice of the frame */ unsigned char AmbeBit[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4][49]; /* 8 x 49 bit of AMBE voice of the frame */
//unsigned char AmbeBit[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4][36];
unsigned char CCHData[NB_OF_DPMR_VOICE_FRAME_TO_DECODE][48]; unsigned char CCHData[NB_OF_DPMR_VOICE_FRAME_TO_DECODE][48];
unsigned int CCHDataHammingOk[NB_OF_DPMR_VOICE_FRAME_TO_DECODE]; unsigned int CCHDataHammingOk[NB_OF_DPMR_VOICE_FRAME_TO_DECODE];
unsigned char CCHDataCRC[NB_OF_DPMR_VOICE_FRAME_TO_DECODE]; unsigned char CCHDataCRC[NB_OF_DPMR_VOICE_FRAME_TO_DECODE];
@@ -601,6 +602,11 @@ typedef struct
#define PROVOICE_EA_SYNC "31131311331331111133131311311133" #define PROVOICE_EA_SYNC "31131311331331111133131311311133"
//LEH dPMR //LEH dPMR
/* dPMR Frame Sync 1 - 48 bits sequence
* HEX : 57 FF 5F 75 D5 77
* Binary : 0101 0111 1111 1111 0101 1111 0111 0101 1101 0101 0111 0111
* Dibit : 1 1 1 3 3 3 3 3 1 1 3 3 1 3 1 1 3 1 1 1 1 3 1 3 */
#define DPMR_FRAME_SYNC_1 "111333331133131131111313" #define DPMR_FRAME_SYNC_1 "111333331133131131111313"
/* dPMR Frame Sync 2 - 24 bits sequence /* dPMR Frame Sync 2 - 24 bits sequence
@@ -620,12 +626,14 @@ typedef struct
* Binary : 1111 1101 0101 0101 1111 0101 1101 1111 0111 1111 1101 1101 * Binary : 1111 1101 0101 0101 1111 0101 1101 1111 0111 1111 1101 1101
* Dibit : 3 3 3 1 1 1 1 1 3 3 1 1 3 1 3 3 1 3 3 3 3 1 3 1 */ * Dibit : 3 3 3 1 1 1 1 1 3 3 1 1 3 1 3 3 1 3 3 3 3 1 3 1 */
#define DPMR_FRAME_SYNC_4 "333111113311313313333131" #define DPMR_FRAME_SYNC_4 "333111113311313313333131"
//#define DPMR_FRAME_SYNC_4 "111333331133131131111313"
/* dPMR Frame Sync 1 to 4 - Inverted */ /* dPMR Frame Sync 1 to 4 - Inverted */
#define INV_DPMR_FRAME_SYNC_1 "333111113311313313333131" #define INV_DPMR_FRAME_SYNC_1 "333111113311313313333131"
#define INV_DPMR_FRAME_SYNC_2 "331111313113" #define INV_DPMR_FRAME_SYNC_2 "331111313113"
#define INV_DPMR_FRAME_SYNC_3 "311313111133" #define INV_DPMR_FRAME_SYNC_3 "311313111133"
#define INV_DPMR_FRAME_SYNC_4 "111333331133131131111313" #define INV_DPMR_FRAME_SYNC_4 "111333331133131131111313"
//#define INV_DPMR_FRAME_SYNC_4 "333111113311313313333131"
// //
/* /*
@@ -743,9 +751,6 @@ uint16_t CRC15BitNXDN(uint8_t * BufferIn, uint32_t BitLength);
uint16_t CRC12BitNXDN(uint8_t * BufferIn, uint32_t BitLength); uint16_t CRC12BitNXDN(uint8_t * BufferIn, uint32_t BitLength);
uint8_t CRC6BitNXDN(uint8_t * BufferIn, uint32_t BitLength); uint8_t CRC6BitNXDN(uint8_t * BufferIn, uint32_t BitLength);
void ScrambledNXDNVoiceBit(int * LfsrValue, char * BufferIn, char * BufferOut, int NbOfBitToScramble); void ScrambledNXDNVoiceBit(int * LfsrValue, char * BufferIn, char * BufferOut, int NbOfBitToScramble);
void NxdnEncryptionStreamGeneration (dsd_opts* opts, dsd_state* state, uint8_t KeyStream[1664]);
void processMbeFrameEncrypted (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char ambe_fr[4][24], char imbe7100_fr[7][24], char ambe_keystream[49], char imbe_keystream[88]);
//LEH dPMR //LEH dPMR
void dPMRVoiceFrameProcess(dsd_opts * opts, dsd_state * state); void dPMRVoiceFrameProcess(dsd_opts * opts, dsd_state * state);
@@ -759,7 +764,7 @@ uint8_t CRC8BitdPMR(uint8_t * BufferIn, uint32_t BitLength);
void ConvertAirInterfaceID(uint32_t AI_ID, uint8_t ID[8]); void ConvertAirInterfaceID(uint32_t AI_ID, uint8_t ID[8]);
int32_t GetdPmrColorCode(uint8_t ChannelCodeBit[24]); int32_t GetdPmrColorCode(uint8_t ChannelCodeBit[24]);
//LEH DMR //LEH DMR
void ProcessDMREncryption (dsd_opts * opts, dsd_state * state); //consider if this is needed void ProcessDMR (dsd_opts * opts, dsd_state * state);
void DMRDataFrameProcess(dsd_opts * opts, dsd_state * state); void DMRDataFrameProcess(dsd_opts * opts, dsd_state * state);
void DMRVoiceFrameProcess(dsd_opts * opts, dsd_state * state); void DMRVoiceFrameProcess(dsd_opts * opts, dsd_state * state);
//BPTC (Block Product Turbo Code) functions //BPTC (Block Product Turbo Code) functions

View File

@@ -18,9 +18,10 @@
#include "dsd.h" #include "dsd.h"
#include "dmr_const.h" #include "dmr_const.h"
#include "p25p1_check_hdu.h" #include "p25p1_check_hdu.h"
//
//
void ProcessDMREncryption (dsd_opts * opts, dsd_state * state) void ProcessDMR (dsd_opts * opts, dsd_state * state)
{ {
uint32_t i, j; uint32_t i, j;
uint32_t Frame; uint32_t Frame;
@@ -33,6 +34,7 @@ void ProcessDMREncryption (dsd_opts * opts, dsd_state * state)
int *errsR; int *errsR;
int *errs2R; int *errs2R;
unsigned long long int k; unsigned long long int k;
int x;
k = 0; k = 0;
if(state->currentslot == 0) if(state->currentslot == 0)
@@ -43,11 +45,11 @@ void ProcessDMREncryption (dsd_opts * opts, dsd_state * state)
{ {
TSVoiceSupFrame = &state->TS2SuperFrame; TSVoiceSupFrame = &state->TS2SuperFrame;
} }
//TSVoiceSupFrameL = &state->TS1SuperFrame; //TSVoiceSupFrameL = &state->TS1SuperFrame;
//TSVoiceSupFrameR = &state->TS2SuperFrame; //TSVoiceSupFrameR = &state->TS2SuperFrame;
// //
//
// //
for(Frame = 0; Frame < 6; Frame++) for(Frame = 0; Frame < 6; Frame++)
{ {
@@ -57,7 +59,6 @@ void ProcessDMREncryption (dsd_opts * opts, dsd_state * state)
{ {
errs = (int*)&(TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs1[i]); errs = (int*)&(TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs1[i]);
//fprintf (stderr, "[%02X] ", TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i]);
errs2 = (int*)&(TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs2[i]); errs2 = (int*)&(TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs2[i]);
state->errs = TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs1[i]; //correct placement state->errs = TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs1[i]; //correct placement
state->errs2 = TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs2[i]; //correct placement state->errs2 = TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs2[i]; //correct placement

View File

@@ -306,18 +306,18 @@ void ProcessDataData(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint
for(i = 0; i < 16; i++) for(i = 0; i < 16; i++)
{ {
CRCExtracted = CRCExtracted << 1; CRCExtracted = CRCExtracted << 1;
//CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 72] & 1); CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 72] & 1);
CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 80] & 1); //80-96 for PI header //CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 80] & 1); //80-96 for PI header
} }
//Look into whether or not we need to run these CRC checks for this header information //Look into whether or not we need to run these CRC checks for this header information
//and see if its applied the same or differently //and see if its applied the same or differently
/* Apply the CRC mask (see DMR standard B.3.12 Data Type CRC Mask) */ /* Apply the CRC mask (see DMR standard B.3.12 Data Type CRC Mask) */
//CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI? CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI?
//CRCExtracted = CRCExtracted ^ 0x6969; //CRCExtracted = CRCExtracted ^ 0x6969;
/* Check/correct the full link control data and compute the Reed-Solomon (12,9) CRC */ /* Check/correct the full link control data and compute the Reed-Solomon (12,9) CRC */
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696); CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696);
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969); //CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969);
/* Convert corrected 12 bytes into 96 bits */ /* Convert corrected 12 bytes into 96 bits */
@@ -332,6 +332,18 @@ void ProcessDataData(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint
DmrDataBit[j + 6] = (DmrDataByte[i] >> 1) & 0x01; DmrDataBit[j + 6] = (DmrDataByte[i] >> 1) & 0x01;
DmrDataBit[j + 7] = (DmrDataByte[i] >> 0) & 0x01; DmrDataBit[j + 7] = (DmrDataByte[i] >> 0) & 0x01;
} }
//test
if((IrrecoverableErrors == 0) && CRCCorrect)
{
fprintf (stderr, "\n(Data CRC Okay)");
}
else if((IrrecoverableErrors == 0))
{
fprintf (stderr, "\n(Data FEC Okay)");
}
else fprintf (stderr, ("\n(Data CRC Fail, FEC Fail)"));
// //
if (DmrDataByte[0] == 0x43) if (DmrDataByte[0] == 0x43)
{ {
@@ -904,20 +916,31 @@ void Process12Data(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_
for(i = 0; i < 16; i++) for(i = 0; i < 16; i++)
{ {
CRCExtracted = CRCExtracted << 1; CRCExtracted = CRCExtracted << 1;
//CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 72] & 1); CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 72] & 1);
CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 80] & 1); //80-96 for PI header //CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 80] & 1); //80-96 for PI header
} }
//Look into whether or not we need to run these CRC checks for this header information //Look into whether or not we need to run these CRC checks for this header information
//and see if its applied the same or differently //and see if its applied the same or differently
/* Apply the CRC mask (see DMR standard B.3.12 Data Type CRC Mask) */ /* Apply the CRC mask (see DMR standard B.3.12 Data Type CRC Mask) */
//CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI? CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI?
//CRCExtracted = CRCExtracted ^ 0x6969; //CRCExtracted = CRCExtracted ^ 0x6969;
/* Check/correct the full link control data and compute the Reed-Solomon (12,9) CRC */ /* Check/correct the full link control data and compute the Reed-Solomon (12,9) CRC */
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696); CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696);
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969); //CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969);
//test
if((IrrecoverableErrors == 0) && CRCCorrect)
{
fprintf (stderr, "\n(1/2 Rate CRC Okay)");
}
else if((IrrecoverableErrors == 0))
{
fprintf (stderr, "\n(1/2 Rate FEC Okay)");
}
else fprintf (stderr, ("\n(1/2 Rate CRC Fail, FEC Fail)"));
/* Convert corrected 12 bytes into 96 bits */ /* Convert corrected 12 bytes into 96 bits */
for(i = 0, j = 0; i < 12; i++, j+=8) for(i = 0, j = 0; i < 12; i++, j+=8)
{ {
@@ -939,7 +962,7 @@ void Process12Data(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_
//ARS? //ARS?
if ( (state->dmr_12_rate_sf[0] & 0x3F) == 0x0C) if ( (state->dmr_12_rate_sf[0] & 0x3F) == 0x0C)
{ {
fprintf (stderr, "\n Source: "); fprintf (stderr, "\n Source:");
fprintf (stderr, " %03d.%03d.%03d.%03d", (state->dmr_12_rate_sf[0] & 0x3F), state->dmr_12_rate_sf[1], state->dmr_12_rate_sf[2], state->dmr_12_rate_sf[3]); //strip first two bits off 1st byte fprintf (stderr, " %03d.%03d.%03d.%03d", (state->dmr_12_rate_sf[0] & 0x3F), state->dmr_12_rate_sf[1], state->dmr_12_rate_sf[2], state->dmr_12_rate_sf[3]); //strip first two bits off 1st byte
fprintf (stderr, " [%08d]", (state->dmr_12_rate_sf[1] <<16 ) + (state->dmr_12_rate_sf[2] << 8) + state->dmr_12_rate_sf[3] ); fprintf (stderr, " [%08d]", (state->dmr_12_rate_sf[1] <<16 ) + (state->dmr_12_rate_sf[2] << 8) + state->dmr_12_rate_sf[3] );
fprintf (stderr, " - Port %05d", (state->dmr_12_rate_sf[8] << 8) + state->dmr_12_rate_sf[9]); fprintf (stderr, " - Port %05d", (state->dmr_12_rate_sf[8] << 8) + state->dmr_12_rate_sf[9]);
@@ -1093,11 +1116,22 @@ void ProcessCSBK(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t
//and see if its applied the same or differently //and see if its applied the same or differently
/* Apply the CRC mask (see DMR standard B.3.12 Data Type CRC Mask) */ /* Apply the CRC mask (see DMR standard B.3.12 Data Type CRC Mask) */
//CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI? //CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI?
//CRCExtracted = CRCExtracted ^ 0x6969; CRCExtracted = CRCExtracted ^ 0x6969;
/* Check/correct the full link control data and compute the Reed-Solomon (12,9) CRC */ /* Check/correct the full link control data and compute the Reed-Solomon (12,9) CRC */
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696); //CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696);
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969); CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969);
//test
if((IrrecoverableErrors == 0) && CRCCorrect)
{
fprintf (stderr, "\n(CSBK CRC Okay)");
}
else if((IrrecoverableErrors == 0))
{
fprintf (stderr, "\n(CSBK FEC Okay)");
}
else fprintf (stderr, ("\n(CSBK CRC Fail, FEC Fail)"));
/* Convert corrected 12 bytes into 96 bits */ /* Convert corrected 12 bytes into 96 bits */
for(i = 0, j = 0; i < 12; i++, j+=8) for(i = 0, j = 0; i < 12; i++, j+=8)
@@ -1247,8 +1281,9 @@ void ProcessCSBK(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t
//possible Site identifier, CSBK Aloha? //possible Site identifier, CSBK Aloha?
if (csbk_o == 0x19) //DmrDataByte[0] == 0x99? if (csbk_o == 0x19) //DmrDataByte[0] == 0x99?
{ {
fprintf (stderr, "\n Site ID %d-%d.%d", (DmrDataByte[2] & 0xF0 >> 4), DmrDataByte[2] & 0xF, DmrDataByte[3]); fprintf (stderr, "\n CSBK Aloha?");
fprintf (stderr, " DCC %d", DmrDataByte[1]); //fprintf (stderr, "\n Site ID %d-%d.%d", (DmrDataByte[2] & 0xF0 >> 4), DmrDataByte[2] & 0xF, DmrDataByte[3]);
//fprintf (stderr, " DCC %d", DmrDataByte[1]);
//sprintf ( state->dmr_callsign[0], "Site ID %d-%d.%d", (DmrDataByte[2] & 0xF0 >> 4), DmrDataByte[2] & 0xF, DmrDataByte[3]); //sprintf ( state->dmr_callsign[0], "Site ID %d-%d.%d", (DmrDataByte[2] & 0xF0 >> 4), DmrDataByte[2] & 0xF, DmrDataByte[3]);
//sprintf(state->dmr_branding, " TIII "); //?? one of these next two seems to be on both types, maybe its a TIII thing? //sprintf(state->dmr_branding, " TIII "); //?? one of these next two seems to be on both types, maybe its a TIII thing?
} }
@@ -1363,11 +1398,11 @@ void ProcessDmrPIHeader(dsd_opts * opts, dsd_state * state, uint8_t info[196], u
//and see if its applied the same or differently //and see if its applied the same or differently
/* Apply the CRC mask (see DMR standard B.3.12 Data Type CRC Mask) */ /* Apply the CRC mask (see DMR standard B.3.12 Data Type CRC Mask) */
//CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI? //CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI?
//CRCExtracted = CRCExtracted ^ 0x6969; CRCExtracted = CRCExtracted ^ 0x6969;
/* Check/correct the full link control data and compute the Reed-Solomon (12,9) CRC */ /* Check/correct the full link control data and compute the Reed-Solomon (12,9) CRC */
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696); //CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696);
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969); CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969);
/* Convert corrected 12 bytes into 96 bits */ /* Convert corrected 12 bytes into 96 bits */
for(i = 0, j = 0; i < 12; i++, j+=8) for(i = 0, j = 0; i < 12; i++, j+=8)
@@ -1390,6 +1425,18 @@ void ProcessDmrPIHeader(dsd_opts * opts, dsd_state * state, uint8_t info[196], u
{ {
fprintf (stderr, "\n DMR PI Header ALG ID: 0x%02X KEY ID: 0x%02X MI: 0x%08X", state->payload_algid, state->payload_keyid, state->payload_mi); fprintf (stderr, "\n DMR PI Header ALG ID: 0x%02X KEY ID: 0x%02X MI: 0x%08X", state->payload_algid, state->payload_keyid, state->payload_mi);
} }
//test
if((IrrecoverableErrors == 0) && CRCCorrect)
{
fprintf (stderr, " (PI CRC Okay)");
}
else if((IrrecoverableErrors == 0))
{
fprintf (stderr, "( PI FEC Okay)");
}
else fprintf (stderr, (" (PI CRC Fail, FEC Fail)"));
} }
void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t syncdata[48], uint8_t SlotType[20]) void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t syncdata[48], uint8_t SlotType[20])
@@ -1599,7 +1646,7 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19
//Full //Full
if (opts->payload == 1) if (opts->payload == 1)
{ {
fprintf (stderr, "\nFull CSBK Payload "); fprintf (stderr, "\nFull Voice Header Payload ");
for (i = 0; i < 12; i++) for (i = 0; i < 12; i++)
{ {
fprintf (stderr, "[%02X]", DmrDataByte[i]); fprintf (stderr, "[%02X]", DmrDataByte[i]);

View File

@@ -637,8 +637,8 @@ void processDMRvoice (dsd_opts * opts, dsd_state * state)
/* Perform the SYNC DMR data embedded decoding */ /* Perform the SYNC DMR data embedded decoding */
ProcessVoiceBurstSync(opts, state); ProcessVoiceBurstSync(opts, state);
/* Perform the DMR encryption decoding */ /* Perform the DMR voice decoding */
ProcessDMREncryption(opts, state); ProcessDMR(opts, state);
/* Print DMR frame (if needed) */ /* Print DMR frame (if needed) */
//DMRVoiceFrameProcess(opts, state); //HERE HERE, was enabled, disabled so I could build //DMRVoiceFrameProcess(opts, state); //HERE HERE, was enabled, disabled so I could build

View File

@@ -36,11 +36,11 @@ void openPulseOutput(dsd_opts * opts)
tt.rate = opts->pulse_digi_rate_out; //48000, switches to 8000 when using RTL dongle tt.rate = opts->pulse_digi_rate_out; //48000, switches to 8000 when using RTL dongle
//fprintf (stderr,"digi rate out = %d\n", opts->pulse_digi_rate_out); //fprintf (stderr,"digi rate out = %d\n", opts->pulse_digi_rate_out);
//pa_channel_map_init_stereo(&channel_map); //pa_channel_map_init_stereo(&channel_map);
//ss //ss
//if (opts->monitor_input_audio == 1) if (opts->monitor_input_audio == 1)
if (opts->frame_dmr == 1 && opts->audio_in_type != 3) //if (opts->frame_dmr == 1 && opts->audio_in_type != 3)
{ {
//opts->pulse_raw_dev_out = pa_simple_new(NULL, "DSD FME", PA_STREAM_PLAYBACK, NULL, "Raw Audio Out", &ss, NULL, NULL, NULL); opts->pulse_raw_dev_out = pa_simple_new(NULL, "DSD-FME", PA_STREAM_PLAYBACK, NULL, "Raw Audio", &ss, NULL, NULL, NULL);
//opts->pulse_raw_dev_out = pa_simple_new(NULL, "DSD FME", PA_STREAM_PLAYBACK, NULL, "DMR/MOTOTRBO Right", &ss, NULL, NULL, NULL); //opts->pulse_raw_dev_out = pa_simple_new(NULL, "DSD FME", PA_STREAM_PLAYBACK, NULL, "DMR/MOTOTRBO Right", &ss, NULL, NULL, NULL);
} }
@@ -57,9 +57,9 @@ void openPulseOutput(dsd_opts * opts)
void openPulseInput(dsd_opts * opts) void openPulseInput(dsd_opts * opts)
{ {
//zz.format = PA_SAMPLE_S16NE; zz.format = PA_SAMPLE_S16NE;
//zz.channels = opts->pulse_raw_in_channels; zz.channels = opts->pulse_raw_in_channels;
//zz.rate = opts->pulse_raw_rate_in; //48000 zz.rate = opts->pulse_raw_rate_in; //48000
cc.format = PA_SAMPLE_S16NE; cc.format = PA_SAMPLE_S16NE;
cc.channels = opts->pulse_digi_in_channels; cc.channels = opts->pulse_digi_in_channels;
@@ -68,93 +68,32 @@ void openPulseInput(dsd_opts * opts)
//zz //zz
if (opts->monitor_input_audio == 1) if (opts->monitor_input_audio == 1)
{ {
//opts->pulse_raw_dev_in = pa_simple_new(NULL, "DSD FME", PA_STREAM_RECORD, NULL, "Raw Audio In", &zz, NULL, NULL, NULL); //opts->pulse_raw_dev_in = pa_simple_new(NULL, "DSD-FME", PA_STREAM_RECORD, NULL, "Raw Audio In", &zz, NULL, NULL, NULL);
} }
//cc //cc
opts->pulse_digi_dev_in = pa_simple_new(NULL, "DSD-FME", PA_STREAM_RECORD, NULL, opts->output_name, &cc, NULL, NULL, NULL); opts->pulse_digi_dev_in = pa_simple_new(NULL, "DSD-FME", PA_STREAM_RECORD, NULL, opts->output_name, &cc, NULL, NULL, NULL);
} }
//playRawAudio may be obsoleted now that I can run these correctly right inside of dsd_symbol
void playRawAudio(dsd_opts * opts, dsd_state * state) { void playRawAudio(dsd_opts * opts, dsd_state * state)
{
short obuf, outl, i, sample2, something; short obuf, outl, i, sample2, something;
something = state->samplesPerSymbol / 1; //1 for buffer steal loops, 5 for rtl loop something = state->samplesPerSymbol / 1; //1 for buffer steal loops, 5 for rtl loop
//something = 1; //something = 1;
if (opts->audio_in_type == 0 && opts->audio_out_type == 0){ //hack, but might as well for this particular type since its nearly perfect if (opts->audio_in_type == 0 && opts->audio_out_type == 0){ //hack, but might as well for this particular type since its nearly perfect
for (i=0; i < something; i++){ for (i=0; i < something; i++){
//read (opts->audio_in_fd, &sample2, 2); //reading here seems to get same speed as gfsk modulation //read (opts->audio_in_fd, &sample2, 2); //reading here seems to get same speed as gfsk modulation
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
//pa_simple_read(opts->pulse_raw_dev_in, &state->pulse_raw_out_buffer, 2, NULL ); //pa_simple_read(opts->pulse_raw_dev_in, &state->pulse_raw_out_buffer, 2, NULL );
//obuf = state->pulse_raw_out_buffer / 4; //dividing here 'quietens' it down a little bit, helps with clicking and clipping //obuf = state->pulse_raw_out_buffer / 4; //dividing here 'quietens' it down a little bit, helps with clicking and clipping
//obuf = state->input_sample_buffer; //obuf = state->input_sample_buffer;
obuf = state->pulse_raw_out_buffer; //obuf = state->pulse_raw_out_buffer;
//write (opts->audio_out_fd, (void*)&obuf, 2); //write (opts->audio_out_fd, (void*)&obuf, 2);
pa_simple_write(opts->pulse_raw_dev_out, (void*)&obuf, 2, NULL); //pa_simple_write(opts->pulse_raw_dev_out, (void*)&obuf, 2, NULL);
//pa_simple_write(opts->pulse_digi_dev_out, (void*)&obuf, 2, NULL);
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
} }
} }
#ifdef USE_PORTAUDIO
if (opts->audio_in_type == 2 && opts->audio_out_type == 0){ //hack, but might as well for this particular type since its nearly perfect
for (i=0; i < something * 5; i++){ //not sure if this should be 'something' or something * 5 like is was with OSS
//Pa_ReadStream( opts->audio_in_pa_stream, &sample2, 1 ); //reading here seems to get same speed as gfsk modulation
obuf = state->pulse_raw_out_buffer;
//obuf = sample2 / 4; //dividing here 'quietens' it down a little bit, helps with clicking and clipping
//write (opts->audio_out_fd, (void*)&obuf, 2);
pa_simple_write(opts->pulse_raw_dev_out, (void*)&obuf, 2, NULL);
}
}
if (opts->audio_in_type == 0 && opts->audio_out_type == 2){ //hack, but might as well for this particular type since its nearly perfect
for (i=0; i < something; i++){
//read (opts->audio_in_fd, &sample2, 2); //reading here seems to get same speed as gfsk modulation
//pa_simple_read(opts->pulse_raw_dev_in, &sample2, 2, NULL );
//obuf = sample2 / 4; //dividing here 'quietens' it down a little bit, helps with clicking and clipping
obuf = state->pulse_raw_out_buffer;
Pa_StartStream( opts->audio_out_pa_stream ); //no promises this work
Pa_WriteStream( opts->audio_out_pa_stream, (void*)&obuf, 2); //no promises this work
}
}
if (opts->audio_in_type == 2 && opts->audio_out_type == 2){ //hack, but might as well for this particular type since its nearly perfect
for (i=0; i < something * 5; i++){ //not sure if this should be 'something' or something * 5 like is was with OSS
//Pa_ReadStream( opts->audio_in_pa_stream, &sample2, 1 ); //reading here seems to get same speed as gfsk modulation
//obuf = sample2 / 4; //dividing here 'quietens' it down a little bit, helps with clicking and clipping
obuf = state->pulse_raw_out_buffer;
Pa_StartStream( opts->audio_out_pa_stream ); //no promises this work
Pa_WriteStream( opts->audio_out_pa_stream, (void*)&obuf, 2); //no promises this work
}
}
#endif
something = state->samplesPerSymbol / 5; //change to 5 for rtl samples, flips back to 1 up top next loop
//something = 1;
if (opts->audio_in_type == 1 || opts->audio_in_type == 3){ //only plays at 83% and sounds like s sadly, but can't get samples directly from sdr when its already being polled for samples
//also, can't get samples from stdin more than once either it seems, unless I borked it when I tried it earlier, so lumping it in here as well
for (i=0; i < something; i++)
{
obuf = state->input_sample_buffer; //dividing here 'quietens' it down a little bit, helps with clicking and clipping
outl = sizeof(obuf) ; //obuf length, I think its always equal to 2
if (opts->audio_out_type == 0){
//write (opts->audio_out_fd, (void*)&obuf, outl);
pa_simple_write(opts->pulse_raw_dev_out, (void*)&obuf, outl, NULL);
//fprintf (stderr,"writing samples");
}
#ifdef USE_PORTAUDIO //no idea if this method will work, since I can't test it
if (opts->audio_out_type == 2){
short err;
err = Pa_IsStreamActive( opts->audio_out_pa_stream );
if(err == 0)
{
err = Pa_StartStream( opts->audio_out_pa_stream );
if( err != paNoError ){
fprintf (stderr,"Can't Start PA Stream");
}
err = Pa_WriteStream( opts->audio_out_pa_stream, (void*)&obuf, outl );
if( err != paNoError ){
fprintf (stderr,"Can't Write PA Stream");
}
}
}
#endif
} // end for loop
} //end if statement
} //end playRawAudio } //end playRawAudio

View File

@@ -83,10 +83,14 @@ saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d)
b = b + ambe_d[k]; b = b + ambe_d[k];
k++; k++;
} }
if (opts->payload == 1) //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?
{
fprintf (stderr, "[%02X] ", b & 0x80); //7th octet should only contain 1 bit?
}
fputc (b, opts->mbe_out_f); fputc (b, opts->mbe_out_f);
} }
@@ -181,10 +185,14 @@ readAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d)
b = b & 255; b = b & 255;
k++; k++;
} }
if (opts->payload == 1) //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] ", x); fprintf (stderr, "[%02X] ", x);
} }
if (opts->payload == 1 && i == 6) //7th octet should only contain 1 bit? value will be either 0x00 or 0x80?
{
fprintf (stderr, "[%02X] ", x & 0x80); //7th octet should only contain 1 bit?
}
} }
if (opts->payload == 1) if (opts->payload == 1)
{ {

View File

@@ -253,8 +253,10 @@ processFrame (dsd_opts * opts, dsd_state * state)
else if ((state->synctype == 21) || (state->synctype == 25)) else if ((state->synctype == 21) || (state->synctype == 25))
{ {
/* dPMR Frame Sync 2 */ /* dPMR Frame Sync 2 */
fprintf(stderr, "dPMR Frame sync 2 "); //for (short o = 0; o < 2; o++)
{ //{
fprintf(stderr, "dPMR Frame sync 2 ");
//state->rf_mod = GFSK_MODE; //state->rf_mod = GFSK_MODE;
state->nac = 0; state->nac = 0;
state->lastsrc = 0; state->lastsrc = 0;
@@ -268,14 +270,16 @@ processFrame (dsd_opts * opts, dsd_state * state)
} }
} }
state->nac = 0; state->nac = 0;
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{ if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
openMbeOutFile (opts, state); {
} openMbeOutFile (opts, state);
sprintf(state->fsubtype, " VOICE "); }
processdPMRvoice (opts, state); sprintf(state->fsubtype, " VOICE ");
processdPMRvoice (opts, state);
//}
return; return;
}
} }
else if ((state->synctype == 22) || (state->synctype == 26)) else if ((state->synctype == 22) || (state->synctype == 26))
{ {

View File

@@ -188,6 +188,13 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
lidx = 0; lidx = 0;
lastt = 0; lastt = 0;
state->numflips = 0; state->numflips = 0;
//move ncursesPrinter outside of the sync loop, causes weird lag inside the loop
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
if ((opts->symboltiming == 1) && (state->carrier == 1)) if ((opts->symboltiming == 1) && (state->carrier == 1))
{ {
fprintf (stderr,"\nSymbol Timing:\n"); fprintf (stderr,"\nSymbol Timing:\n");
@@ -195,18 +202,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
} }
while (sync == 0) while (sync == 0)
{ {
//fprintf (stderr,"now=%d\n", now); //okay, so this is incrementing as expected
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
/*
if (opts->reset_state == 1 && state->carrier == 0)
{
resetState (state);
}
*/
t++; t++;
symbol = getSymbol (opts, state, 0); symbol = getSymbol (opts, state, 0);
@@ -594,7 +590,82 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
} }
} }
*/ */
// lwvmobile dPMR sync
strncpy(synctest, (synctest_p - 23), 24);
strncpy(synctest12, (synctest_p - 11), 12);
if(opts->frame_dpmr == 1)
{
if (opts->inverted_dpmr == 0)
{
if(strcmp(synctest, DPMR_FRAME_SYNC_1) == 0)
{
fprintf (stderr, "DPMR_FRAME_SYNC_1\n");
}
if(strcmp(synctest12, DPMR_FRAME_SYNC_2) == 0)
{
fprintf (stderr, "DPMR_FRAME_SYNC_2\n");
state->carrier = 1;
state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2;
sprintf(state->ftype, "dPMR ");
if (opts->errorbars == 1)
{
printFrameSync (opts, state, "+dPMR ", synctest_pos + 1, modulation);
}
state->lastsynctype = 21;
return (21);
}
if(strcmp(synctest12, DPMR_FRAME_SYNC_3) == 0)
{
fprintf (stderr, "DPMR_FRAME_SYNC_3\n");
}
if(strcmp(synctest, DPMR_FRAME_SYNC_4) == 0)
{
fprintf (stderr, "DPMR_FRAME_SYNC_4\n");
}
}
if (opts->inverted_dpmr == 1)
{
if(strcmp(synctest, INV_DPMR_FRAME_SYNC_1) == 0)
{
fprintf (stderr, "INV_DPMR_FRAME_SYNC_1\n");
}
if(strcmp(synctest12, INV_DPMR_FRAME_SYNC_2) == 0)
{
fprintf (stderr, "INV_DPMR_FRAME_SYNC_2\n");
state->carrier = 1;
state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2;
sprintf(state->ftype, "dPMR ");
if (opts->errorbars == 1)
{
printFrameSync (opts, state, "-dPMR ", synctest_pos + 1, modulation);
}
state->lastsynctype = 25;
return (25);
}
if(strcmp(synctest12, INV_DPMR_FRAME_SYNC_3) == 0)
{
fprintf (stderr, "INV_DPMR_FRAME_SYNC_3\n");
}
if(strcmp(synctest, INV_DPMR_FRAME_SYNC_4) == 0)
{
fprintf (stderr, "INV_DPMR_FRAME_SYNC_4\n");
}
}
}
//LEH dPMR //LEH dPMR
/*
if(opts->frame_dpmr == 1) if(opts->frame_dpmr == 1)
{ {
strncpy(synctest, (synctest_p - 23), 24); strncpy(synctest, (synctest_p - 23), 24);
@@ -604,11 +675,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
{ {
if (opts->inverted_dpmr == 0) if (opts->inverted_dpmr == 0)
{ {
//fprintf(stderr, "DPMR_FRAME_SYNC_1\n"); // TODO : To be removed fprintf(stderr, "DPMR_FRAME_SYNC_1\n"); // TODO : To be removed
if ((state->lastsynctype == 20) || (state->lastsynctype == 21) || //if ((state->lastsynctype == 20) || (state->lastsynctype == 21) ||
(state->lastsynctype == 22) || (state->lastsynctype == 23)) // (state->lastsynctype == 22) || (state->lastsynctype == 23))
{ //{
state->carrier = 1; state->carrier = 1;
state->offset = synctest_pos; state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2; state->max = ((state->max) + lmax) / 2;
@@ -619,28 +690,28 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+dPMR ", synctest_pos + 1, modulation); printFrameSync (opts, state, "+dPMR ", synctest_pos + 1, modulation);
} }
/* The next part of the superframe will normally be the first part */ //The next part of the superframe will normally be the first part
//opts->dPMR_next_part_of_superframe = 1; //opts->dPMR_next_part_of_superframe = 1;
state->lastsynctype = 20; state->lastsynctype = 20;
return (20); return (20);
} //}
else //else
{ //{
state->lastsynctype = 20; // state->lastsynctype = 20;
} //}
} /* End if (opts->inverted_dpmr == 0) */ } //End if (opts->inverted_dpmr == 0)
} }
else if(strcmp(synctest12, DPMR_FRAME_SYNC_2) == 0) if(strcmp(synctest12, DPMR_FRAME_SYNC_2) == 0)
{ {
if (opts->inverted_dpmr == 0) if (opts->inverted_dpmr == 0)
{ {
//fprintf(stderr, "DPMR_FRAME_SYNC_2\n"); // TODO : To be removed fprintf(stderr, "DPMR_FRAME_SYNC_2\n"); // TODO : To be removed
// TODO : Modif 2019-01-04 // TODO : Modif 2019-01-04
if ((state->lastsynctype == 20) || (state->lastsynctype == 21) || //if ((state->lastsynctype == 20) || (state->lastsynctype == 21) ||
(state->lastsynctype == 22) || (state->lastsynctype == 23)) // (state->lastsynctype == 22) || (state->lastsynctype == 23))
{ //{
state->carrier = 1; state->carrier = 1;
state->offset = synctest_pos; state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2; state->max = ((state->max) + lmax) / 2;
@@ -655,18 +726,18 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->lastsynctype = 21; state->lastsynctype = 21;
return (21); return (21);
// TODO : Modif 2019-01-04 // TODO : Modif 2019-01-04
} //}
else //else
{ //{
state->lastsynctype = 21; // state->lastsynctype = 21;
} //}
} }
} }
else if(strcmp(synctest12, DPMR_FRAME_SYNC_3) == 0) else if(strcmp(synctest12, DPMR_FRAME_SYNC_3) == 0)
{ {
if (opts->inverted_dpmr == 0) //if (opts->inverted_dpmr == 0)
{ //{
//fprintf(stderr, "DPMR_FRAME_SYNC_3\n"); // TODO : To be removed fprintf(stderr, "DPMR_FRAME_SYNC_3\n"); // TODO : To be removed
if ((state->lastsynctype == 20) || (state->lastsynctype == 21) || if ((state->lastsynctype == 20) || (state->lastsynctype == 21) ||
(state->lastsynctype == 22) || (state->lastsynctype == 23)) (state->lastsynctype == 22) || (state->lastsynctype == 23))
@@ -681,16 +752,16 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+dPMR ", synctest_pos + 1, modulation); printFrameSync (opts, state, "+dPMR ", synctest_pos + 1, modulation);
} }
/* The next part of the superframe will normally be the first part */ //The next part of the superframe will normally be the first part
//opts->dPMR_next_part_of_superframe = 1; //opts->dPMR_next_part_of_superframe = 1;
state->lastsynctype = 22; state->lastsynctype = 22;
return (22); return (22);
} //}
else //else
{ //{
state->lastsynctype = 22; // state->lastsynctype = 22;
} //}
} }
} }
if(strcmp(synctest, DPMR_FRAME_SYNC_4) == 0) if(strcmp(synctest, DPMR_FRAME_SYNC_4) == 0)
@@ -699,9 +770,9 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
{ {
//fprintf(stderr, "DPMR_FRAME_SYNC_4\n"); // TODO : To be removed //fprintf(stderr, "DPMR_FRAME_SYNC_4\n"); // TODO : To be removed
if ((state->lastsynctype == 20) || (state->lastsynctype == 21) || //if ((state->lastsynctype == 20) || (state->lastsynctype == 21) ||
(state->lastsynctype == 22) || (state->lastsynctype == 23)) // (state->lastsynctype == 22) || (state->lastsynctype == 23))
{ //{
state->carrier = 1; state->carrier = 1;
state->offset = synctest_pos; state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2; state->max = ((state->max) + lmax) / 2;
@@ -712,26 +783,26 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+dPMR ", synctest_pos + 1, modulation); printFrameSync (opts, state, "+dPMR ", synctest_pos + 1, modulation);
} }
/* The next part of the superframe will normally be the first part */ //The next part of the superframe will normally be the first part
//opts->dPMR_next_part_of_superframe = 1; //opts->dPMR_next_part_of_superframe = 1;
state->lastsynctype = 23; state->lastsynctype = 23;
return (23); return (23);
} //}
else //else
{ //{
state->lastsynctype = 23; // state->lastsynctype = 23;
} //}
} }
} }
else if(strcmp(synctest, INV_DPMR_FRAME_SYNC_1) == 0) if(strcmp(synctest, INV_DPMR_FRAME_SYNC_1) == 0)
{ {
if (opts->inverted_dpmr) if (opts->inverted_dpmr == 1)
{ {
//fprintf(stderr, "INV_DPMR_FRAME_SYNC_1\n"); // TODO : To be removed fprintf(stderr, "INV_DPMR_FRAME_SYNC_1\n"); // TODO : To be removed
if ((state->lastsynctype == 24) || (state->lastsynctype == 25) || //if ((state->lastsynctype == 24) || (state->lastsynctype == 25) ||
(state->lastsynctype == 26) || (state->lastsynctype == 27)) // (state->lastsynctype == 26) || (state->lastsynctype == 27))
{ //{
state->carrier = 1; state->carrier = 1;
state->offset = synctest_pos; state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2; state->max = ((state->max) + lmax) / 2;
@@ -743,22 +814,22 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
} }
state->lastsynctype = 24; state->lastsynctype = 24;
return (24); return (24);
} //}
else //else
{ //{
state->lastsynctype = 24; // state->lastsynctype = 24;
} //}
} }
} }
else if(strcmp(synctest12, INV_DPMR_FRAME_SYNC_2) == 0) if(strcmp(synctest12, INV_DPMR_FRAME_SYNC_2) == 0)
{ {
if (opts->inverted_dpmr) if (opts->inverted_dpmr == 1)
{ {
//fprintf(stderr, "DPMR_FRAME_SYNC_2\n"); // TODO : To be removed fprintf(stderr, "INV_DPMR_FRAME_SYNC_2\n"); // TODO : To be removed
if ((state->lastsynctype == 24) || (state->lastsynctype == 25) || //if ((state->lastsynctype == 24) || (state->lastsynctype == 25) ||
(state->lastsynctype == 26) || (state->lastsynctype == 27)) // (state->lastsynctype == 26) || (state->lastsynctype == 27))
{ //{
state->carrier = 1; state->carrier = 1;
state->offset = synctest_pos; state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2; state->max = ((state->max) + lmax) / 2;
@@ -770,22 +841,22 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
} }
state->lastsynctype = 25; state->lastsynctype = 25;
return (25); return (25);
} //}
else //else
{ //{
state->lastsynctype = 25; // state->lastsynctype = 25;
} //}
} }
} }
else if(strcmp(synctest12, INV_DPMR_FRAME_SYNC_3) == 0) if(strcmp(synctest12, INV_DPMR_FRAME_SYNC_3) == 0)
{ {
if (opts->inverted_dpmr) if (opts->inverted_dpmr == 1)
{ {
//fprintf(stderr, "INV_DPMR_FRAME_SYNC_3\n"); // TODO : To be removed fprintf(stderr, "INV_DPMR_FRAME_SYNC_3\n"); // TODO : To be removed
if ((state->lastsynctype == 24) || (state->lastsynctype == 25) || //if ((state->lastsynctype == 24) || (state->lastsynctype == 25) ||
(state->lastsynctype == 26) || (state->lastsynctype == 27)) // (state->lastsynctype == 26) || (state->lastsynctype == 27))
{ //{
state->carrier = 1; state->carrier = 1;
state->offset = synctest_pos; state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2; state->max = ((state->max) + lmax) / 2;
@@ -797,22 +868,22 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
} }
state->lastsynctype = 26; state->lastsynctype = 26;
return (26); return (26);
} //}
else //else
{ //{
state->lastsynctype = 26; // state->lastsynctype = 26;
} //}
} }
} }
if(strcmp(synctest, INV_DPMR_FRAME_SYNC_4) == 0) if(strcmp(synctest, INV_DPMR_FRAME_SYNC_4) == 0)
{ {
if (opts->inverted_dpmr) if (opts->inverted_dpmr == 1)
{ {
//fprintf(stderr, "INV_DPMR_FRAME_SYNC_4\n"); // TODO : To be removed fprintf(stderr, "INV_DPMR_FRAME_SYNC_4\n"); // TODO : To be removed
if ((state->lastsynctype == 24) || (state->lastsynctype == 25) || //if ((state->lastsynctype == 24) || (state->lastsynctype == 25) ||
(state->lastsynctype == 26) || (state->lastsynctype == 27)) // (state->lastsynctype == 26) || (state->lastsynctype == 27))
{ //{
state->carrier = 1; state->carrier = 1;
state->offset = synctest_pos; state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2; state->max = ((state->max) + lmax) / 2;
@@ -825,21 +896,22 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->lastsynctype = 27; state->lastsynctype = 27;
return (27); return (27);
} }
else //else
{ //{
state->lastsynctype = 27; // state->lastsynctype = 27;
} //}
} //}
} }
else //else
{ //{
/* No dPMR frame sync detected */ // No dPMR frame sync detected
} //}
} /* End if(opts->frame_dpmr == 1) */ } // End if(opts->frame_dpmr == 1)
*/
// //
//LEH dPMR //LEH dPMR
/* //testing frame syncs here for better performance //testing frame syncs here for better performance
/*
if(opts->frame_dpmr == 1) if(opts->frame_dpmr == 1)
{ {
strncpy(synctest, (synctest_p - 23), 24); strncpy(synctest, (synctest_p - 23), 24);
@@ -1126,6 +1198,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+DMR ", synctest_pos + 1, modulation); printFrameSync (opts, state, "+DMR ", synctest_pos + 1, modulation);
} }
state->lastsynctype = 10; state->lastsynctype = 10;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (10); return (10);
} }
else else
@@ -1141,6 +1218,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->firstframe = 1; state->firstframe = 1;
} }
state->lastsynctype = 11; state->lastsynctype = 11;
if ( opts->monitor_input_audio == 1)
{
pa_simple_drain(opts->pulse_raw_dev_out, NULL);
}
return (11); return (11);
} }
} }
@@ -1161,6 +1242,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+DMR ", synctest_pos + 1, modulation); printFrameSync (opts, state, "+DMR ", synctest_pos + 1, modulation);
} }
state->lastsynctype = 10; state->lastsynctype = 10;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (10); return (10);
} }
else else
@@ -1176,6 +1262,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->firstframe = 1; state->firstframe = 1;
} }
state->lastsynctype = 11; state->lastsynctype = 11;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (11); return (11);
} }
} /* End if(strcmp (synctest, DMR_DIRECT_MODE_TS1_DATA_SYNC) == 0) */ } /* End if(strcmp (synctest, DMR_DIRECT_MODE_TS1_DATA_SYNC) == 0) */
@@ -1196,6 +1287,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+DMR ", synctest_pos + 1, modulation); printFrameSync (opts, state, "+DMR ", synctest_pos + 1, modulation);
} }
state->lastsynctype = 10; state->lastsynctype = 10;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (10); return (10);
} }
else else
@@ -1211,6 +1307,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->firstframe = 1; state->firstframe = 1;
} }
state->lastsynctype = 11; state->lastsynctype = 11;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (11); return (11);
} }
} /* End if(strcmp (synctest, DMR_DIRECT_MODE_TS2_DATA_SYNC) == 0) */ } /* End if(strcmp (synctest, DMR_DIRECT_MODE_TS2_DATA_SYNC) == 0) */
@@ -1245,6 +1346,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "-DMR ", synctest_pos + 1, modulation); printFrameSync (opts, state, "-DMR ", synctest_pos + 1, modulation);
} }
state->lastsynctype = 13; state->lastsynctype = 13;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (13); return (13);
} }
} }
@@ -1269,6 +1375,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->firstframe = 1; state->firstframe = 1;
} }
state->lastsynctype = 12; state->lastsynctype = 12;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (12); return (12);
} }
else else
@@ -1304,6 +1415,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->firstframe = 1; state->firstframe = 1;
} }
state->lastsynctype = 12; state->lastsynctype = 12;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (12); return (12);
} }
else else
@@ -1315,6 +1431,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "-DMR ", synctest_pos + 1, modulation); printFrameSync (opts, state, "-DMR ", synctest_pos + 1, modulation);
} }
state->lastsynctype = 13; state->lastsynctype = 13;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (13); return (13);
} }
} //End if(strcmp (synctest, DMR_DIRECT_MODE_TS2_VOICE_SYNC) == 0) } //End if(strcmp (synctest, DMR_DIRECT_MODE_TS2_VOICE_SYNC) == 0)
@@ -1338,9 +1459,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "-ProVoice ", synctest_pos + 1, modulation); printFrameSync (opts, state, "-ProVoice ", synctest_pos + 1, modulation);
} }
state->lastsynctype = 14; state->lastsynctype = 14;
if (opts->use_ncurses_terminal == 1) if ( opts->monitor_input_audio == 1)
{ {
ncursesPrinter(opts, state); //pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
} }
return (14); return (14);
} }
@@ -1357,9 +1479,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "-ProVoice ", synctest_pos + 1, modulation); printFrameSync (opts, state, "-ProVoice ", synctest_pos + 1, modulation);
} }
state->lastsynctype = 15; state->lastsynctype = 15;
if (opts->use_ncurses_terminal == 1) if ( opts->monitor_input_audio == 1)
{ {
ncursesPrinter(opts, state); //pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
} }
return (15); return (15);
} }
@@ -1385,6 +1508,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
{ {
//sprintf (state->ftype, " NXDN48 "); //sprintf (state->ftype, " NXDN48 ");
sprintf (state->ftype, "NXDN48 "); //get rid of spaces sprintf (state->ftype, "NXDN48 "); //get rid of spaces
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
if (opts->errorbars == 1) if (opts->errorbars == 1)
{ {
//printFrameSync (opts, state, " +NXDN48 ", synctest_pos + 1, modulation); //printFrameSync (opts, state, " +NXDN48 ", synctest_pos + 1, modulation);
@@ -1394,16 +1522,18 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
else else
{ {
sprintf (state->ftype, "NXDN96"); sprintf (state->ftype, "NXDN96");
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
if (opts->errorbars == 1) if (opts->errorbars == 1)
{ {
printFrameSync (opts, state, " +NXDN96 ", synctest_pos + 1, modulation); printFrameSync (opts, state, " +NXDN96 ", synctest_pos + 1, modulation);
} }
} }
state->lastsynctype = 8; state->lastsynctype = 8;
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
return (8); return (8);
} }
else else
@@ -1443,9 +1573,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
} }
} }
state->lastsynctype = 9; state->lastsynctype = 9;
if (opts->use_ncurses_terminal == 1) if ( opts->monitor_input_audio == 1)
{ {
ncursesPrinter(opts, state); //pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
} }
return (9); return (9);
} }
@@ -1484,9 +1615,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
} }
} }
state->lastsynctype = 16; state->lastsynctype = 16;
if (opts->use_ncurses_terminal == 1) if ( opts->monitor_input_audio == 1)
{ {
ncursesPrinter(opts, state); //pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
} }
return (16); return (16);
} }
@@ -1526,9 +1658,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
} }
} }
state->lastsynctype = 17; state->lastsynctype = 17;
if (opts->use_ncurses_terminal == 1) if ( opts->monitor_input_audio == 1)
{ {
ncursesPrinter(opts, state); //pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
} }
return (17); return (17);
} }
@@ -1555,9 +1688,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+D-STAR ", synctest_pos + 1, modulation); printFrameSync (opts, state, "+D-STAR ", synctest_pos + 1, modulation);
} }
state->lastsynctype = 6; state->lastsynctype = 6;
if (opts->use_ncurses_terminal == 1) if ( opts->monitor_input_audio == 1)
{ {
ncursesPrinter(opts, state); //pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
} }
return (6); return (6);
} }
@@ -1574,9 +1708,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "-D-STAR ", synctest_pos + 1, modulation); printFrameSync (opts, state, "-D-STAR ", synctest_pos + 1, modulation);
} }
state->lastsynctype = 7; state->lastsynctype = 7;
if (opts->use_ncurses_terminal == 1) if ( opts->monitor_input_audio == 1)
{ {
ncursesPrinter(opts, state); //pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
} }
return (7); return (7);
} }
@@ -1593,9 +1728,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+D-STAR_HD ", synctest_pos + 1, modulation); printFrameSync (opts, state, "+D-STAR_HD ", synctest_pos + 1, modulation);
} }
state->lastsynctype = 18; state->lastsynctype = 18;
if (opts->use_ncurses_terminal == 1) if ( opts->monitor_input_audio == 1)
{ {
ncursesPrinter(opts, state); //pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
} }
return (18); return (18);
} }
@@ -1612,9 +1748,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "-D-STAR_HD ", synctest_pos + 1, modulation); printFrameSync (opts, state, "-D-STAR_HD ", synctest_pos + 1, modulation);
} }
state->lastsynctype = 19; state->lastsynctype = 19;
if (opts->use_ncurses_terminal == 1) if ( opts->monitor_input_audio == 1)
{ {
ncursesPrinter(opts, state); //pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
} }
return (19); return (19);
} }
@@ -1635,11 +1772,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "(+P25p1) ", synctest_pos + 1, modulation); printFrameSync (opts, state, "(+P25p1) ", synctest_pos + 1, modulation);
} }
state->lastsynctype = -1; state->lastsynctype = -1;
//do we want ncursesPrinter here??
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
return (0); return (0);
} }
else if ((state->lastsynctype == 1) && ((state->lastp25type == 1) || (state->lastp25type == 2))) else if ((state->lastsynctype == 1) && ((state->lastp25type == 1) || (state->lastp25type == 2)))
@@ -1654,10 +1787,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "(-P25p1) ", synctest_pos + 1, modulation); printFrameSync (opts, state, "(-P25p1) ", synctest_pos + 1, modulation);
} }
state->lastsynctype = -1; state->lastsynctype = -1;
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
return (1); return (1);
} }
else if ((state->lastsynctype == 3) && ((strcmp (synctest, X2TDMA_BS_VOICE_SYNC) != 0) || (strcmp (synctest, X2TDMA_MS_VOICE_SYNC) != 0))) else if ((state->lastsynctype == 3) && ((strcmp (synctest, X2TDMA_BS_VOICE_SYNC) != 0) || (strcmp (synctest, X2TDMA_MS_VOICE_SYNC) != 0)))
@@ -1672,10 +1802,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "(-X2-TDMA) ", synctest_pos + 1, modulation); printFrameSync (opts, state, "(-X2-TDMA) ", synctest_pos + 1, modulation);
} }
state->lastsynctype = -1; state->lastsynctype = -1;
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
return (3); return (3);
} }
else if ((state->lastsynctype == 4) && ((strcmp (synctest, X2TDMA_BS_DATA_SYNC) != 0) || (strcmp (synctest, X2TDMA_MS_DATA_SYNC) != 0))) else if ((state->lastsynctype == 4) && ((strcmp (synctest, X2TDMA_BS_DATA_SYNC) != 0) || (strcmp (synctest, X2TDMA_MS_DATA_SYNC) != 0)))
@@ -1690,10 +1817,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "(+X2-TDMA) ", synctest_pos + 1, modulation); printFrameSync (opts, state, "(+X2-TDMA) ", synctest_pos + 1, modulation);
} }
state->lastsynctype = -1; state->lastsynctype = -1;
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
return (4); return (4);
} }
else if ((state->lastsynctype == 11) && ((strcmp (synctest, DMR_BS_VOICE_SYNC) != 0) || (strcmp (synctest, DMR_MS_VOICE_SYNC) != 0))) else if ((state->lastsynctype == 11) && ((strcmp (synctest, DMR_BS_VOICE_SYNC) != 0) || (strcmp (synctest, DMR_MS_VOICE_SYNC) != 0)))
@@ -1708,9 +1832,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "(-DMR) ", synctest_pos + 1, modulation); printFrameSync (opts, state, "(-DMR) ", synctest_pos + 1, modulation);
} }
state->lastsynctype = -1; state->lastsynctype = -1;
if (opts->use_ncurses_terminal == 1) if ( opts->monitor_input_audio == 1)
{ {
ncursesPrinter(opts, state); //pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
} }
return (11); return (11);
} }
@@ -1726,9 +1851,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "(+DMR) ", synctest_pos + 1, modulation); printFrameSync (opts, state, "(+DMR) ", synctest_pos + 1, modulation);
} }
state->lastsynctype = -1; state->lastsynctype = -1;
if (opts->use_ncurses_terminal == 1) if ( opts->monitor_input_audio == 1)
{ {
ncursesPrinter(opts, state); //pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
} }
return (12); return (12);
} }
@@ -1751,18 +1877,22 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
synctest_pos = 0; synctest_pos = 0;
synctest_p = synctest_buf; synctest_p = synctest_buf;
noCarrier (opts, state); noCarrier (opts, state);
} }
if (state->lastsynctype != 1) if (state->lastsynctype != 1)
{ {
if (synctest_pos >= 1800) if (synctest_pos >= 1800)
{ {
if ((opts->errorbars == 1) && (opts->verbose > 1) && (state->carrier == 1)) if ((opts->errorbars == 1) && (opts->verbose > 1) && (state->carrier == 1))
{ {
fprintf (stderr,"Sync: no sync\n"); fprintf (stderr,"Sync: no sync\n");
fprintf (stderr,"Press CTRL + C to close.\n"); //Kindly remind user to double tap CTRL + C fprintf (stderr,"Press CTRL + C to close.\n"); //Kindly remind user to double tap CTRL + C
}
}
noCarrier (opts, state); noCarrier (opts, state);
/* /*
if (opts->reset_state == 1) if (opts->reset_state == 1)
{ {
@@ -1775,7 +1905,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
if ( opts->monitor_input_audio == 1 && (time(NULL) - now) > 1 ) //okay, still something going on, still doing the read part for some reason if ( opts->monitor_input_audio == 1 && (time(NULL) - now) > 1 ) //okay, still something going on, still doing the read part for some reason
//if ( opts->monitor_input_audio == 1) //if ( opts->monitor_input_audio == 1)
{ {
playRawAudio(opts, state); //this is on line 21 in dsd_audio.c //playRawAudio(opts, state); //this is on line 21 in dsd_audio.c
} }
} }

View File

@@ -190,6 +190,7 @@ initOpts (dsd_opts * opts)
opts->rtl_volume_multiplier = 1; //set multipler from rtl sample to 'boost volume' opts->rtl_volume_multiplier = 1; //set multipler from rtl sample to 'boost volume'
opts->rtl_udp_port = 6020; //set UDP port for RTL remote opts->rtl_udp_port = 6020; //set UDP port for RTL remote
opts->rtl_bandwidth = 12; //changed recommended default to 12, 24 for ProVoice opts->rtl_bandwidth = 12; //changed recommended default to 12, 24 for ProVoice
opts->rtlsdr_ppm_error = 0; //initialize ppm with 0 value; bug reported by N.
opts->pulse_raw_rate_in = 48000; opts->pulse_raw_rate_in = 48000;
opts->pulse_raw_rate_out = 48000; //doing tests with 2 channels at 24000 for 48000 audio default in pulse opts->pulse_raw_rate_out = 48000; //doing tests with 2 channels at 24000 for 48000 audio default in pulse
opts->pulse_digi_rate_in = 48000; opts->pulse_digi_rate_in = 48000;
@@ -438,14 +439,16 @@ void
liveScanner (dsd_opts * opts, dsd_state * state) liveScanner (dsd_opts * opts, dsd_state * state)
{ {
//need to use this area to configure audio rates for different sources if not pulse //need to use this area to configure audio rates for different sources if not pulse
if (opts->audio_in_type == 1) //if stdin, switch to 8000 and single channel audio if (opts->audio_in_type == 1) //if stdin, switch to 8000 and single channel audio
{ {
opts->pulse_digi_rate_out = 8000; //stdin needs 8000 output, could have sworn this was working with 48000 opts->pulse_digi_rate_out = 8000; //stdin needs 8000 output, could have sworn this was working with 48000
opts->pulse_digi_out_channels = 1; opts->pulse_digi_out_channels = 1;
opts->pulse_raw_rate_out = 8000; opts->pulse_raw_rate_out = 48000;
opts->pulse_raw_out_channels = 1; opts->pulse_raw_out_channels = 1;
fprintf (stderr, "STDIN Audio Rate Out set to 8000 Khz/1 Channel \n"); fprintf (stderr, "STDIN Audio Rate Out set to 8000 Khz/1 Channel \n");
} }
#ifdef USE_PORTAUDIO #ifdef USE_PORTAUDIO
if(opts->audio_in_type == 2) if(opts->audio_in_type == 2)
{ {
@@ -464,7 +467,7 @@ if (opts->audio_in_type == 1) //if stdin, switch to 8000 and single channel audi
{ {
opts->pulse_digi_rate_out = 8000; //if rtl, switch to 8000 and 1 channel opts->pulse_digi_rate_out = 8000; //if rtl, switch to 8000 and 1 channel
opts->pulse_digi_out_channels = 1; opts->pulse_digi_out_channels = 1;
opts->pulse_raw_rate_out = 8000; opts->pulse_raw_rate_out = 48000;
opts->pulse_raw_out_channels = 1; opts->pulse_raw_out_channels = 1;
fprintf (stderr, "RTL Audio Rate Out set to 8000 Khz/1 Channel \n"); fprintf (stderr, "RTL Audio Rate Out set to 8000 Khz/1 Channel \n");
open_rtlsdr_stream(opts); open_rtlsdr_stream(opts);
@@ -476,16 +479,20 @@ if (opts->audio_in_type == 0){
if (opts->audio_out_type == 0){ if (opts->audio_out_type == 0){
openPulseOutput(opts); openPulseOutput(opts);
} }
//openPulse(opts);
while (1) while (1)
{ {
noCarrier (opts, state); noCarrier (opts, state);
state->synctype = getFrameSync (opts, state); state->synctype = getFrameSync (opts, state);
// recalibrate center/umid/lmid // recalibrate center/umid/lmid
state->center = ((state->max) + (state->min)) / 2; state->center = ((state->max) + (state->min)) / 2;
state->umid = (((state->max) - state->center) * 5 / 8) + state->center; state->umid = (((state->max) - state->center) * 5 / 8) + state->center;
state->lmid = (((state->min) - state->center) * 5 / 8) + state->center; state->lmid = (((state->min) - state->center) * 5 / 8) + state->center;
while (state->synctype != -1) while (state->synctype != -1)
{ {
processFrame (opts, state); processFrame (opts, state);
@@ -734,7 +741,10 @@ main (int argc, char **argv)
case 'K': case 'K':
sscanf (optarg, "%lld", &state.K); sscanf (optarg, "%lld", &state.K);
state.K = ( ((state.K & 0xFF0F) << 32 ) + (state.K << 16) + state.K ); if (state.K > 256)
{
state.K = 256;
}
break; break;
case 'G': //Set rtl device gain case 'G': //Set rtl device gain
@@ -763,18 +773,8 @@ main (int argc, char **argv)
case 'W': //monitor_input_audio if no sync case 'W': //monitor_input_audio if no sync
opts.monitor_input_audio = 1; opts.monitor_input_audio = 1;
fprintf (stderr,"Monitor Source Audio Enabled.\n"); fprintf (stderr,"Monitoring Source Audio when carrier present and No Sync Detected.\n");
//opts.pulse_raw_rate_in = 48000; fprintf (stderr," - May cause Pulse Audio Server to crash on some systems.\n");
//opts.pulse_raw_rate_out = 48000; //doing tests with 2 channels at 24000 for 48000 audio default in pulse
//opts.pulse_digi_rate_in = 48000;
//opts.pulse_digi_rate_out = 48000; //need to copy this to rtl type in and change rate out to 8000
//opts.pulse_raw_in_channels = 1;
//opts.pulse_raw_out_channels = 1;
//opts.pulse_digi_in_channels = 1; //2
//opts.pulse_digi_out_channels = 1; //2
fprintf (stderr," Monitor Source Audio may cause decoding issues.\n");
fprintf (stderr," Don't Run Monitor Source Audio with Ncurses Terminal.\n");
opts.use_ncurses_terminal = 0; //may not set depends on when -N and -W are first and second
break; break;
case 'N': case 'N':
@@ -1141,7 +1141,7 @@ main (int argc, char **argv)
if (opts.use_ncurses_terminal == 1) if (opts.use_ncurses_terminal == 1)
{ {
ncursesOpen(); ncursesOpen();
ncursesPrinter(&opts, &state); //ncursesPrinter(&opts, &state);
} }
if (opts.resume > 0) if (opts.resume > 0)
@@ -1231,7 +1231,7 @@ main (int argc, char **argv)
} }
if (opts.use_ncurses_terminal == 1){ if (opts.use_ncurses_terminal == 1){
ncursesClose (); //ncursesClose ();
} }
cleanupAndExit (&opts, &state); cleanupAndExit (&opts, &state);

View File

@@ -47,7 +47,9 @@ playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv)
if (opts->audio_out == 1) if (opts->audio_out == 1)
{ {
playSynthesizedVoice (opts, state); playSynthesizedVoice (opts, state);
} }
} }
else if (state->mbe_file_type == 1) else if (state->mbe_file_type == 1)
@@ -164,121 +166,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
} }
} }
void processMbeFrameEncrypted (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char ambe_fr[4][24], char imbe7100_fr[7][24], char ambe_keystream[49], char imbe_keystream[88]) /* This function decipher data */
{
int i;
char imbe_d[88];
char ambe_d[49];
#ifdef AMBE_PACKET_OUT
char ambe_d_str[50];
#endif
for (i = 0; i < 88; i++)
{
imbe_d[i] = 0;
}
if ((state->synctype == 0) || (state->synctype == 1))
{
// 0 +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);
DecipherData(imbe_d, imbe_keystream, imbe_d, 88);
if (opts->mbe_out_f != NULL)
{
saveImbe4400Data (opts, state, imbe_d);
}
}
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);
DecipherData(imbe_d, imbe_keystream, imbe_d, 88);
if (opts->mbe_out_f != NULL)
{
saveImbe4400Data (opts, state, imbe_d);
}
}
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);
state->errs = 0;
state->errs2 = 0;
state->errs = mbe_eccAmbe3600x2400C0 (ambe_fr);
mbe_demodulateAmbe3600x2400Data (ambe_fr);
state->errs2 = state->errs;
state->errs2 += mbe_eccAmbe3600x2400Data (ambe_fr, ambe_d);
memcpy(state->ambe_ciphered, ambe_d, sizeof(state->ambe_ciphered));
DecipherData(ambe_d, ambe_keystream, ambe_d, 49);
memcpy(state->ambe_deciphered, ambe_d, sizeof(state->ambe_deciphered));
mbe_processAmbe2400Dataf (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);
if (opts->mbe_out_f != NULL)
{
saveAmbe2450Data (opts, state, ambe_d);
}
}
else
{
//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);
state->errs = 0;
state->errs2 = 0;
state->errs = mbe_eccAmbe3600x2450C0 (ambe_fr);
mbe_demodulateAmbe3600x2450Data (ambe_fr);
state->errs2 = state->errs;
state->errs2 += mbe_eccAmbe3600x2450Data (ambe_fr, ambe_d);
memcpy(state->ambe_ciphered, ambe_d, sizeof(state->ambe_ciphered));
DecipherData(ambe_d, ambe_keystream, ambe_d, 49);
memcpy(state->ambe_deciphered, ambe_d, sizeof(state->ambe_deciphered));
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);
#ifdef AMBE_PACKET_OUT
for(i=0; i<49; i++) {
ambe_d_str[i] = ambe_d[i] + '0';
}
ambe_d_str[49] = '\0';
// print binary string
fprintf(stderr, "\n?\t?\t%s\t", ambe_d_str);
// print error data
fprintf(stderr, "E1: %d; E2: %d; S: %s", state->errs, state->errs2, state->err_str);
#endif
if (opts->mbe_out_f != NULL)
{
saveAmbe2450Data (opts, state, ambe_d);
}
}
if (opts->errorbars == 1)
{
fprintf(stderr, "%s", state->err_str);
}
state->debug_audio_errors += state->errs2;
processAudio (opts, state);
if (opts->wav_out_f != NULL)
{
writeSynthesizedVoice (opts, state);
}
if (opts->audio_out == 1)
{
playSynthesizedVoice (opts, state);
}
}
/* This function decipher/decrypt data */
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;

View File

@@ -275,6 +275,10 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
{ {
printw ("| Pulse Audio Output [%i] kHz [%i] Channel\n", opts->pulse_digi_rate_out/1000, opts->pulse_digi_out_channels); printw ("| Pulse Audio Output [%i] kHz [%i] Channel\n", opts->pulse_digi_rate_out/1000, opts->pulse_digi_out_channels);
} }
if (opts->monitor_input_audio == 1)
{
printw ("| Monitoring Source Audio when carrier present and No Sync Detected\n");
}
if (opts->mbe_out_dir[0] != 0) if (opts->mbe_out_dir[0] != 0)
{ {
printw ("| Writing MBE data files to directory %s\n", opts->mbe_out_dir); printw ("| Writing MBE data files to directory %s\n", opts->mbe_out_dir);
@@ -459,11 +463,11 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
attroff(COLOR_PAIR(5)); attroff(COLOR_PAIR(5));
attron(COLOR_PAIR(3)); attron(COLOR_PAIR(3));
} }
//if(state->K > 0 && state->dmr_so & 0x40) //if(state->K > 0 && state->payload_keyid == 0 && state->dmr_so & 0x40)
if(state->K > 0 && state->dmr_so == 0x40) if(state->K > 0 && state->dmr_so == 0x40)
{ {
attron(COLOR_PAIR(5)); attron(COLOR_PAIR(5));
//printw ("K 0x[%12llX]", state->K); //seems to get reset in ncurses for some reason? some bigger issue perhaps? other strange issues occur too with provoice printw ("BPK [%3d]", state->K);
attroff(COLOR_PAIR(5)); attroff(COLOR_PAIR(5));
attron(COLOR_PAIR(3)); attron(COLOR_PAIR(3));
} }
@@ -620,7 +624,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (lls != -1) //is there a synctype 0? if (lls != -1) //is there a synctype 0?
{ {
printw ("| %s ", SyncTypes[lls]); printw ("| %s ", SyncTypes[lls]);
printw ("%s", state->dmr_branding); //printw ("%s", state->dmr_branding);
printw ("\n"); printw ("\n");
} }
printw ("------------------------------------------------------------------------------\n"); printw ("------------------------------------------------------------------------------\n");

View File

@@ -84,10 +84,21 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
if(opts->audio_in_type == 0) if(opts->audio_in_type == 0)
{ {
pa_simple_read(opts->pulse_digi_dev_in, &sample, 2, NULL ); pa_simple_read(opts->pulse_digi_dev_in, &sample, 2, NULL );
state->pulse_raw_out_buffer = sample; //steal raw out buffer sample here? //look into how processAudio handles playback, not sure if latency issues, or garbage sample values crash pulse when written
if (opts->monitor_input_audio == 1 && state->lastsynctype == -1 && sample < 32767 && sample > -32767)
{
state->pulse_raw_out_buffer = sample; //steal raw out buffer sample here?
pa_simple_write(opts->pulse_raw_dev_out, (void*)&state->pulse_raw_out_buffer, 2, NULL);
}
} }
else if (opts->audio_in_type == 1) { else if (opts->audio_in_type == 1) {
result = sf_read_short(opts->audio_in_file, &sample, 1); result = sf_read_short(opts->audio_in_file, &sample, 1);
if (opts->monitor_input_audio == 1 && state->lastsynctype == -1 && sample < 32767 && sample > -32767)
{
state->pulse_raw_out_buffer = sample; //steal raw out buffer sample here?
pa_simple_write(opts->pulse_raw_dev_out, (void*)&state->pulse_raw_out_buffer, 2, NULL);
}
if(result == 0) { if(result == 0) {
cleanupAndExit (opts, state); cleanupAndExit (opts, state);
} }
@@ -111,7 +122,11 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
#ifdef USE_RTLSDR #ifdef USE_RTLSDR
// TODO: need to read demodulated stream here // TODO: need to read demodulated stream here
get_rtlsdr_sample(&sample); get_rtlsdr_sample(&sample);
//state->pulse_raw_out_buffer = sample; if (opts->monitor_input_audio == 1 && state->lastsynctype == -1 && sample < 32767 && sample > -32767)
{
state->pulse_raw_out_buffer = sample; //steal raw out buffer sample here?
pa_simple_write(opts->pulse_raw_dev_out, (void*)&state->pulse_raw_out_buffer, 2, NULL);
}
#endif #endif
} }

View File

@@ -67,11 +67,11 @@ void processNXDNData (dsd_opts * opts, dsd_state * state)
if(CrcIsGood) if(CrcIsGood)
{ {
fprintf (stderr, "RAN=%02d - Part %d/4 ", RAN, PartOfFrame + 1); fprintf (stderr, "RAN=%02d - Part %d/4 ", RAN, PartOfFrame + 1);
fprintf (stderr, " (OK) - "); fprintf (stderr, "(CRC OK) ");
state->nxdn_last_ran = RAN; //disable, try to grab this in voice instead state->nxdn_last_ran = RAN; //disable, try to grab this in voice instead
} }
else fprintf (stderr, "(CRC ERR) - "); else fprintf (stderr, "(CRC ERR) ");
/* Decode the SACCH only when all 4 voice frame /* Decode the SACCH only when all 4 voice frame

View File

@@ -627,8 +627,6 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state,
CurrentIV = CurrentIV << 8; CurrentIV = CurrentIV << 8;
} }
/* Encryption is not supported in the public version,
* so do not compute the next IV */
} }
break; break;
} /* End case NXDN_VCALL_IV: */ } /* End case NXDN_VCALL_IV: */
@@ -636,7 +634,7 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state,
/* Unknown Message Type */ /* Unknown Message Type */
default: default:
{ {
fprintf(stderr, "Unknown Message type "); //fprintf(stderr, "Unknown Message type ");
break; break;
} }
} /* End switch(MessageType) */ } /* End switch(MessageType) */
@@ -772,10 +770,10 @@ void NXDN_decode_VCALL(dsd_opts * opts, dsd_state * state, uint8_t * Message)
state->nxdn_key = (KeyID & 0xFF); state->nxdn_key = (KeyID & 0xFF);
state->nxdn_cipher_type = CipherType; state->nxdn_cipher_type = CipherType;
} }
fprintf(stderr, " (OK) - "); fprintf(stderr, "(CRC OK) ");
} }
//fprintf(stderr, " (OK) - "); //fprintf(stderr, " (OK) - ");
else fprintf(stderr, "(CRC ERR) - "); else fprintf(stderr, "(CRC ERR) ");
//fprintf(stderr, "\nVCALL = "); //fprintf(stderr, "\nVCALL = ");
@@ -1043,67 +1041,5 @@ void ScrambledNXDNVoiceBit(int * LfsrValue, char * BufferIn, char * BufferOut, i
} /* End ScrambledNXDNVoiceBit() */ } /* End ScrambledNXDNVoiceBit() */
void NxdnEncryptionStreamGeneration (dsd_opts* opts, dsd_state* state, uint8_t KeyStream[1664])
{
uint32_t i = 0, j = 0, k = 0;
uint32_t LFSR = 0;
uint64_t CurrentIV = 0;
uint64_t NextIV = 0;
uint64_t TempIV = 0;
uint8_t Temp = 0;
/* Remove compiler warning */
/*
UNUSED_VARIABLE(opts);
UNUSED_VARIABLE(state);
UNUSED_VARIABLE(i);
UNUSED_VARIABLE(j);
UNUSED_VARIABLE(k);
UNUSED_VARIABLE(LFSR);
UNUSED_VARIABLE(CurrentIV);
UNUSED_VARIABLE(NextIV);
UNUSED_VARIABLE(TempIV);
UNUSED_VARIABLE(Temp);
*/
if((state->NxdnElementsContent.CipherParameterValidity))
{
//fprintf(stderr, "Scrambler Encryption ");
/* Scrambler encryption mode */
if(state->NxdnElementsContent.CipherType == 0x01)
{
/* Encryption not supported in the public version
* Set the keystream to 0 */
memset(KeyStream, 0, sizeof(uint8_t) * 1664);
} /* End if(state->NxdnElementsContent.CipherType == 0x01) - Scrambler */
/* DES Mode */
else if(state->NxdnElementsContent.CipherType == 0x02)
{
/* Encryption not supported in the public version
* Set the keystream to 0 */
memset(KeyStream, 0, sizeof(uint8_t) * 1664);
} /* End else if(state->NxdnElementsContent.CipherType == 0x02) - DES mode */
/* AES Mode */
else if(state->NxdnElementsContent.CipherType == 0x03)
{
/* Encryption not supported in the public version
* Set the keystream to 0 */
memset(KeyStream, 0, sizeof(uint8_t) * 1664);
} /* End else if(state->NxdnElementsContent.CipherType == 0x03) - AES mode */
else
{
/* No encryption required, simply set the keystream to "0" */
memset(KeyStream, 0, sizeof(uint8_t) * 1664);
}
}
else
{
/* No encryption required or error, simply set the keystream to "0" */
memset(KeyStream, 0, sizeof(uint8_t) * 1664);
}
} /* End NxdnEncryptionStreamGeneration() */
/* End of file */ /* End of file */

View File

@@ -16,7 +16,6 @@ void processNXDNVoice (dsd_opts * opts, dsd_state * state)
uint8_t StructureField = 0; uint8_t StructureField = 0;
uint8_t RAN = 0; uint8_t RAN = 0;
uint8_t PartOfFrame = 0; uint8_t PartOfFrame = 0;
uint8_t KeyStream[1664] = {0};
char ambe7bytesArray[7] = {0}; char ambe7bytesArray[7] = {0};
int PartOfEncryptedSuperFrame = 0; int PartOfEncryptedSuperFrame = 0;
@@ -26,7 +25,7 @@ void processNXDNVoice (dsd_opts * opts, dsd_state * state)
} }
/* Start pseudo-random NXDN sequence after /* Start pseudo-random NXDN sequence after
* LITCH = 16 bit = 8 dibit * LICH = 16 bit = 8 dibit
* ==> Index 8 */ * ==> Index 8 */
pr = (unsigned char *)(&nxdnpr2[8]); pr = (unsigned char *)(&nxdnpr2[8]);
for (i = 0; i < 30; i++) for (i = 0; i < 30; i++)
@@ -82,17 +81,10 @@ void processNXDNVoice (dsd_opts * opts, dsd_state * state)
if(CrcIsGood) if(CrcIsGood)
{ {
fprintf (stderr, "RAN=%02d - Part %d/4 ", RAN, PartOfFrame + 1); fprintf (stderr, "RAN=%02d - Part %d/4 ", RAN, PartOfFrame + 1);
fprintf (stderr, " (OK) - "); fprintf (stderr, "(CRC OK) ");
state->nxdn_last_ran = RAN; //disable, try to grab this in voice instead state->nxdn_last_ran = RAN; //disable, try to grab this in voice instead
} }
else fprintf(stderr, "(CRC ERR) - "); else fprintf(stderr, "(CRC ERR) ");
/* Generate the key stream */
NxdnEncryptionStreamGeneration(opts, state, KeyStream);
//fprintf(stderr, "\nKeyStream = ");
//for(i = 0; i < 49; i++) fprintf(stderr, "%d", KeyStream[i]);
//fprintf(stderr, "\n");
/* Determine the current part of superframe /* Determine the current part of superframe
@@ -114,11 +106,11 @@ void processNXDNVoice (dsd_opts * opts, dsd_state * state)
if (opts->errorbars == 1) if (opts->errorbars == 1)
{ {
fprintf(stderr, "e:"); //fprintf(stderr, "e:");
} }
/* Start pseudo-random NXDN sequence after /* Start pseudo-random NXDN sequence after
* LITCH = 16 bit = 8 dibit + * LICH = 16 bit = 8 dibit +
* SACCH = 60 bit = 30 dibit * SACCH = 60 bit = 30 dibit
* = 76 bit = 38 dibit * = 76 bit = 38 dibit
* ==> Index 38 */ * ==> Index 38 */
@@ -144,26 +136,8 @@ void processNXDNVoice (dsd_opts * opts, dsd_state * state)
y++; y++;
z++; z++;
} }
//processMbeFrame (opts, state, NULL, ambe_fr, NULL); processMbeFrame (opts, state, NULL, ambe_fr, NULL);
processMbeFrameEncrypted(opts, state, NULL, ambe_fr, NULL, (char *)&KeyStream[(PartOfEncryptedSuperFrame * 4 * 4 * 49) + (PartOfFrame * 4 * 49) + (j * 49)], NULL);
#ifdef BUILD_DSD_WITH_FRAME_CONTENT_DISPLAY
if(state->printNXDNAmbeVoiceSampleHex)
{
/* Display AMBE frame content */
/* Convert the 49 bit AMBE frame into 7 bytes */
Convert49BitSampleInto7Bytes(state->ambe_deciphered, ambe7bytesArray);
fprintf(stderr, "\nVoice Frame %d/4 : ", j + 1);
fprintf(stderr, "E1 = %d ; E2 = %d ; Content = ", state->errs, state->errs2);
for(i = 0; i < 7; i++) fprintf(stderr, "0x%02X, ", ambe7bytesArray[i] & 0xFF);
//fprintf(stderr, "\n");
}
#endif /* BUILD_DSD_WITH_FRAME_CONTENT_DISPLAY */
#ifdef NXDN_DUMP
fprintf(stderr, " ");
#endif
} /* End for (j = 0; j < 4; j++) */ } /* End for (j = 0; j < 4; j++) */
if (opts->errorbars == 1) if (opts->errorbars == 1)