MySensors Library & Examples  2.3.2
Public Member Functions | List of all members
SerialPort Class Reference

Detailed Description

SerialPort Class Class that provides the functionality of arduino Serial library

Definition at line 31 of file SerialPort.h.

#include <SerialPort.h>

+ Inheritance diagram for SerialPort:
+ Collaboration diagram for SerialPort:

Public Member Functions

 SerialPort (const char *port, bool isPty=false)
 SerialPort constructor.
 
void begin (int bauds)
 Open the serial port and set the data rate in bits per second (baud). More...
 
bool open (int bauds=115200)
 Open the serial port and set the data rate in bits per second (baud). More...
 
bool setGroupPerm (const char *groupName)
 Grant access to the specified system group for the serial device. More...
 
int available ()
 Get the number of bytes available. More...
 
int read ()
 Reads 1 byte of incoming serial data. More...
 
size_t write (uint8_t b)
 Writes a single byte to the serial port. More...
 
size_t write (const uint8_t *buffer, size_t size)
 Writes binary data to the serial port. More...
 
int peek ()
 Returns the next byte (character) of incoming serial data without removing it from the internal serial buffer. More...
 
void flush ()
 Remove any data remaining on the serial buffer.
 
void end ()
 Disables serial communication.
 

Member Function Documentation

◆ available()

int SerialPort::available ( )

Get the number of bytes available.

Get the numberof bytes (characters) available for reading from the serial port.

Returns
number of bytes avalable to read.

◆ begin()

void SerialPort::begin ( int  bauds)

Open the serial port and set the data rate in bits per second (baud).

This function will terminate the program on an error.

Parameters
baudsbits per second.

◆ open()

bool SerialPort::open ( int  bauds = 115200)

Open the serial port and set the data rate in bits per second (baud).

Parameters
baudsbits per second.
Returns
true if no errors, else false.

◆ peek()

int SerialPort::peek ( )

Returns the next byte (character) of incoming serial data without removing it from the internal serial buffer.

Returns
-1 if no data else character in the buffer.

◆ read()

int SerialPort::read ( )

Reads 1 byte of incoming serial data.

Returns
first byte of incoming serial data available.

◆ setGroupPerm()

bool SerialPort::setGroupPerm ( const char *  groupName)

Grant access to the specified system group for the serial device.

Parameters
groupNamesystem group name.

◆ write() [1/2]

size_t SerialPort::write ( const uint8_t *  buffer,
size_t  size 
)

Writes binary data to the serial port.

Parameters
bufferto write.
sizeof the buffer.
Returns
number of bytes written.

◆ write() [2/2]

size_t SerialPort::write ( uint8_t  b)

Writes a single byte to the serial port.

Parameters
bbyte to write.
Returns
number of bytes written.

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