kopia lustrzana https://github.com/M17-Project/M17_Implementations
Add files via upload
rodzic
ecedd527e7
commit
75b2e6ddaf
|
@ -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
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#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; i<len; i++)
|
||||
{
|
||||
crc^=in[i]<<8;
|
||||
for(uint8_t j=0; j<8; j++)
|
||||
{
|
||||
crc<<=1;
|
||||
if(crc&0x10000)
|
||||
crc=(crc^M17_CRC_POLY)&0xFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
return crc&(0xFFFF);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef CRC_H
|
||||
#define CRC_H
|
||||
|
||||
uint16_t CRC_M17(const uint8_t *in, const uint16_t len);
|
||||
|
||||
#endif
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "../inc/m17.h"
|
||||
#include "golay.h"
|
||||
#include "crc.h"
|
||||
|
||||
struct LSF
|
||||
{
|
||||
|
@ -92,8 +93,6 @@ void conv_Encode_Frame(uint8_t* out, uint8_t* in, uint16_t fn)
|
|||
//encode
|
||||
for(uint8_t i=0; i<144+4; i++)
|
||||
{
|
||||
//uint8_t G1=(ud[i+0] +ud[i+3]+ud[i+4])%2;
|
||||
//uint8_t G2=(ud[i+0]+ud[i+1]+ud[i+2] +ud[i+4])%2;
|
||||
uint8_t G1=(ud[i+4] +ud[i+1]+ud[i+0])%2;
|
||||
uint8_t G2=(ud[i+4]+ud[i+3]+ud[i+2] +ud[i+0])%2;
|
||||
|
||||
|
@ -117,6 +116,18 @@ void conv_Encode_Frame(uint8_t* out, uint8_t* in, uint16_t fn)
|
|||
//printf("pb=%d\n", pb);
|
||||
}
|
||||
|
||||
uint16_t LSF_CRC(struct LSF *in)
|
||||
{
|
||||
uint8_t d[28];
|
||||
|
||||
memcpy(&d[0], in->dst, 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
|
||||
|
|
Ładowanie…
Reference in New Issue