Hardware Controller Reference
kevinbotlib.hardware.controllers.keyvalue
kevinbotlib.hardware.controllers.keyvalue.RawKeyValueSerialController
A controller for managing key-value pairs over a raw serial interface
is_connected
property
Check if the serial connection is active
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
Connection status |
interface
property
Get the serial interface
Returns:
Name | Type | Description |
---|---|---|
RawSerialInterface |
RawSerialInterface
|
Serial interface |
__init__(interface, delimeter=b'=', terminator=b'\n')
Initialize the controller with a serial interface
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interface
|
RawSerialInterface
|
The serial interface to use |
required |
delimeter
|
bytes
|
Key-value delimeter |
b'='
|
terminator
|
bytes
|
EOL character |
b'\n'
|
write(key, value=None)
Send a key-value pair over the serial connection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
bytes
|
The key to set |
required |
value
|
bytes | None
|
The value to associate with the key. If no value is provided, will not send a delimeter. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
int | None
|
int | None: Number of bytes written |
read()
Read the next key-value pair from the serial connection
Returns:
Type | Description |
---|---|
tuple[bytes, bytes] | None
|
tuple[bytes, bytes] | None: (key, value) tuple if successful, None otherwise |