panoptes.pocs.tests.serial_handlers package

Submodules

panoptes.pocs.tests.serial_handlers.protocol_buffers module

panoptes.pocs.tests.serial_handlers.protocol_hooked module

panoptes.pocs.tests.serial_handlers.protocol_no_op module

Module contents

The protocol_*.py files in this package are based on PySerial’s file test/handlers/protocol_test.py, modified for different behaviors. The call serial.serial_for_url(“XYZ://”) looks for a class Serial in a file named protocol_XYZ.py in this package (i.e. directory).

class panoptes.pocs.tests.serial_handlers.NoOpSerial(*args, **kwargs)[source]

Bases: serial.serialutil.SerialBase

No-op implementation of PySerial’s SerialBase.

Provides no-op implementation of various methods that SerialBase expects to have implemented by the sub-class. Can be used as is for a /dev/null type of behavior.

close()[source]

Close port immediately.

in_waiting

The number of input bytes available to read immediately.

open()[source]

Open port.

Raises:SerialException if the port cannot be opened.
read(size=1)[source]

Read size bytes.

If a timeout is set it may return fewer characters than requested. With no timeout it will block until the requested number of bytes is read.

Parameters:size – Number of bytes to read.
Returns:Bytes read from the port, of type ‘bytes’.
Raises:SerialTimeoutException – In case a write timeout is configured for the port and the time is exceeded.
reset_input_buffer()[source]

Remove any accumulated bytes from the device.

reset_output_buffer()[source]

Remove any accumulated bytes not yet sent to the device.

write(data)[source]
Parameters:data – The data to write.
Returns:Number of bytes written.
Raises:SerialTimeoutException – In case a write timeout is configured for the port and the time is exceeded.