Skip to content

Commit a707fc8

Browse files
committed
Cleaned up output.
1 parent 53d5b2b commit a707fc8

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

Diff for: src/bch.c

+20-9
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ int bch_init(bch_t *bch, int m, int length, int t) {
254254
printf("This is a (%d, %d, %d) binary BCH code\n", bch->length, bch->k, d);
255255

256256
/* Compute the generator polynomial */
257-
bch->g = malloc(rdncy * sizeof(int));
257+
bch->g = malloc((rdncy + 1) * sizeof(int));
258258
bch->g[0] = bch->alpha_to[zeros[1]];
259259
bch->g[1] = 1; /* g(x) = (X + zeros[1]) initially */
260260
for (ii = 2; ii <= rdncy; ii++) {
@@ -552,26 +552,28 @@ int main()
552552
};
553553

554554
int bits[63];
555+
int temp[8];
555556
bch_t bch;
556557

557558
bch_init(&bch, 6, 63, 3);
558559

559560
for (int count = 0; count < sizeof(test) / sizeof(*test); count++) {
560561
bytes_to_bits(test[count], bits, 63);
561-
#ifdef TEST_BYTES_TO_BITS
562-
printf("ORIG pkt [%d]\n", count);
562+
563+
printf("--------------------------\nORIG pkt [%d] ", count);
563564
for (int i = 0; i < 8; i++) {
564565
printf("%02x ", test[count][i]);
565566
}
566567
printf("\n");
568+
569+
#ifdef TEST_BYTES_TO_BITS
567570

568571
printf("ORIG pkt[%d] bits\n", count);
569572
for (int i = 0; i < 63; i++) {
570573
printf("%d ", bits[i]);
571574
}
572575
printf("\n");
573576

574-
int temp[8];
575577
bits_to_bytes(bits, temp, 63);
576578
printf("bits_to_bytes pkt [%d]\n", count);
577579
for (int i = 0; i < 8; i++) {
@@ -590,32 +592,41 @@ int main()
590592
}
591593
printf("\n");
592594
#endif
595+
593596
#ifdef TEST_APPLY
594597
int recv[63];
595598

596599
for (int i = 0; i < 63; i++) {
597600
recv[i] = bits[i];
598601
}
599-
602+
/*
600603
printf("rearranged packet [%d]: ", count);
601604
for (int i = 0; i < 63; i++) {
602605
printf("%d ", recv[i]);
603606
}
604607
printf("\n");
605-
608+
609+
bits_to_bytes(recv, temp, 63);
610+
611+
printf("original [%d] bytes: ", count);
612+
for (int i = 0; i < 8; i++) {
613+
printf("%02x ", temp[i]);
614+
}
615+
printf("\n");
616+
*/
606617
int corrected = apply_bch(&bch, recv);
607618

608619
if (corrected >= 0) {
620+
/*
609621
printf("corrected [%d] packet: ", corrected);
610622
for (int i = 0; i < 63; i++) {
611623
printf("%d ", recv[i]);
612624
}
613625
printf("\n");
614-
615-
int temp[8];
626+
*/
616627
bits_to_bytes(recv, temp, 63);
617628

618-
printf("corrected [%d] DATA: ", count);
629+
printf("corrected [%d] bytes: ", corrected);
619630
for (int i = 0; i < 8; i++) {
620631
printf("%02x ", temp[i]);
621632
}

0 commit comments

Comments
 (0)