This class provides methods for Spiedo-Arduino communication. Can be compiled as library and used in a ROOT interactive session, or just linked in the main program. Does not require dictionaries of any sort.
[ back to index ]
SerialPort();
Constructor
virtual ~SerialPort();
Destructor
int Open(const char* device);
Opens the port. Returns -1 if opening fails.
void Close();
Closes the port.
void RequestData(uint8_t channel);
Sends an '1x' message to Arduino, where 'x' is the channel. '1x' tells Arduino to read channel 'x' and print the value as an alphanumeric line.
int Readline();
Waits to read up a single line from Arduino, and converts it to integer.
SerialPort USBport; USBport.Open("/dev/ttyUSB0"); USBport.RequestData(2); int value = USBport.Readline(); printf("Value: %d\n", value); USBport.Close();