aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-07-15 21:49:28 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2017-08-08 12:52:29 +0200
commit0c9de251bedc16e51a1b5f5dc2735fa878708098 (patch)
tree7b2176be70afdbf4548189f39ad169ea2ccee514 /src/test
parentcd9cb9a1070f008b676cd5925f74d47f13dd5122 (diff)
NMT: Implement Hagelbarger Code
This will correct burst errors of received messages. If the message is too corrupted, it will be ignored, because some element may not match then. The digits and line signals are checked for consistency, since they are repeated serveral times in a message.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/Makefile.am10
-rw-r--r--src/test/test_hagelbarger.c29
2 files changed, 38 insertions, 1 deletions
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
index 852c235..dbe6c73 100644
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -7,7 +7,8 @@ noinst_PROGRAMS = \
test_emphasis \
test_dms \
test_sms \
- test_performance
+ test_performance \
+ test_hagelbarger
test_filter_SOURCES = test_filter.c dummy.c
@@ -77,3 +78,10 @@ test_performance_LDADD = \
$(SOAPY_LIBS) \
-lm
+test_hagelbarger_SOURCES = \
+ $(top_builddir)/src/nmt/hagelbarger.c \
+ test_hagelbarger.c
+
+test_hagelbarger_LDADD = \
+ $(COMMON_LA)
+
diff --git a/src/test/test_hagelbarger.c b/src/test/test_hagelbarger.c
new file mode 100644
index 0000000..d4117e3
--- /dev/null
+++ b/src/test/test_hagelbarger.c
@@ -0,0 +1,29 @@
+#include "stdio.h"
+#include "stdint.h"
+#include "string.h"
+#include "../nmt/hagelbarger.h"
+
+int main(void)
+{
+ uint8_t message[9] = "JollyRog", code[20];
+
+ printf("Message: %s\n", message);
+
+ /* clean tail at code bit 72 and above */
+ memset(code, 0, sizeof(code));
+
+ /* encode message */
+ hagelbarger_encode(message, code, 72);
+
+ /* corrupt data */
+ code[0] ^= 0xfc;
+ code[3] ^= 0xfc;
+ code[7] ^= 0xfc;
+
+ /* decode */
+ hagelbarger_decode(code, message, 64);
+ printf("Decoded: %s (must be the same as above)\n", message);
+
+ return 0;
+}
+