Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cinder::Serial Class Reference

#include <Serial.h>

Classes

class  Device
 
struct  Obj
 

Public Member Functions

 Serial ()
 
 Serial (const Serial::Device &device, int baudRate)
 
const DevicegetDevice () const
 Returns the Device associated with this Serial port. More...
 
void readBytes (void *data, size_t numBytes)
 Reads numBytes bytes of data from the serial port to data. More...
 
size_t 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. More...
 
void writeBytes (const void *data, size_t numBytes)
 Writes numBytes bytes of data to the serial port from data. More...
 
void writeByte (uint8_t data)
 Writes a single byte data to the serial port. More...
 
uint8_t readByte ()
 Returns a single byte read from the serial port. More...
 
char readChar ()
 Returns a single character read from the serial port. More...
 
std::string 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. More...
 
void writeString (const std::string &str)
 Writes a string str to the serial port, excluding the null terminator. More...
 
void flush (bool input=true, bool output=true)
 Forces the device to flush any buffered input and/or output bytes. More...
 
size_t getNumBytesAvailable () const
 Returns the number of bytes available for reading from the device. More...
 

Static Public Member Functions

static const std::vector
< Serial::Device > & 
getDevices (bool forceRefresh=false)
 Returns a vector of all serial devices available on the machine. Uses a cached list unless forceRefresh. More...
 
static Serial::Device findDeviceByName (const std::string &name, bool forceRefresh=false)
 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. More...
 
static Serial::Device findDeviceByNameContains (const std::string &searchString, bool forceRefresh=false)
 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. More...
 

Protected Attributes

std::shared_ptr< ObjmObj
 

Constructor & Destructor Documentation

cinder::Serial::Serial ( )
cinder::Serial::Serial ( const Serial::Device device,
int  baudRate 
)

Member Function Documentation

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.

const Serial::Device & cinder::Serial::getDevice ( ) const

Returns the Device associated with this Serial port.

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.

Member Data Documentation

std::shared_ptr<Obj> cinder::Serial::mObj
protected

The documentation for this class was generated from the following files: