ASL
|
SerialPort represents a serial port to communicate with.
#include <SerialPort.h>
Public Member Functions | |
bool | open (const String &port) |
Opens the port by name (Windows: "COM..." , Linux: "/dev/..." ) | |
void | setNewline (const String &nl) |
Sets the newline to expect by readLine(), normally one of "\n", "\r" or "\r\n". | |
void | close () |
Closes the port. | |
bool | error () |
Returns true if there were communication errors (possibly the device was disconnected) | |
void | setTimeout (double s) |
Sets the read timeout in seconds. | |
bool | config (int bps, const String &mode="8N1") |
Configures the port with a bitrate and a string encoded as "BPS": B=data bits, P=parity (N/E/O), S=stop bits, plus an optional X for Xon/Xoff flow control. | |
bool | waitInput (double timeout=10) |
Waits until there is data to read for a maximum time of timeout seconds (or the device disconnected), and return true if something happened before the timeout. | |
int | available () |
Returns the number of bytes available for reading. | |
int | write (const void *p, int n) |
Writes n bytes of buffer p to the port. | |
int | read (void *p, int n) |
Reads n bytes from the port into buffer p. | |
int | write (const String &s) |
Writes the given string to the port. | |
String | readLine () |
Reads a text line from the port (up to a \r or \n character) and returns it not including the newline. | |