bpod_core.com.to_bytes

bpod_core.com.to_bytes(data) bytes

Convert data to a bytes object.

This function extends serial.to_bytes() with support for: - NumPy arrays and scalars - Unsigned 8-bit integers - Strings (encoded as UTF-8) - Arbitrary iterables of ByteLike

Parameters:

data (ByteLike) – Data to be converted to a bytes object.

Returns:

Data converted to bytes.

Return type:

bytes

Raises:
  • TypeError – If the input type cannot be interpreted as bytes

  • ValueError – If an integer is out of the 0..255 range when coerced to a single byte.