Repository navigation
Improved registration and corruption detection
Improvements Made:
- 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
- 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
- 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)
- 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)