mirror of https://github.com/wb2osz/direwolf.git
Cleaned up output.
This commit is contained in:
parent
53d5b2b9f8
commit
a707fc8225
27
src/bch.c
27
src/bch.c
|
@ -254,7 +254,7 @@ int bch_init(bch_t *bch, int m, int length, int t) {
|
||||||
printf("This is a (%d, %d, %d) binary BCH code\n", bch->length, bch->k, d);
|
printf("This is a (%d, %d, %d) binary BCH code\n", bch->length, bch->k, d);
|
||||||
|
|
||||||
/* Compute the generator polynomial */
|
/* Compute the generator polynomial */
|
||||||
bch->g = malloc(rdncy * sizeof(int));
|
bch->g = malloc((rdncy + 1) * sizeof(int));
|
||||||
bch->g[0] = bch->alpha_to[zeros[1]];
|
bch->g[0] = bch->alpha_to[zeros[1]];
|
||||||
bch->g[1] = 1; /* g(x) = (X + zeros[1]) initially */
|
bch->g[1] = 1; /* g(x) = (X + zeros[1]) initially */
|
||||||
for (ii = 2; ii <= rdncy; ii++) {
|
for (ii = 2; ii <= rdncy; ii++) {
|
||||||
|
@ -552,26 +552,28 @@ int main()
|
||||||
};
|
};
|
||||||
|
|
||||||
int bits[63];
|
int bits[63];
|
||||||
|
int temp[8];
|
||||||
bch_t bch;
|
bch_t bch;
|
||||||
|
|
||||||
bch_init(&bch, 6, 63, 3);
|
bch_init(&bch, 6, 63, 3);
|
||||||
|
|
||||||
for (int count = 0; count < sizeof(test) / sizeof(*test); count++) {
|
for (int count = 0; count < sizeof(test) / sizeof(*test); count++) {
|
||||||
bytes_to_bits(test[count], bits, 63);
|
bytes_to_bits(test[count], bits, 63);
|
||||||
#ifdef TEST_BYTES_TO_BITS
|
|
||||||
printf("ORIG pkt [%d]\n", count);
|
printf("--------------------------\nORIG pkt [%d] ", count);
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
printf("%02x ", test[count][i]);
|
printf("%02x ", test[count][i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
#ifdef TEST_BYTES_TO_BITS
|
||||||
|
|
||||||
printf("ORIG pkt[%d] bits\n", count);
|
printf("ORIG pkt[%d] bits\n", count);
|
||||||
for (int i = 0; i < 63; i++) {
|
for (int i = 0; i < 63; i++) {
|
||||||
printf("%d ", bits[i]);
|
printf("%d ", bits[i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
int temp[8];
|
|
||||||
bits_to_bytes(bits, temp, 63);
|
bits_to_bytes(bits, temp, 63);
|
||||||
printf("bits_to_bytes pkt [%d]\n", count);
|
printf("bits_to_bytes pkt [%d]\n", count);
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
|
@ -590,32 +592,41 @@ int main()
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TEST_APPLY
|
#ifdef TEST_APPLY
|
||||||
int recv[63];
|
int recv[63];
|
||||||
|
|
||||||
for (int i = 0; i < 63; i++) {
|
for (int i = 0; i < 63; i++) {
|
||||||
recv[i] = bits[i];
|
recv[i] = bits[i];
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
printf("rearranged packet [%d]: ", count);
|
printf("rearranged packet [%d]: ", count);
|
||||||
for (int i = 0; i < 63; i++) {
|
for (int i = 0; i < 63; i++) {
|
||||||
printf("%d ", recv[i]);
|
printf("%d ", recv[i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
bits_to_bytes(recv, temp, 63);
|
||||||
|
|
||||||
|
printf("original [%d] bytes: ", count);
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
printf("%02x ", temp[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
*/
|
||||||
int corrected = apply_bch(&bch, recv);
|
int corrected = apply_bch(&bch, recv);
|
||||||
|
|
||||||
if (corrected >= 0) {
|
if (corrected >= 0) {
|
||||||
|
/*
|
||||||
printf("corrected [%d] packet: ", corrected);
|
printf("corrected [%d] packet: ", corrected);
|
||||||
for (int i = 0; i < 63; i++) {
|
for (int i = 0; i < 63; i++) {
|
||||||
printf("%d ", recv[i]);
|
printf("%d ", recv[i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
*/
|
||||||
int temp[8];
|
|
||||||
bits_to_bytes(recv, temp, 63);
|
bits_to_bytes(recv, temp, 63);
|
||||||
|
|
||||||
printf("corrected [%d] DATA: ", count);
|
printf("corrected [%d] bytes: ", corrected);
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
printf("%02x ", temp[i]);
|
printf("%02x ", temp[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue