Create formatted frame from basic types:
- uint8_t, int8_t => 1Byte
- uint16_t, int16_t => 2Bytes
- uint32_t, int32_t => 4Bytes
- float => 4Bytes
Data are stared in Little Endian format.
Structure of data frame:
- starting byte (0xCC)
- length of frame: count of bytes in payload. The first 2 bytes is not included to overal length. Maximum length: 254 (0xFE)
- payload
- CRC8
The library contans universal function:
Detailed description of class: DataFrame
void main(){
uint8_t data[24];
packet.AddUint8(0xAB);
packet.AddUint16(65874);
packet.AddInt8(-45874);
packet.AddUint32(0x12345678);
packet.AddInt32(-0xA2345678);
packet.AddFloat(0.265);
packet.AddFloat(-3.1415);
CRC)
int data_length = packet.Commit();
if (packet.getError() ==
ERROR_NONE) {
uint8_t* frame = packet.GetFrame();
}
}