Misc Code Cleanup;

This commit is contained in:
lwvmobile
2023-08-10 13:57:50 -04:00
parent b50119e0bc
commit d6968dffdd
6 changed files with 29 additions and 230 deletions

View File

@@ -31,12 +31,6 @@ if (PVC)
add_definitions(-DPVCONVENTIONAL) add_definitions(-DPVCONVENTIONAL)
endif () endif ()
#use cmake option -DNXDN=ON to enable the old NXDN Sync Pattern
option(NXDN
"Build with Old NXDN Sync Pattern Enabled" OFF)
if (NXDN)
add_definitions(-DNXDNOLDSYNC)
endif ()
#use cmake option -DLZ=ON to enable LimaZulu Requested NXDN Tweaks #use cmake option -DLZ=ON to enable LimaZulu Requested NXDN Tweaks
option(LZ option(LZ
@@ -45,19 +39,6 @@ if (LZ)
add_definitions(-DLIMAZULUTWEAKS) add_definitions(-DLIMAZULUTWEAKS)
endif () endif ()
#use cmake option -DTONES to change default location of the tones.wav files (lwvmobile precompiled 'Aero' releases only)
option(TN
"Build with tone wav files in the dsd-fme folder and not in /usr/share/" OFF)
if (TN)
add_definitions(-DTONES)
endif ()
#use cmake option -DZDEV to change designation of this build from MAIN to zDEV
option(ZDEV
"change designation of this build from MAIN to zDEV" OFF)
if (ZDEV)
add_definitions(-DZDEV_BUILD)
endif ()
include(git_revision) include(git_revision)
git_describe(GIT_TAG) git_describe(GIT_TAG)

View File

@@ -998,7 +998,6 @@ short nxdn_filter(short sample);
short dpmr_filter(short sample); short dpmr_filter(short sample);
short m17_filter(short sample); short m17_filter(short sample);
int strncmperr(const char *s1, const char *s2, size_t size, int MaxErr);
uint64_t ConvertBitIntoBytes(uint8_t * BufferIn, uint32_t BitLength); uint64_t ConvertBitIntoBytes(uint8_t * BufferIn, uint32_t BitLength);
void ncursesOpen (dsd_opts * opts, dsd_state * state); void ncursesOpen (dsd_opts * opts, dsd_state * state);

View File

@@ -428,7 +428,7 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
uint8_t tdibits[98]; uint8_t tdibits[98];
memset (tdibits, 0, sizeof(tdibits)); memset (tdibits, 0, sizeof(tdibits));
//reconstitute info bits into reverse ordered dibits for the trellis decoder //reconstitute info bits into dibits for the trellis decoder
for (i = 0; i < 98; i++) for (i = 0; i < 98; i++)
tdibits[i] = (info[i*2] << 1) | info[i*2+1]; tdibits[i] = (info[i*2] << 1) | info[i*2+1];
@@ -439,10 +439,9 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
//debug -- its a lot easier to hear the number of errors, than to eyeball it //debug -- its a lot easier to hear the number of errors, than to eyeball it
// if (IrrecoverableErrors) beeper (opts, state, slot); // if (IrrecoverableErrors) beeper (opts, state, slot);
for (i = 0; i < pdu_len; i++) //18 for (i = 0; i < pdu_len; i++)
DMR_PDU[i] = TrellisReturn[i+pdu_start]; DMR_PDU[i] = TrellisReturn[i+pdu_start];
for(i = 0, j = 0; i < 18; i++, j+=8) for(i = 0, j = 0; i < 18; i++, j+=8)
{ {
DMR_PDU_bits[j + 0] = (TrellisReturn[i] >> 7) & 0x01; DMR_PDU_bits[j + 0] = (TrellisReturn[i] >> 7) & 0x01;
@@ -467,7 +466,6 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
CRCExtracted = CRCExtracted ^ crcmask; CRCExtracted = CRCExtracted ^ crcmask;
//reorganize the DMR_PDU_bits array into confdatabits, just for CRC9 check //reorganize the DMR_PDU_bits array into confdatabits, just for CRC9 check
//confirmed working now!
for(i = 0; i < 128; i++) confdatabits[i] = DMR_PDU_bits[i + 16]; for(i = 0; i < 128; i++) confdatabits[i] = DMR_PDU_bits[i + 16];
for(i = 0; i < 7; i++) confdatabits[i + 128] = DMR_PDU_bits[i]; for(i = 0; i < 7; i++) confdatabits[i + 128] = DMR_PDU_bits[i];
@@ -478,10 +476,8 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
state->data_block_crc_valid[slot][blockcounter] = 1; state->data_block_crc_valid[slot][blockcounter] = 1;
} }
else else
{
state->data_block_crc_valid[slot][blockcounter] = 0; state->data_block_crc_valid[slot][blockcounter] = 0;
}
} }

View File

