mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-12 08:47:24 -05:00
Misc Code Cleanup;
This commit is contained in:
@@ -31,12 +31,6 @@ if (PVC)
|
||||
add_definitions(-DPVCONVENTIONAL)
|
||||
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
|
||||
option(LZ
|
||||
@@ -45,19 +39,6 @@ if (LZ)
|
||||
add_definitions(-DLIMAZULUTWEAKS)
|
||||
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)
|
||||
git_describe(GIT_TAG)
|
||||
|
||||
@@ -998,7 +998,6 @@ short nxdn_filter(short sample);
|
||||
short dpmr_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);
|
||||
|
||||
void ncursesOpen (dsd_opts * opts, dsd_state * state);
|
||||
|
||||
24
src/dmr_34.c
24
src/dmr_34.c
@@ -9,10 +9,10 @@
|
||||
#include "dsd.h"
|
||||
|
||||
uint8_t interleave[98] = {
|
||||
0, 1, 8, 9, 16, 17, 24, 25, 32, 33, 40, 41, 48, 49, 56, 57, 64, 65, 72, 73, 80, 81, 88, 89, 96, 97,
|
||||
2, 3, 10, 11, 18, 19, 26, 27, 34, 35, 42, 43, 50, 51, 58, 59, 66, 67, 74, 75, 82, 83, 90, 91,
|
||||
4, 5, 12, 13, 20, 21, 28, 29, 36, 37, 44, 45, 52, 53, 60, 61, 68, 69, 76, 77, 84, 85, 92, 93,
|
||||
6, 7, 14, 15, 22, 23, 30, 31, 38, 39, 46, 47, 54, 55, 62, 63, 70, 71, 78, 79, 86, 87, 94, 95};
|
||||
0, 1, 8, 9, 16, 17, 24, 25, 32, 33, 40, 41, 48, 49, 56, 57, 64, 65, 72, 73, 80, 81, 88, 89, 96, 97,
|
||||
2, 3, 10, 11, 18, 19, 26, 27, 34, 35, 42, 43, 50, 51, 58, 59, 66, 67, 74, 75, 82, 83, 90, 91,
|
||||
4, 5, 12, 13, 20, 21, 28, 29, 36, 37, 44, 45, 52, 53, 60, 61, 68, 69, 76, 77, 84, 85, 92, 93,
|
||||
6, 7, 14, 15, 22, 23, 30, 31, 38, 39, 46, 47, 54, 55, 62, 63, 70, 71, 78, 79, 86, 87, 94, 95};
|
||||
|
||||
//this is a convertion table for converting the dibit pairs into contellation points
|
||||
uint8_t constellation_map[16] = {
|
||||
@@ -25,14 +25,14 @@ uint8_t constellation_map[16] = {
|
||||
|
||||
//finite state machine values
|
||||
uint8_t fsm[64] = {
|
||||
0, 8, 4, 12, 2, 10, 6, 14,
|
||||
4, 12, 2, 10, 6, 14, 0, 8,
|
||||
1, 9, 5, 13, 3, 11, 7, 15,
|
||||
5, 13, 3, 11, 7, 15, 1, 9,
|
||||
3, 11, 7, 15, 1, 9, 5, 13,
|
||||
7, 15, 1, 9, 5, 13, 3, 11,
|
||||
2, 10, 6, 14, 0, 8, 4, 12,
|
||||
6, 14, 0, 8, 4, 12, 2, 10};
|
||||
0, 8, 4, 12, 2, 10, 6, 14,
|
||||
4, 12, 2, 10, 6, 14, 0, 8,
|
||||
1, 9, 5, 13, 3, 11, 7, 15,
|
||||
5, 13, 3, 11, 7, 15, 1, 9,
|
||||
3, 11, 7, 15, 1, 9, 5, 13,
|
||||
7, 15, 1, 9, 5, 13, 3, 11,
|
||||
2, 10, 6, 14, 0, 8, 4, 12,
|
||||
6, 14, 0, 8, 4, 12, 2, 10};
|
||||
|
||||
uint32_t dmr_34(uint8_t * input, uint8_t treturn[18])
|
||||
{
|
||||
|
||||
@@ -428,7 +428,7 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
|
||||
uint8_t tdibits[98];
|
||||
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++)
|
||||
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
|
||||
// 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];
|
||||
|
||||
|
||||
for(i = 0, j = 0; i < 18; i++, j+=8)
|
||||
{
|
||||
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;
|
||||
|
||||
//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 < 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;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
state->data_block_crc_valid[slot][blockcounter] = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -18,39 +18,6 @@
|
||||
#include "dsd.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
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
@@ -214,7 +181,6 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
char synctest[25];
|
||||
char synctest12[13]; //dPMR
|
||||
char synctest10[11]; //NXDN FSW only
|
||||
char synctest19[20]; //NXDN Preamble + FSW
|
||||
char synctest18[19];
|
||||
char synctest32[33];
|
||||
char synctest20[21]; //YSF
|
||||
@@ -1289,162 +1255,26 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
|
||||
}
|
||||
|
||||
#ifdef NXDNOLDSYNC //Use FSW vs strncmperr method
|
||||
|
||||
//NXDN FSW sync and handling - moved to very bottom of sync stack for falsing sanity
|
||||
//NXDN
|
||||
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
|
||||
|
||||
//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 (
|
||||
(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, "3131331111") == 0 )
|
||||
|| (strcmp (synctest10, "3331331111") == 0 )
|
||||
|| (strcmp (synctest10, "3131311131") == 0 ) //First few FSW on NXDN48 Type-C seems to hit this for some reason
|
||||
(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, "3131331111") == 0 )
|
||||
|| (strcmp (synctest10, "3331331111") == 0 )
|
||||
|| (strcmp (synctest10, "3131311131") == 0 ) //First few FSW on NXDN48 Type-C seems to hit this for some reason
|
||||
|
||||
)
|
||||
)
|
||||
{
|
||||
|
||||
// state->carrier = 1;
|
||||
state->offset = synctest_pos;
|
||||
state->max = ((state->max) + lmax) / 2;
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
// state->last_cc_sync_time = time(NULL);
|
||||
|
||||
if (state->lastsynctype == 28)
|
||||
{
|
||||
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);
|
||||
}
|
||||
state->lastsynctype = 28;
|
||||
@@ -1452,36 +1282,27 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
|
||||
else if (
|
||||
|
||||
(strcmp (synctest10, "1313113313") == 0 )
|
||||
|| (strcmp (synctest10, "1113113313") == 0 )
|
||||
|| (strcmp (synctest10, "1313113333") == 0 )
|
||||
|| (strcmp (synctest10, "1113113333") == 0 )
|
||||
|| (strcmp (synctest10, "1313133313") == 0 ) //
|
||||
(strcmp (synctest10, "1313113313") == 0 )
|
||||
|| (strcmp (synctest10, "1113113313") == 0 )
|
||||
|| (strcmp (synctest10, "1313113333") == 0 )
|
||||
|| (strcmp (synctest10, "1113113333") == 0 )
|
||||
|| (strcmp (synctest10, "1313133313") == 0 )
|
||||
|
||||
)
|
||||
{
|
||||
|
||||
// state->carrier = 1;
|
||||
state->offset = synctest_pos;
|
||||
state->max = ((state->max) + lmax) / 2;
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
// state->last_cc_sync_time = time(NULL);
|
||||
|
||||
if (state->lastsynctype == 29)
|
||||
{
|
||||
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);
|
||||
}
|
||||
state->lastsynctype = 29;
|
||||
}
|
||||
}
|
||||
|
||||
#endif //NXDN Sync Type Selection
|
||||
|
||||
//Provoice Conventional -- Some False Positives due to shortened frame sync pattern, so use squelch if possible
|
||||
#ifdef PVCONVENTIONAL
|
||||
if (opts->frame_provoice == 1)
|
||||
|
||||
@@ -2236,7 +2236,9 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||
if (i == 1) printw (" ESC to Menu");
|
||||
if (i == 2) printw (" 'q' to Quit ");
|
||||
if (i == 4 && opts->frame_m17 == 0) printw (" MBElib %s", versionstr);
|
||||
#ifdef USE_CODEC2
|
||||
if (i == 4 && opts->frame_m17 == 1) printw (" CODEC2");
|
||||
#endif
|
||||
#ifdef AERO_BUILD
|
||||
if (i == 5) printw (" %s ", "Aero Build");
|
||||
if (i == 6) printw (" AW (WIP) \n");
|
||||
|
||||
Reference in New Issue
Block a user