rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
pdmini_codec.c File Reference

The PD mini's codec: the CRC8 (cyclic redundancy check, 8 bits) of a frame and the framing of a reply. More...

#include "pdmini.h"

Functions

uint8_t pdmini_crc8 (const uint8_t *p, size_t n)
 CRC8, polynomial 0x31, initial 0xFF, over n bytes.
static size_t fixed_len (uint8_t cmd)
 A fixed-length reply's whole length, or 0 for one that is not.
pdmini_frame_t pdmini_reply_frame (uint8_t cmd, const uint8_t *buf, size_t n)
 Checks the bytes received so far against a reply to cmd.

Detailed Description

The PD mini's codec: the CRC8 (cyclic redundancy check, 8 bits) of a frame and the framing of a reply.

See pdmini.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ fixed_len()

size_t fixed_len ( uint8_t cmd)
static

A fixed-length reply's whole length, or 0 for one that is not.

Parameters
cmdCommand byte the reply answers.
Returns
The reply length in bytes, or 0 for a command whose reply is not fixed in length.

◆ pdmini_crc8()

uint8_t pdmini_crc8 ( const uint8_t * p,
size_t n )

CRC8, polynomial 0x31, initial 0xFF, over n bytes.

Parameters
pBytes to check.
nNumber of bytes in p.
Returns
The CRC8 of the bytes.

◆ pdmini_reply_frame()

pdmini_frame_t pdmini_reply_frame ( uint8_t cmd,
const uint8_t * buf,
size_t n )

Checks the bytes received so far against a reply to cmd.

Parameters
cmdCommand byte the reply answers.
bufBytes received so far.
nNumber of bytes in buf.
Returns
PDMINI_MORE, PDMINI_DONE or PDMINI_BAD.