-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
executable file
·50 lines (41 loc) · 1.08 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "config_polynomials.h"
#include "../lib_data/data.h"
#include "src/poly.h"
#ifdef __AVR__
uint16_t syndrome[N+1] PROGMEM= { {0}, {1}, {2}, {4}, {3}, {7}, {5}, {6} };
#else
uint16_t syndrome[N+1] = { {0}, {1}, {2}, {4}, {3}, {7}, {5}, {6} };
#endif // __AVR__
Poly generator;
void test();
int main(int argc, char *argv[])
{
poly_init_generator();
make_syndrome();
printf("Message: ");
Poly message = data_generate(K);
data_set(0, 1, message);
data_set(1, 1, message);
poly_show(message);
printf("Coded word: ");
Poly coded_word = poly_encode(message);
poly_show(coded_word);
data_set(4,1,coded_word); // Add an error
printf("Modified codeword: ");
poly_show(coded_word);
Poly decoded = poly_decode(coded_word);
printf("Decoded word: ");
poly_show(decoded);
data_free(decoded);
data_free(coded_word);
data_free(message);
data_free(generator);
return EXIT_SUCCESS;
}
void test()
{
Poly m = data_generate(N);
Poly r = poly_remainder(m);
data_free(m);
data_free(r);
}