pyebus.connection module
EBUS Connection Handling.
- class pyebus.connection.Connection(host='127.0.0.1', port=8888, autoconnect=False, timeout=10)[source]
Bases:
object
EBUS Connection.
- Keyword Arguments:
- property host
Host.
- property port
Port.
- property autoconnect
Automatically connect and re-connect.
- property timeout
Connection Timeout.
- async async_connect()[source]
Establish connection (required before first communication).
- Raises:
ConnectionRefusedError – If connection cannot be established
- is_connected()[source]
Return True if connection is established.
This does not check if the connection is still usable.
- Returns:
bool
- async async_write(message)[source]
Send TCP message to EBUSD.
- Raises:
ConnectionRefusedError – If connection cannot be established
ConnectionError – If not connected (autoconnect==False)
- async async_request(cmd, *args, **kwargs)[source]
Assemble request starting with cmd and position args and keywords `kwargs’.
- Raises:
ConnectionRefusedError – If connection cannot be established
ConnectionError – If not connected (autoconnect==False)
- async async_read(infinite=False, check=True)[source]
Receive lines until an empty one (infinite==False) or infinitly (infinite==True).
- Yields:
str – line read
- Raises:
ConnectionRefusedError – If connection cannot be established
ConnectionError – If not connected (autoconnect==False)
CommandError – If command failed (check==True)
Shutdown – On EBUSD shutdown.
- async async_readresp(check=True)[source]
Receive command response.
Read one line as command response and one empty line.
- Returns:
response
- Return type:
- Raises:
ConnectionRefusedError – If connection cannot be established
ConnectionError – If not connected (autoconnect==False)
CommandError – If command failed (check==True) or trailing data.
Shutdown – On EBUSD shutdown.