From 761777e1d7142ac8aa2c5fa7aa8c7b88a09a4416 Mon Sep 17 00:00:00 2001 From: Zilog80 Date: Tue, 4 Sep 2018 16:34:15 +0200 Subject: [PATCH] LMS6: Reed-Solomon RS(223,32)-CCSDS --- lms6/lms6.txt | 5 +++-- lms6/lms6ecc.c | 17 +++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lms6/lms6.txt b/lms6/lms6.txt index 18f6160..34360d8 100644 --- a/lms6/lms6.txt +++ b/lms6/lms6.txt @@ -12,11 +12,12 @@ NRZ-S, convolutional code R=1/2 bits: little endian bytes: big endian +Reed-Solomon RS(223,32)-CCSDS +(msg[223],par[32]): 223+32 byte vor 5-byte-Block [00 58 f3 3f b8] (ring-buffer!) + CRC16: poly 0x1021 crc-frame: 24 54 00 00 00 .. (len=221) -Block32: 32+5 byte, enden: 00 58 f3 3f b8 - sync/header: .. pp pp pp 24 54 00 00 00 (7A .. ..) diff --git a/lms6/lms6ecc.c b/lms6/lms6ecc.c index bdd1fe3..2796d72 100644 --- a/lms6/lms6ecc.c +++ b/lms6/lms6ecc.c @@ -207,9 +207,9 @@ int read_rawbit(FILE *fp, int *bit) { // (pp pp 24) 54 00 00 00 (7A..: SondeID, GPS, ...) char header[] = /*"0000110110011000"*/"0011101100100000""0000000000000000""0000000000000000";//"0010010011110001"; -ui8_t block32[32]; -ui8_t block32end[] = { 0x00, 0x58, 0xf3, 0x3f, 0xb8}; -#define FEND 256 +ui8_t rs_ecc32[32]; // parity RS(223,32)-CCSDS +ui8_t rs_ecc32end[] = { 0x00, 0x58, 0xf3, 0x3f, 0xb8}; +#define FEND 255 #define FRAMESTART 0 @@ -766,22 +766,23 @@ void print_frame(int len) { for (i = 32; i < FEND-5; i++) { int bf = 0; - for (j = 0; j < 5; j++) bf += (frame_bytes[i+j] == block32end[j]); + for (j = 0; j < 5; j++) bf += (frame_bytes[i+j] == rs_ecc32end[j]); if (bf == 5) { - for (j = 0; j < 32; j++) block32[j] = frame_bytes[i-(32+5)+j]; + for (j = 0; j < 32; j++) rs_ecc32[j] = frame_bytes[i-32+j]; for (j = i; j < FEND-5; j++) frame_bytes[j-32] = frame_bytes[j+5]; - for (j = 0; j < 32; j++) frame_bytes[FEND-32-5+j] = block32[j]; - for (j = 0; j < 5; j++) frame_bytes[FEND-5+j] = block32end[j]; + for (j = 0; j < 32; j++) frame_bytes[FEND-5+j-32] = rs_ecc32[j]; + for (j = 0; j < 5; j++) frame_bytes[FEND-5+j] = rs_ecc32end[j]; break; } } crc_err = check_CRC(frame); + if (option_raw) { if ( err==0 || err>8*(pos_GPSTOW+8) ) { if (option_raw == 1) { - for (i = 0; i < len/(2*BITS); i++) printf("%02x ", frame_bytes[i]); printf("\n"); + for (i = 0; i < len/(2*BITS); i++) printf("%02x ", frame[i]); printf("\n"); } else { for (i = 0; i < len; i++) printf("%c", frame_rawbits[i]); printf("\n");