Skip to content

Improved registration and corruption detection

Choose a tag to compare

@juano2310 juano2310 released this 15 Dec 21:35
· 10 commits to main since this release
99af8dc

Improvements Made:

  1. CRC8 Checksum Validation
  • Added calculateCRC8() function using CRC8-CCITT polynomial
  • Clients append checksum to serial number when requesting registration
  • Broker validates checksum before processing - silently rejects corrupted messages
  • Prevents corrupted data from being stored
  1. Message Length Validation
  • Added isValidMessageLength() helper to validate message size
  • Rejects messages that are too short or too long (outside expected range)
  • Prevents buffer overflow and malformed data processing
  1. Enhanced Registration Flow
  • Broker side: Reads message into buffer, validates checksum, then validates serial format via callback
  • Client side: Calculates checksum before sending registration request
  • Messages that fail checksum validation are silently discarded (no invalid ID assigned)
  1. Backward Compatibility
  • Checksum feature controlled by CAN_PS_USE_CHECKSUM flag
  • Can be disabled if needed for compatibility with older clients
  • When disabled, falls back to serial validation only

Key Benefits:

  • Detects corruption immediately - No invalid data reaches storage
  • Silent rejection - Corrupted messages don't trigger responses, reducing bus congestion
  • Low overhead - CRC8 is fast and only adds 1 byte per message
  • Combined with existing protections: Validation callback + startup cleanup + deterministic delays + exponential backoff

The library now has comprehensive collision prevention:

✓ Deterministic delays (spacing between clients)
✓ Checksum validation (detect corruption)
✓ Serial format validation (application-specific via callback)
✓ Length validation (reject malformed messages)
✓ Smallest ID assignment (optimize ID usage)