Any C++ CRC would be fine, but keep it small. I googled it and found
http://excamera.com/sphinx/article-crc.html
I took that code and added another function to do a CRC on data instead of a string (I think I got the code right... Please check it yourself);
#include <avr/pgmspace.h>
struct SEND_DATA_STRUCTURE{
// ????????? ??????
byte com_stat ;
byte id_data;
double Shirota;
double Dolgota;
int kurs_tek;
int kurs_raschet;
int napr_vetra;
int skor_vetra;
byte parus;
byte rul;
byte chasy;
byte minuty;
byte RC1;
byte RC2;
byte RC3;
};
struct DATA_AND_CRC
{
struct SEND_DATA_STRUCTURE send_data;
unsigned long crc;
} my_data;
static PROGMEM prog_uint32_t crc_table[16] = {
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
};
unsigned long crc_update(unsigned long crc, byte data)
{
byte tbl_idx;
tbl_idx = crc ^ (data >> (0 * 4));
crc = pgm_read_dword_near(crc_table + (tbl_idx & 0x0f)) ^ (crc >> 4);
tbl_idx = crc ^ (data >> (1 * 4));
crc = pgm_read_dword_near(crc_table + (tbl_idx & 0x0f)) ^ (crc >> 4);
return crc;
}
unsigned long crc_string(char *s)
{
unsigned long crc = ~0L;
while (*s)
crc = crc_update(crc, *s++);
crc = ~crc;
return crc;
}
unsigned long crc_data(byte *data,int len)
{
unsigned long crc = ~0L;
while(len-->0)
{
crc = crc_update(crc, *data++);
}
crc = ~crc;
return crc;
}
void fake_send(byte *data,int len)
{
while(len-->0)
{
Serial.print(*data++,HEX);
}
}
void setup()
{
unsigned long crc;
Serial.begin(115200);
Serial.println(crc_string("HELLO"), HEX);// Example of existing function
Serial.println(crc_data((byte *)"HELLO",5), HEX);// test my function returns the same result for 5 char string ;-)
Serial.println(sizeof(my_data.send_data), DEC);// get size of struct
my_data.send_data.com_stat=1 ;
my_data.send_data.id_data=2;
my_data.send_data.Shirota=123.456789;
my_data.send_data.Dolgota=321.987654;
my_data.send_data.kurs_tek=3;
my_data.send_data.kurs_raschet=4;
my_data.send_data.napr_vetra=5;
my_data.send_data.skor_vetra=6;
my_data.send_data.parus=7;
my_data.send_data.rul=8;
my_data.send_data.chasy=9;
my_data.send_data.minuty=10;
my_data.send_data.RC1=11;
my_data.send_data.RC2=12;
my_data.send_data.RC3=13;
my_data.crc=crc_data((byte *)&my_data.send_data,sizeof(my_data.send_data));
Serial.println(sizeof(my_data), DEC);// get size of struct
fake_send((byte *)&my_data,sizeof(my_data));
}
void loop()
{
}
Edit. Compression is probably not worth it, as the data length is only 29 bytes
You may find compressing it makes it bigger not smaller
Edit.
BTW to decode it, rather than doing it manually, just feed the data to another Arduino and get it to print the contents of the same struct.