RTIS Serial

RTIS Serial

C++ library and Python wrapper for serial interface to an RTIS device

This repository hold a C++ library to connect to an RTIS device over its serial communication interface. Furthermore, a Python wrapper extension module is available to use this library within Python programs and scripts. This library allows you to connect to an RTIS device, execute commands and receive data packages.

Usage

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:

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()