Move Hagelbarger error correction code from NMT to common code

It will be used by Radiocom 2000 also.
Some minor fixes and improvements apply.
This commit is contained in:
Andreas Eversberg
2017-07-24 19:18:01 +02:00
parent 6c64025717
commit 0cbd9657d2
7 changed files with 32 additions and 14 deletions

View File

@@ -79,7 +79,7 @@ test_performance_LDADD = \
-lm
test_hagelbarger_SOURCES = \
$(top_builddir)/src/nmt/hagelbarger.c \
$(top_builddir)/src/common/hagelbarger.c \
test_hagelbarger.c
test_hagelbarger_LDADD = \

View File

@@ -1,7 +1,7 @@
#include "stdio.h"
#include "stdint.h"
#include "string.h"
#include "../nmt/hagelbarger.h"
#include "../common/hagelbarger.h"
int main(void)
{
@@ -9,11 +9,15 @@ int main(void)
printf("Message: %s\n", message);
/* clean tail at code bit 72 and above */
/* clean tail at code bit 70 and above */
memset(code, 0, sizeof(code));
/* encode message */
hagelbarger_encode(message, code, 72);
hagelbarger_encode(message, code, 70);
/* decode */
hagelbarger_decode(code, message, 64);
printf("Decoded without corruption: %s (must be the same as above)\n", message);
/* corrupt data */
code[0] ^= 0xfc;
@@ -22,7 +26,7 @@ int main(void)
/* decode */
hagelbarger_decode(code, message, 64);
printf("Decoded: %s (must be the same as above)\n", message);
printf("Decoded with corruption: %s (must be the same as above)\n", message);
return 0;
}