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.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
29
src/test/test_hagelbarger.c
Normal file
29
src/test/test_hagelbarger.c
Normal file
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user