#include <Serial.h>
Inherits cinder::Noncopyable.
cinder::Serial::~Serial |
( |
| ) |
|
cinder::Serial::Serial |
( |
const Serial::Device & |
device, |
|
|
int |
baudRate |
|
) |
| |
|
protected |
const std::vector< Serial::Device > & cinder::Serial::getDevices |
( |
bool |
forceRefresh = false | ) |
|
|
static |
Returns a vector of all serial devices available on the machine. Uses a cached list unless forceRefresh.
Serial::Device cinder::Serial::findDeviceByName |
( |
const std::string & |
name, |
|
|
bool |
forceRefresh = false |
|
) |
| |
|
static |
Returns the first Serial::Device whose name is name. Returns a null Serial::Device if none are found. Uses a cached list of the serial devices unless forceRefresh.
Serial::Device cinder::Serial::findDeviceByNameContains |
( |
const std::string & |
searchString, |
|
|
bool |
forceRefresh = false |
|
) |
| |
|
static |
Returns the first Serial::Device whose name contains the string searchString. Returns a null Serial::Device if none are found. Uses a cached list of the serial devices unless forceRefresh.
Creates and returns a shared Serial object.
void cinder::Serial::readBytes |
( |
void * |
data, |
|
|
size_t |
numBytes |
|
) |
| |
Reads numBytes bytes of data from the serial port to data.
size_t cinder::Serial::readAvailableBytes |
( |
void * |
data, |
|
|
size_t |
maximumBytes |
|
) |
| |
Reads up to maximumBytes bytes of data from the serial port to data. Returns the number of bytes read.
void cinder::Serial::writeBytes |
( |
const void * |
data, |
|
|
size_t |
numBytes |
|
) |
| |
Writes numBytes bytes of data to the serial port from data.
void cinder::Serial::writeByte |
( |
uint8_t |
data | ) |
|
Writes a single byte data to the serial port.
uint8_t cinder::Serial::readByte |
( |
| ) |
|
Returns a single byte read from the serial port.
char cinder::Serial::readChar |
( |
| ) |
|
Returns a single character read from the serial port.
std::string cinder::Serial::readStringUntil |
( |
char |
token, |
|
|
size_t |
maxLength = 0 , |
|
|
double |
timeoutSeconds = -1.0 |
|
) |
| |
Returns a string composed of bytes read until a character token is found, or up to maxLength bytes have been read and maxLength > 0. Throws a SerialTimeoutExc() if timeoutSeconds > 0 and timeoutSeconds seconds pass before token is found.
void cinder::Serial::writeString |
( |
const std::string & |
str | ) |
|
Writes a string str to the serial port, excluding the null terminator.
void cinder::Serial::flush |
( |
bool |
input = true , |
|
|
bool |
output = true |
|
) |
| |
Forces the device to flush any buffered input and/or output bytes.
size_t cinder::Serial::getNumBytesAvailable |
( |
| ) |
const |
Returns the number of bytes available for reading from the device.
The documentation for this class was generated from the following files: