Skip to content

MiP_Serial

github-actions[bot] edited this page Aug 11, 2026 · 9 revisions

Class MiP_Serial

Manages low-level UART transport and Out-Of-Band (OOB) event demultiplexing.

Detailed Description

Handles serial transmission delays, command-response pairing, hex-ASCII parsing, and dispatching asynchronous event notifications received from MiP.

Table of Contents


Public Functions

rawSend

Signature: void rawSend(const uint8_t request[], size_t requestLength)

Summary: Sends a raw command buffer to MiP without waiting for a response (fire-and-forget).

Details:

Used internally by non-verified commands and higher-level driver methods. Enforces the minimum MIP_REQUEST_DELAY before writing data to the hardware serial port.

Parameters:

Parameter Description
request Pointer to the array of command bytes to transmit.
requestLength Number of bytes in the request array.

rawReceive

Signature: uint8_t rawReceive(const uint8_t request[], size_t requestLength, uint8_t responseBuffer[], size_t responseBufferSize, size_t &responseLength)

Summary: Sends a raw command and blocks until the expected response is received or times out.

Details:

Transmits the request buffer over UART, waits for the corresponding command response byte, converts incoming hex-ASCII payload characters to binary, and populates the response buffer.

Parameters:

Parameter Description
request Pointer to the array of command bytes to transmit.
requestLength Number of bytes in the request array.
responseBuffer Pointer to the buffer where the received response will be stored.
responseBufferSize Maximum capacity of the response buffer in bytes.
responseLength Receives the actual number of bytes written into responseBuffer.

Returns: uint8_t MIP_ERROR_NONE on success, or MIP_ERROR_TIMEOUT on response timeout.


processAllResponseData

Signature: bool processAllResponseData()

Summary: Reads and processes all incoming data available in the hardware serial receive buffer.

Details:

Decodes incoming hex-ASCII command pairs. If the command byte matches an expected synchronous response, it populates the response buffer. Otherwise, it treats the data as an Out-Of-Band (OOB) notification and dispatches it to MiP::dispatchEvent().

Returns: true if the expected synchronous response was found during buffer processing, false otherwise.


Public Variables

MIP_MAX_RETRIES

Signature: constexpr uint8_t MIP_MAX_RETRIES

Summary: Maximum number of retry attempts for verified read and write operations.


MIP_RETRY_WAIT

Signature: constexpr uint16_t MIP_RETRY_WAIT

Summary: Duration in milliseconds to wait between retry attempts.


Clone this wiki locally