diff --git a/SP5WWP/m17-coder/Makefile b/SP5WWP/m17-coder/Makefile index ca184c9..1293125 100644 --- a/SP5WWP/m17-coder/Makefile +++ b/SP5WWP/m17-coder/Makefile @@ -1,5 +1,5 @@ -m17-coder-sym: m17-coder-sym.c golay.c - gcc -O2 -w -lm m17-coder-sym.c golay.c -o m17-coder-sym +m17-coder-sym: m17-coder-sym.c golay.c crc.c + gcc -O2 -w -lm m17-coder-sym.c golay.c crc.c -o m17-coder-sym clean: rm m17-coder-sym diff --git a/SP5WWP/m17-coder/crc.c b/SP5WWP/m17-coder/crc.c new file mode 100644 index 0000000..200cd87 --- /dev/null +++ b/SP5WWP/m17-coder/crc.c @@ -0,0 +1,23 @@ +#include +#include +#include "crc.h" + +const uint16_t M17_CRC_POLY = 0x5935; + +uint16_t CRC_M17(const uint8_t *in, const uint16_t len) +{ + uint32_t crc=0xFFFF; //init val + + for(uint16_t i=0; idst, 6); + memcpy(&d[6], in->src, 6); + memcpy(&d[12], in->type, 2); + memcpy(&d[14], in->meta, 14); + + return CRC_M17(d, 28); +} + //main routine int main(void) { @@ -278,6 +289,11 @@ int main(void) while(read(STDIN_FILENO, &(lsf.meta), 14)<14); while(read(STDIN_FILENO, data, 16)<16); + //calculate LSF CRC + uint16_t ccrc=LSF_CRC(&lsf); + lsf.crc[0]=ccrc>>8; + lsf.crc[1]=ccrc&0xFF; + got_lsf=1; //send out the preamble and LSF