@@ -18,39 +18,6 @@
#include "dsd.h" #include "dsd.h"
#include <locale.h> #include <locale.h>
//borrowed from LEH/DSDcc for 'improved NXDN sync detection'
int strncmperr(const char *s1, const char *s2, size_t size, int MaxErr)
{
int Compare = -1;
size_t i = 0;
int err = 0;
int BreakBeforeEnd = 0;
if(s1 && s2)
{
for(i = 0; i < size; i++)
{
if(((s1[i] & 0xFF) != '\0') && ((s2[i] & 0xFF) != '\0'))
{
if((s1[i] & 0xFF) != (s2[i] & 0xFF)) err++;
}
else
{
BreakBeforeEnd = 1;
break;
}
}
if((err <= MaxErr) && (BreakBeforeEnd == 0))
{
Compare = 0;
}
} /* End if(s1 && s2) */
return Compare;
} /* End strncmperr() */
char * getTime(void) //get pretty hh:mm:ss timestamp char * getTime(void) //get pretty hh:mm:ss timestamp
{ {
time_t t = time(NULL); time_t t = time(NULL);
@@ -214,7 +181,6 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
char synctest[25]; char synctest[25];
char synctest12[13]; //dPMR char synctest12[13]; //dPMR
char synctest10[11]; //NXDN FSW only char synctest10[11]; //NXDN FSW only
char synctest19[20]; //NXDN Preamble + FSW
char synctest18[19]; char synctest18[19];
char synctest32[33]; char synctest32[33];
char synctest20[21]; //YSF char synctest20[21]; //YSF
@@ -1289,139 +1255,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
} }
#ifdef NXDNOLDSYNC //Use FSW vs strncmperr method //NXDN
//NXDN FSW sync and handling - moved to very bottom of sync stack for falsing sanity
else if ((opts->frame_nxdn96 == 1) || (opts->frame_nxdn48 == 1)) else if ((opts->frame_nxdn96 == 1) || (opts->frame_nxdn48 == 1))
{ {
strncpy (synctest10, (synctest_p - 9), 10); //FSW only strncpy (synctest10, (synctest_p - 9), 10); //FSW only
strncpy (synctest19, (synctest_p - 18), 19); //Preamble + FSW
//Preamble plus FSW, proceed right away
if ( (strncmperr (synctest19, NXDN_PANDFSW, 19, 1) == 0) )
{
state->carrier = 1;
state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2;
state->lastsynctype = 28;
state->last_cc_sync_time = time(NULL);
// if (opts->payload == 1) fprintf (stderr, "PANDF ");
// fprintf (stderr, " %s ", synctest19);
return (28);
}
else if ( (strncmperr (synctest19, INV_NXDN_PANDFSW, 19, 1) == 0) )
{
state->carrier = 1;
state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2;
state->lastsynctype = 29;
state->last_cc_sync_time = time(NULL);
// if (opts->payload == 1) fprintf (stderr, "PANDF ");
// fprintf (stderr, " %s ", synctest19);
return (29);
}
else if ( (strncmperr (synctest10, NXDN_FSW, 10, 1) == 0) )
{
state->carrier = 1;
state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2;
if (state->lastsynctype == 28)
{
state->last_cc_sync_time = time(NULL);
// if (opts->payload == 1) fprintf (stderr, "FSW ");
// fprintf (stderr, " %s ", synctest10);
return (28);
}
state->lastsynctype = 28; //need two consecutive patterns to continue
}
else if ( (strncmperr (synctest10, INV_NXDN_FSW, 10, 1) == 0) )
{
state->carrier = 1;
state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2;
if (state->lastsynctype == 29)
{
state->last_cc_sync_time = time(NULL);
// if (opts->payload == 1) fprintf (stderr, "FSW ");
// fprintf (stderr, " %s ", synctest10);
return (29);
}
state->lastsynctype = 29; //need two consecutive patterns to continue
}
}
#else //use Current FSW Pattern
//NXDN FSW sync and handling - using more exact frame sync values
else if ((opts->frame_nxdn96 == 1) || (opts->frame_nxdn48 == 1))
{
strncpy (synctest10, (synctest_p - 9), 10); //FSW only
strncpy (synctest19, (synctest_p - 18), 19); //Preamble + FSW
//Using Hard Coded Sync Strings with variations for the areas where the symbol
//error will occur due to the demodulation issues internally
//Disabling the Preamble+FSW version for now
//its nearly impossible to catch it
//Preamble plus FSW, proceed right away
// if (
// (strcmp (synctest19, "3131133313131331131") == 0 )
// || (strcmp (synctest19, "3131133313331331131") == 0 )
// || (strcmp (synctest19, "3131133313131331111") == 0 )
// || (strcmp (synctest19, "3131133313331331111") == 0 )
// )
// {
// //state->carrier = 1;
// state->offset = synctest_pos;
// state->max = ((state->max) + lmax) / 2;
// state->min = ((state->min) + lmin) / 2;
// state->lastsynctype = 28;
// state->last_cc_sync_time = time(NULL);
// // if (opts->payload == 1)
// // fprintf (stderr, "\n +PANDF ");
// // if (opts->payload == 1)
// // fprintf (stderr, " %s \n", synctest19);
// return (28);
// }
// else if (
// (strcmp (synctest19, "1313311133131331131") == 0 )
// || (strcmp (synctest19, "1313311133331331131") == 0 )
// || (strcmp (synctest19, "1313311133131331111") == 0 )
// || (strcmp (synctest19, "1313311133331331111") == 0 )
// )
// {
// // state->carrier = 1;
// state->carrier = 1;
// state->offset = synctest_pos;
// state->max = ((state->max) + lmax) / 2;
// state->min = ((state->min) + lmin) / 2;
// state->lastsynctype = 29;
// state->last_cc_sync_time = time(NULL);
// // if (opts->payload == 1)
// // fprintf (stderr, "\n -PANDF ");
// // if (opts->payload == 1)
// // fprintf (stderr, " %s \n", synctest19);
// return (29);
// }
// else if (
if ( if (
(strcmp (synctest10, "3131331131") == 0 ) //this seems to be the most common 'correct' pattern on Type-C (strcmp (synctest10, "3131331131") == 0 ) //this seems to be the most common 'correct' pattern on Type-C
|| (strcmp (synctest10, "3331331131") == 0 ) //this one hits on new sync but gives a bad lich code || (strcmp (synctest10, "3331331131") == 0 ) //this one hits on new sync but gives a bad lich code
@@ -1432,19 +1269,12 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
) )
{ {
// state->carrier = 1;
state->offset = synctest_pos; state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2; state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2; state->min = ((state->min) + lmin) / 2;
// state->last_cc_sync_time = time(NULL);
if (state->lastsynctype == 28) if (state->lastsynctype == 28)
{ {
state->last_cc_sync_time = time(NULL); state->last_cc_sync_time = time(NULL);
// if (opts->payload == 1)
// fprintf (stderr, "\n +FSW ");
// if (opts->payload == 1)
// fprintf (stderr, " %s \n", synctest10);
return (28); return (28);
} }
state->lastsynctype = 28; state->lastsynctype = 28;
@@ -1456,32 +1286,23 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|| (strcmp (synctest10, "1113113313") == 0 ) || (strcmp (synctest10, "1113113313") == 0 )
|| (strcmp (synctest10, "1313113333") == 0 ) || (strcmp (synctest10, "1313113333") == 0 )
|| (strcmp (synctest10, "1113113333") == 0 ) || (strcmp (synctest10, "1113113333") == 0 )
|| (strcmp (synctest10, "1313133313") == 0 ) // || (strcmp (synctest10, "1313133313") == 0 )
) )
{ {
// state->carrier = 1;
state->offset = synctest_pos; state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2; state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2; state->min = ((state->min) + lmin) / 2;
// state->last_cc_sync_time = time(NULL);
if (state->lastsynctype == 29) if (state->lastsynctype == 29)
{ {
state->last_cc_sync_time = time(NULL); state->last_cc_sync_time = time(NULL);
// if (opts->payload == 1)
// fprintf (stderr, "\n -FSW ");
// if (opts->payload == 1)
// fprintf (stderr, " %s \n", synctest10);
return (29); return (29);
} }
state->lastsynctype = 29; state->lastsynctype = 29;
} }
} }
#endif //NXDN Sync Type Selection
//Provoice Conventional -- Some False Positives due to shortened frame sync pattern, so use squelch if possible //Provoice Conventional -- Some False Positives due to shortened frame sync pattern, so use squelch if possible
#ifdef PVCONVENTIONAL #ifdef PVCONVENTIONAL
if (opts->frame_provoice == 1) if (opts->frame_provoice == 1)

View File

@@ -2236,7 +2236,9 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (i == 1) printw (" ESC to Menu"); if (i == 1) printw (" ESC to Menu");
if (i == 2) printw (" 'q' to Quit "); if (i == 2) printw (" 'q' to Quit ");
if (i == 4 && opts->frame_m17 == 0) printw (" MBElib %s", versionstr); if (i == 4 && opts->frame_m17 == 0) printw (" MBElib %s", versionstr);
#ifdef USE_CODEC2
if (i == 4 && opts->frame_m17 == 1) printw (" CODEC2"); if (i == 4 && opts->frame_m17 == 1) printw (" CODEC2");
#endif
#ifdef AERO_BUILD #ifdef AERO_BUILD
if (i == 5) printw (" %s ", "Aero Build"); if (i == 5) printw (" %s ", "Aero Build");
if (i == 6) printw (" AW (WIP) \n"); if (i == 6) printw (" AW (WIP) \n");