psychos.triggers.DummyPort#

class psychos.triggers.DummyPort(log: bool = True)[source]#

Bases: BasePort

Dummy port implementation for testing and debugging.

This class simulates a port without requiring actual hardware. It logs all values that are sent, reset actions, and close operations.

Examples

>>> dummy = DummyPort(address='dummy')
>>> dummy.send(128)        # Logs the sending of integer 128.
>>> dummy.send(b'€')    # Logs the sending of the byte b'€'.
>>> dummy.reset()          # Logs the reset action.
>>> dummy.close()          # Logs the close action.
__init__(log: bool = True)[source]#

Initialize the DummyPort instance.

Parameters:
  • address (str) – A dummy address identifier.

  • **kwargs – Additional keyword arguments (ignored).

Methods

__init__([log])

Initialize the DummyPort instance.

close()

Log the action of closing the port.

encode(value)

Encode a value to send through the port.

reset()

Log the action of resetting the port.

send(value)

Log the value that would be sent over the port.

close()[source]#

Log the action of closing the port.

This method simulates closing the port connection.

reset()[source]#

Log the action of resetting the port.

This method simulates resetting the port to a known, idle state.

send(value: int | bytes)[source]#

Log the value that would be sent over the port.

If an integer is provided, it must be between 0 and 255. If a bytes object is provided, it must be exactly one byte long. For multi-byte values, send the data in separate calls.

Parameters:

value (Union[int, bytes]) – The value to log. If an integer, it is logged directly. If bytes, it is converted to an integer for logging.