Use Error-Correction Codes (ECC) with HammingStream
masterStreamUtils supports the Hamming(7, 4) error-correction code, which adds three parity bits to every 4 bits of data. This allows correcting any single-bit error within a 7-bit block.
Available Classes:
HammingEncodingStream<7, 4>: Decorates a stream to include parity bits in every write operation.HammingDecodingStream<7, 4>: Decorates a stream to decode parity bits in every read operation.HammingStream<7, 4>: Combines both encoding and decoding, ideal for two-way communication.
Optimization Tip:
When using HardwareSerial (like Serial1), you can reduce overhead by configuring the port as a 7-bit channel using SERIAL_7N1.
// For two-way communication with error correction
HammingStream<7, 4> eccSerial(Serial1);
eccSerial.println("Hello world!");
char buffer[256];
size_t n = eccSerial.readBytes(buffer, sizeof(buffer));