brian.sensors.BrianBrianComm
BrianBrianComm class objects
Class exposing the communication between two Brians connected via a sensor port.
Sensor (other Brian) is automatically registered in the constructor of the base class and un-registered in its destructor.
There can be at most one instance at any given time, of any sensor class per port in the entire program.
__init__
Initialize a new Brian-Brian communication handler at the given port.
The communication can be initialized in either of two modes - master and slave. One of the ends must be master, the other must be slave.
Arguments:
port
: Sensor port to which the sensor is attached.is_master
: true if this should be used in master mode, false for slave mode
available
read
reads data incoming from the other Brian.
Arguments:
size
: size limit, how many bytes to copy. If not provided, all available data will be read.
Raises:
OSError
: If an error occurs during the write operation. Error Codes:MP_EIO
: BrianBrianComm is not ready or is disconnected.
Returns:
read bytes
write
Sends the given buffer to the other Brian.
Arguments:
message
: str, bytearray or bytes buffer containing the actual message.
Raises:
OSError
: If an error occurs during the write operation. Error Codes:MP_EIO
: BrianBrianComm is not ready or is disconnected.
Returns:
number of bytes written