P25p1 -- LSD Parity Check; #166

This commit is contained in:
lwvmobile
2023-10-09 17:35:11 -04:00
parent 55a1d5a9f3
commit a6a300e7c5
4 changed files with 88 additions and 32 deletions

View File

@@ -32,9 +32,9 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
char algid[9], kid[17];
char lsd1[9], lsd2[9];
int algidhex, kidhex;
uint8_t lsd_hex1, lsd_hex2;
uint8_t lsd_hex1, lsd_hex2; uint8_t lowspeeddata[32]; memset (lowspeeddata, 0, sizeof(lowspeeddata));
unsigned long long int mihex1, mihex2, mihex3;
int status_count;
int status_count; int lsd1_okay, lsd2_okay = 0;
UNUSED(mihex3);
char hex_data[16][6]; // Data in hex-words (6 bit words). A total of 16 hex words.
@@ -230,6 +230,8 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
lsd_hex1 = lsd_hex1 << 1;
lsd1[i] = lsd[i] + '0';
lsd_hex1 |= (uint8_t)lsd[i];
lowspeeddata[i+0] = (uint8_t)lsd1[i];
lowspeeddata[i+8] = (uint8_t)cyclic_parity[i];;
}
for (i=0; i<=6; i+=2)
@@ -246,6 +248,8 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
lsd_hex2 = lsd_hex2 << 1;
lsd2[i] = lsd[i] + '0';
lsd_hex2 |= (uint8_t)lsd[i];
lowspeeddata[i+16] = (uint8_t)lsd2[i];
lowspeeddata[i+24] = (uint8_t)cyclic_parity[i];
}
// TODO: error correction of the LSD bytes... <--THIS!
@@ -455,6 +459,10 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
mihex2 = (unsigned long long int)ConvertBitIntoBytes(&mi[32], 32);
mihex3 = (unsigned long long int)ConvertBitIntoBytes(&mi[64], 8);
//WIP: LSD FEC
lsd1_okay = p25p1_lsd_fec (lowspeeddata+0);
lsd2_okay = p25p1_lsd_fec (lowspeeddata+16);
if (irrecoverable_errors == 0)
{
fprintf (stderr, "%s", KYEL);
@@ -481,46 +489,50 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
fprintf (stderr, " ENC");
fprintf (stderr, "%s", KNRM);
}
if (opts->payload == 1)
{
//view Low Speed Data
fprintf (stderr, "%s",KCYN);
fprintf (stderr, " LSD: %02X %02X ", lsd_hex1, lsd_hex2);
if ( (lsd_hex1 > 0x19) && (lsd_hex1 < 0x7F) ) fprintf (stderr, "(%c", lsd_hex1);
else fprintf (stderr, "( ");
if ( (lsd_hex2 > 0x19) && (lsd_hex2 < 0x7F) )fprintf (stderr, "%c)", lsd_hex2);
else fprintf (stderr, " )");
fprintf (stderr, "%s",KNRM);
}
fprintf (stderr, "\n");
}
else
{
fprintf (stderr, "%s", KRED);
fprintf (stderr, " LDU2 FEC ERR \n");
fprintf (stderr, " LDU2 FEC ERR ");
fprintf (stderr, "%s", KNRM);
}
if (opts->payload == 1)
{
//view Low Speed Data
fprintf (stderr, "%s",KCYN);
fprintf (stderr, " LSD: %02X %02X ", lsd_hex1, lsd_hex2);
if ( (lsd_hex1 > 0x19) && (lsd_hex1 < 0x7F) && (lsd1_okay == 1) ) fprintf (stderr, "(%c", lsd_hex1);
else fprintf (stderr, "( ");
if ( (lsd_hex2 > 0x19) && (lsd_hex2 < 0x7F) && (lsd2_okay == 1) ) fprintf (stderr, "%c)", lsd_hex2);
else fprintf (stderr, " )");
if (lsd1_okay == 0) fprintf (stderr, " L1 ERR");
if (lsd2_okay == 0) fprintf (stderr, " L2 ERR");
fprintf (stderr, "%s", KNRM);
}
fprintf (stderr, "\n", KNRM);
//TEST: Store LSD into array if 0x02 0x08 (opcode and len?)
int k = 0;
if (state->dmr_alias_format[0] == 0x02)
{
k = state->data_block_counter[0];
if ( (lsd_hex1 > 0x19) && (lsd_hex1 < 0x7F) )
if ( (lsd_hex1 > 0x19) && (lsd_hex1 < 0x7F) && (lsd1_okay == 1) )
state->dmr_alias_block_segment[0][0][k/4][k%4] = (char)lsd_hex1;
else state->dmr_alias_block_segment[0][0][k/4][k%4] = 0x20;
// else state->dmr_alias_block_segment[0][0][k/4][k%4] = 0x20;
k++;
if ( (lsd_hex2 > 0x19) && (lsd_hex2 < 0x7F) )
if ( (lsd_hex2 > 0x19) && (lsd_hex2 < 0x7F) && (lsd2_okay == 1) )
state->dmr_alias_block_segment[0][0][k/4][k%4] = (char)lsd_hex2;
else state->dmr_alias_block_segment[0][0][k/4][k%4] = 0x20;
// else state->dmr_alias_block_segment[0][0][k/4][k%4] = 0x20;
k++;
state->data_block_counter[0] = k;
}
//reset format, len, counter.
if (lsd_hex1 == 0x02)
if (lsd_hex1 == 0x02 && lsd1_okay == 1 && lsd2_okay == 1)
{
state->dmr_alias_format[0] = 0x02;
if (lsd_hex2 > 8) lsd_hex2 = 8; //sanity check