DMR 3/4 Simple Error Correction;

This commit is contained in:
lwvmobile
2023-08-19 07:43:30 -04:00
parent abe2e61cf2
commit 1c17757a4e
2 changed files with 35 additions and 8 deletions

View File

@@ -60,6 +60,14 @@ uint32_t dmr_34(uint8_t * input, uint8_t treturn[18])
for (i = 0; i < 49; i++)
point[i] = constellation_map[nibs[i]];
//debug view points -- point[0] should be zero
// fprintf (stderr, "\n P =");
// for (i = 0; i < 49; i++)
// fprintf (stderr, " %02d", point[i]);
//free-bee on err correction, point[0] should always be zero (flush bits)
point[0] = 0;
//convert constellation points into tribit values using the FSM
uint8_t state = 0;
uint32_t tribits[49];
@@ -82,16 +90,31 @@ uint32_t dmr_34(uint8_t * input, uint8_t treturn[18])
if (tribits[i] > 7)
{
irr_err++; //tally number of errors
state = 0; //just using this for now, ideally we want to try to correct errors
}
//TODO: Implement some form/attempt to correct errors here
//debug position of error and state value
// fprintf (stderr, " %d:%d;", i, state);
//Make a hard decision and flip point to fit in current state
point[i] ^= 7; //lucky number 7 (0111)
//NOTE: Ideally, a full path metric to find the surviving path
//is the best way to correct this, but it is also complex and no garauntee to fix errs
//decrement one and try again
if (i != 0) i--;
}
}
//if there are no errors, then convert tribits into a return payload
//debug view tribits/states
// fprintf (stderr, "\n T =");
// for (i = 0; i < 49; i++)
// fprintf (stderr, " %02d", tribits[i]);
//convert tribits into a return payload
uint32_t temp = 0;
if (irr_err == 0)
if (1 == 1) //irr_err == 0
{
//break into chunks of 24 bit values and shuffle into 8-bit (byte) treturn values
for (i = 0; i < 6; i++)
@@ -104,6 +127,10 @@ uint32_t dmr_34(uint8_t * input, uint8_t treturn[18])
}
}
//trellis point/state err tally
if (irr_err != 0)
fprintf (stderr, " ERR = %d", irr_err);
return (irr_err);
}

View File

@@ -436,8 +436,8 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
memset (TrellisReturn, 0, sizeof(TrellisReturn));
IrrecoverableErrors = dmr_34(tdibits, TrellisReturn);
//debug -- its a lot easier to hear the number of errors, than to eyeball it
// if (IrrecoverableErrors) beeper (opts, state, slot);
//NOTE: IrrecoverableErrors in this context are a tally of errors from trellis
//they may have been successfully corrected, the CRC will reveal as much
for (i = 0; i < pdu_len; i++)
DMR_PDU[i] = TrellisReturn[i+pdu_start];
@@ -597,7 +597,7 @@ void dmr_data_burst_handler(dsd_opts * opts, dsd_state * state, uint8_t info[196
// }
if (IrrecoverableErrors != 0 && databurst != 0x09) //&& databurst != 0x05
if (IrrecoverableErrors != 0 && databurst != 0x08 && databurst != 0x09) //&& databurst != 0x05
{
fprintf (stderr, "%s", KRED);
fprintf(stderr, " (FEC ERR)");