Geen omschrijving

Juraj Ďuďák dcf67fe870 add fast CRC8 computation 2 jaren geleden
src dcf67fe870 add fast CRC8 computation 2 jaren geleden
readme.md dcf67fe870 add fast CRC8 computation 2 jaren geleden

readme.md

Simple wrapper for DataFrame

Create formatted frame from basic types:

  • uint8_t, int8_t
  • uint16_t, int16_t
  • uint32_t, int32_t
  • float

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(0xABCD);
    packet_add_uint32(0x12345678);
    
    packet_add_float(0.265);

    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)