client module
Classes for communicating with a GPIO server via a Unix socket.
For more specific, well-known client APIs, see:
Classes
- class gpiosvr.client.Response(result=None)
Response from a GPIO server, with methods for encoding and decoding.
Mimics asyncio.Future. Other than asyncio.Future, a server response can hold more than one exception, if several errors occurred om the server side.
- static encodeException(exception)
Encodes a single exception for sending it over the Unix socket.
- Returns:
The encoded string representation of the exception.
- Return type:
str
- static decodeExceptions(errorMessages)
Decodes the error messages part of a response.
- Returns:
The corresponding Exception instances.
- Return type:
list[Exception]
- static decode(response: str)
Decodes an encoded representation of a response.
- encode()
Encodes this response for sending it over the Unix socket.
Considers the set result and all appended exceptions.
- Returns:
The encoded string representation of the response.
- Return type:
str
- append_exception(exception)
Appends an exception to this response.
It is up to the clients to evaluate all or only specific exceptions if there are more than one.
- result()
- Returns:
The result/payload of the response.
- Return type:
object
- set_result(result)
Sets the result of the response.
Automatically converts the data type to int, if
resultis a string containing only digits.
- set_exception(exception)
By contrast to
append_exception(), sets only one exception, discarding all exceptions appended before.
- exception()
- Returns:
The last exception appended to this response.
- Return type:
Exception
- exceptions()
- Returns:
All exceptions appended to this response.
- Return type:
list[Exception]
- done()
- Returns:
True if a result and/or exception has already been set on this response.
- Return type:
bool
- class gpiosvr.client.SocketClient(loop, socketPath, name=None, connectTimeout_ms=10000, responseBufferSize=256, responseTimeout_ms=1000, isKeepAlive=False)
Base class for establishing and operating a connection with a GPIO server via a Unix socket.
- stop()
A non-async variant of
close()for compatibility withPigpioMinimalApi.
Constants and defaults
- class gpiosvr.client.GpioDirection(value)
Constants representing the input/output direction of a GPIO.
- class gpiosvr.client.GpioLevel(value)
Constants representing the level of a GPIO.
- class gpiosvr.client.GpioPull(value)
Constants corresponding to the internal pull resistors of a GPIO.
- class gpiosvr.client.RequestDelimiters
Constant string values for delimiting certain parts of a request to a GPIO server.