Raised if an error occurs while communicating with a node
Class for communicating with nodes via Eth2CAN
Parameters: |
|
---|
Close the TCP/IP communication socket
Connect to the Eth2CAN device over TCP/IP
Retreive multiple responses from the OpenLCB bus
Send an OpenLCB message over TCP/IP
Base class for OpenLCB communication mechanisms
Subclasses should define the following methods for communicating with an OpenLCB bus over a given transport:
Instances are also context managers. This facilitates opening and closing of connections using the with statement:
conn = EthernetConnection(hostname)
with conn:
conn.send(message)
The above example will automatically open and close the connection upon entering and leaving the context.
Close the connection to the OpenLCB bus
Connect to the OpenLCB bus
Retreive a response from the OpenLCB bus
Returns str: | A string containing the CAN frame received from the bus, suitable for creating a new instance of a CANMessage subclass |
---|
Deprecated since version 0.1: This method is ambiguous; use receive_one() instead.
Retreive multiple responses from the OpenLCB bus
Returns list: | A list of strings containing CAN frames, suitable for creating new instances of a subclass of CANMessage. If no response was returned within the timeout period, an empty list (i.e. []) is returned. |
---|
Retreive a single response message from the node
Returns str: | A string containing the first message received, suitable for creating a new instance of a CANMessage subclass. If no response was received within the timeout period, None is returned. |
---|
Note
Calling this method will actually empty the buffer, meaning that if more than one message was received, any subsequent messages will be discarded. If multiple response messages are expected, use receive_multi() instead.
Send a message to the OpenLCB bus
Parameters: | message (str) – The CAN frame to send |
---|
Any object that can be converted to a string can be passed as the message parameter, such as openlcb.can.CANMessage subclasses.
Class for communicating with nodes via Serial Connection
Parameters: |
|
---|
Close the serial port and terminate the OpenLCB connection
Open the serial port and set RTS
Retreive multiple responses from the OpenLCB bus
Send an OpenLCB message through the serial port