bpod_core.serial.ChunkedSerialReader

class bpod_core.serial.ChunkedSerialReader

A protocol for reading chunked data from a serial port.

This class provides methods to buffer incoming data and retrieve it in chunks.

__init__()

Initialize the protocol with an empty buffer.

data_received(data)

Called with snippets received from the serial port.

Parameters:

data (-)

get(size)

Retrieve a specified amount of data from the buffer.

Parameters:

size (int) – The number of bytes to retrieve from the buffer.

Returns:

The retrieved data.

Return type:

bytearray

put(data)

Add data to the buffer.

Parameters:

data (bytes) – The binary data to be added to the buffer.