MCPcopy Create free account
hub / github.com/PowerBroker2/SerialTransfer / stuffPacket

Method stuffPacket

src/Packet.cpp:375–390  ·  view source on GitHub ↗

void Packet::stuffPacket(uint8_t arr[], const uint8_t &len) Description: ------------ * Enforces the COBS (Consistent Overhead Stuffing) ruleset across all bytes in the packet against the value of START_BYTE Inputs: ------- * uint8_t arr[] - Array of values to stuff * const uint8_t &len - Number of elements in arr[] Return: ------- * void */

Source from the content-addressed store, hash-verified

373 * void
374*/
375void Packet::stuffPacket(uint8_t arr[], const uint8_t& len)
376{
377 int16_t refByte = findLast(arr, len);
378
379 if (refByte != -1)
380 {
381 for (uint8_t i = (len - 1); i != 0xFF; i--)
382 {
383 if (arr[i] == START_BYTE)
384 {
385 arr[i] = refByte - i;
386 refByte = i;
387 }
388 }
389 }
390}
391
392
393/*

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected