|
|
|
# RTIS Serial - Usage Documentation
|
|
|
|
|
|
|
|
The Python extension module has the following functions available:
|
|
|
|
|
|
|
|
- `connect(port, baudrate)`: To connect to the RTIS device over the serial communication interface. The serial connection stays open!
|
|
|
|
- `port` : _string_, The port ID to connect over.
|
|
|
|
- `baudrate` : _integer_, The baud-rate to use for the serial connection.
|
|
|
|
- `test(port)`: To connect to the RTIS device over the serial communication interface as a test. Will disconnect afterwards. The serial connection will not stay open!
|
|
|
|
- `port` : _string_, The port ID to connect over.
|
|
|
|
- returns _True_ on successful completion, _False_ on failure.
|
|
|
|
- `command(command, toggleResponse)`: To execute a command on the RTIS device and optionally get the returned response.
|
|
|
|
- `command` : _string_, The port ID to connect over.
|
|
|
|
- `toggleResponse` : _bool_, Disable or enable that the RTIS device response to the command should be retrieved.
|
|
|
|
- Optionally returns an _integer_ holding the response of the command.
|
|
|
|
- `getdata(amountOfBytes)`: Get a certain amount of bytes over the serial connection of the RTIS device.
|
|
|
|
- `amountOfBytes` : _integer_, The amount of bytes to retrieve over the serial communication interface.
|
|
|
|
- Returns a _Numpy ndarray_ with shape _(amountOfBytes,)_ and datatype _uint8_ containing the retrieved bytes.
|
|
|
|
- `getavailablebytes()`: Get the amount of available bytes in the read buffer of the serial connection to the RTIS device.
|
|
|
|
- Returns an _integer_ holding the amount of available bytes currently in the read buffer.
|
|
|
|
- `flush()`: Clean the input and output buffers completely of the serial connection to the RTIS device.
|
|
|
|
- `close()`: To close the connection to the RTIS device.
|
|
|
|
|
|
|
|
to use it in your Python program you simply have to import it and use one of the functions above. For example:
|
|
|
|
|
|
|
|
```python
|
|
|
|
import rtisserial
|
|
|
|
|
|
|
|
print(rtisserial.test("/dev/ttyACM0"))
|
|
|
|
rtisserial.connect("/dev/ttyACM1", 115200)
|
|
|
|
print(rtisserial.command("!G,67108864,0,0\n", True))
|
|
|
|
rtisserial.command("!A,0,0,0\n", False)
|
|
|
|
data = rtisserial.getdata(67108864 + 12)
|
|
|
|
rtisserial.close()
|
|
|
|
``` |
|
|
|
\ No newline at end of file |