upm  0.2.0
Sensor/Actuator repository for libmraa (v0.6.1)
Public Member Functions | Protected Member Functions
HM11 Class Reference

Public Member Functions

 HM11 (int uart)
 
 ~HM11 ()
 
bool dataAvailable (unsigned int millis)
 
int readData (char *buffer, size_t len)
 
int writeData (char *buffer, size_t len)
 
bool setupTty (speed_t baud=B9600)
 

Protected Member Functions

int ttyFd ()
 
int setTtyFd (int fd)
 

Constructor & Destructor Documentation

HM11 ( int  uart)

HM11 module constructor

Parameters
uartdefault uart to use (0 or 1)
~HM11 ( )

HM11 module Destructor

Member Function Documentation

bool dataAvailable ( unsigned int  millis)

check to see if there is data available for reading

Parameters
millisnumber of milliseconds to wait, 0 means no wait.
Returns
true if there is data available to be read
int readData ( char *  buffer,
size_t  len 
)

read any available data into a user-supplied buffer. Note, the call will block until data is available to be read. Use dataAvailable() to determine whether there is data available beforehand, to avoid blocking.

Parameters
bufferthe buffer to hold the data read
lenthe length of the buffer
Returns
the number of bytes read
int writeData ( char *  buffer,
size_t  len 
)

write the data in buffer to the device

Parameters
bufferthe buffer to hold the data read
lenthe length of the buffer
Returns
the number of bytes written
bool setupTty ( speed_t  baud = B9600)

setup the proper tty i/o modes and the baudrate. The default baud rate is 9600 (B9600) for this device.

Parameters
baudthe desired baud rate.
Returns
true if successful

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