Fără Descriere

Juraj Ďuďák 7c784a9745 fix length 2 ani în urmă
src 7c784a9745 fix length 2 ani în urmă
readme.md 7c784a9745 fix length 2 ani în urmă

readme.md

Simple wrapper for DataFrame

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

Basic usage


    void main(){
    uint8_t data[128];

    packet_create(data, 128);

    packet_add_uint8(0xAB);
    packet_add_uint16(65874);
    packet_add_int16(-45874);
    packet_add_uint32(0x12345678);
    packet_add_int32(-0xA2345678);
    
    packet_add_float(0.265);
    packet_add_float(-3.1415);

    int data_length = packet_commit();
    }

CRC8 Computation

  • Generator polynome: 0x97 -> 0x197 = x^8 + x^7 + x^4 + x^2 + x^1 +1
  • CRC is implemented as fast computation with prepared CrcTable. Algorithm complexity is O(n)