Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Public Member Functions | List of all members
Serial Class Reference

Public Member Functions

int setup (const char *device, unsigned int speed)
 
int read (char *buf, size_t len, int timeoutMs=-1)
 
int write (const char *buf, size_t len=-1)
 
void cleanup ()
 

Detailed Description

Examples:
Communication/Serial/render.cpp.

Member Function Documentation

int Serial::setup ( const char *  device,
unsigned int  speed 
)

Initialize the device

Parameters
devicepath to the device file (e.g.: /dev/ttyS4 for UART4)
speedthe speed of the communication, for instance 9600 or 115200. Only values in /usr/include/arm-linux-gnueabihf/ are valid.
Returns
0 on success, an error code otherwise.
Examples:
Communication/Serial/render.cpp.
int Serial::read ( char *  buf,
size_t  len,
int  timeoutMs = -1 
)

Read bytes from the serial port with specified timeout.

Parameters
bufthe destination for the data being read.
lenthe maximum amount of bytes to be read.
timeoutMsthe timeout (in ms) after which the function call will return. A negative value means infinite timeout (default).
Returns
The number of bytes read, or 0 if the timeout has expired, or a negative error code if an error occurred.
Examples:
Communication/Serial/render.cpp.
int Serial::write ( const char *  buf,
size_t  len = -1 
)

Write bytes to the serial port.

Parameters
bufa buffer containing the data to be written.
lenthe number of bytes to write. If omitted, buf will be the length of the string pointed at by buf.
Returns
the number of bytes written, or a negative error cade if an error occurred.
Examples:
Communication/Serial/render.cpp.
void Serial::cleanup ( )

Close the device.


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