Added error correction to the metadata of LDU1 and LDU2.

Refactored implementation of p25p1_ldu1.c and p25p1_ldu2.c. There are less duplicities now and hopefully is easier to read and maintain.
Added a unit test for the Hamming algorithm.
This commit is contained in:
EdFuentetaja
2014-03-31 23:37:08 +08:00
parent 7299b78c3b
commit 01a2b6959a
17 changed files with 1594 additions and 612 deletions

View File

@@ -21,7 +21,7 @@ int check_and_fix_golay24(char* hex, char* parity, int* fixed_errors)
printf("]");
#endif
int uncorrectable_errors = golay24.decode(hex, parity, fixed_errors);
int irrecoverable_errors = golay24.decode(hex, parity, fixed_errors);
#ifdef __CHECK_HDU_DEBUG__
printf(" -> [");
@@ -29,20 +29,20 @@ int check_and_fix_golay24(char* hex, char* parity, int* fixed_errors)
printf("%c", (hex[i] != 0)? 'X': ' ');
}
printf("]");
if (uncorrectable_errors) {
printf(" Errors: +4");
if (irrecoverable_errors) {
printf(" Errors: >4");
} else {
printf(" Errors: %i", *fixed_errors);
}
printf("\n");
#endif
return uncorrectable_errors;
return irrecoverable_errors;
}
void check_and_fix_redsolomon63(char* data, char* parity)
int check_and_fix_redsolomon_36_20_17(char* data, char* parity)
{
static DSDReedSolomon_63_20_17 reed_solomon63;
static DSDReedSolomon_36_20_17 reed_solomon_36_20_17;
#ifdef __CHECK_HDU_DEBUG__
char original[20][6];
@@ -53,22 +53,36 @@ void check_and_fix_redsolomon63(char* data, char* parity)
}
#endif
reed_solomon63.decode(data, parity);
int irrecoverable_errors = reed_solomon_36_20_17.decode(data, parity);
#ifdef __CHECK_HDU_DEBUG__
printf("Results for Reed-Solomon code (n=%3d, k=%3d, t= %3d)\n\n", nn, kk, tt);
printf(" i original fixed\n");
for (int i = 0; i < 20; i++) {
printf("%3d [", i);
for (int j = 0; j < 6; j++) {
printf("%c", (original[i][j] == 1)? 'X' : ' ');
printf("Results for Reed-Solomon code (36,20,17)\n\n");
if (irrecoverable_errors == 0) {
printf(" i original fixed\n");
for (int i = 0; i < 20; i++) {
printf("%3d [", i);
for (int j = 0; j < 6; j++) {
printf("%c", (original[i][j] == 1)? 'X' : ' ');
}
printf("] [");
for (int j = 0; j < 6; j++) {
printf("%c", (data[i*6+j] == 1)? 'X' : ' ');
}
printf("]\n");
}
printf("] [");
for (int j = 0; j < 6; j++) {
printf("%c", (data[i*6+j] == 1)? 'X' : ' ');
} else {
printf("Irrecoverable errors found\n");
printf(" i original fixed\n");
for (int i = 0; i < 20; i++) {
printf("%3d [", i);
for (int j = 0; j < 6; j++) {
printf("%c", (original[i][j] == 1)? 'X' : ' ');
}
printf("]\n");
}
printf("]\n");
}
printf("\n");
#endif
return irrecoverable_errors;
}