aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-07-24 19:18:01 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2017-08-08 12:53:48 +0200
commit0cbd9657d20fb300d4fc2039ec137988eb40d21a (patch)
tree6fc80af8fb3f701eca4a4b98b8b851eaa599ac20 /src/test
parent6c6402571758340c640bd2350599ff6a9e5ffeb6 (diff)
Move Hagelbarger error correction code from NMT to common code
It will be used by Radiocom 2000 also. Some minor fixes and improvements apply.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/Makefile.am2
-rw-r--r--src/test/test_hagelbarger.c12
2 files changed, 9 insertions, 5 deletions
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
index dbe6c73..d9f0de9 100644
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -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 = \
diff --git a/src/test/test_hagelbarger.c b/src/test/test_hagelbarger.c
index d4117e3..1e0838a 100644
--- a/src/test/test_hagelbarger.c
+++ b/src/test/test_hagelbarger.c
@@ -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;
}