PDA

View Full Version : How to concatenate boost crc16 checksum ?



Pechkin
3rd July 2014, 14:14
Good Day.
I transfer a packet by chunks and use boost library for computing crc (16 bits) of packet.
I obtain other checksums for whole byte's array and concatenation by chunks.
For example:
step1 (transfer of first chunk)


boost::crc_16_type crcobject;
...
memcpy(ba_tosocket->data()+offset,(char *)&bin_tosocket[0],headersize);
crcobject.reset(0);
crcobject.process_bytes(ba_tosocket->data(),headersize);
bin_tosocket[3] = crcobject.checksum();

step2 (transfer of second chunk)


memcpy(ba_tosocket->data()+offset,batmp.data(),dataframesize);
crcobject.reset(bin_tosocket[3]);
crcobject.process_bytes(ba_tosocket->data(),dataframesize);
bin_tosocket[3] = crcobject.checksum();

First and second chunks were aligned on word's margin (16 bits).
Is it right approach for concatenation of CRCs ?

Pechkin
3rd July 2014, 18:54
Thank's for attention.
The problem is solved.