MySensors Library & Examples  2.3.2
SerialPort.h
1 /*
2  * The MySensors Arduino library handles the wireless radio link and protocol
3  * between your home built sensors/actuators and HA controller of choice.
4  * The sensors forms a self healing radio network with optional repeaters. Each
5  * repeater and gateway builds a routing tables in EEPROM which keeps track of the
6  * network topology allowing messages to be routed to nodes.
7  *
8  * Created by Henrik Ekblad <[email protected]>
9  * Copyright (C) 2013-2019 Sensnology AB
10  * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
11  *
12  * Documentation: http://www.mysensors.org
13  * Support Forum: http://forum.mysensors.org
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * version 2 as published by the Free Software Foundation.
18  */
19 
20 #ifndef SerialPort_h
21 #define SerialPort_h
22 
23 #include <string>
24 #include <stdbool.h>
25 #include "Stream.h"
26 
31 class SerialPort : public Stream
32 {
33 
34 private:
35  int sd;
36  std::string serialPort;
37  bool isPty;
38 
39 public:
43  SerialPort(const char *port, bool isPty = false);
51  void begin(int bauds);
58  bool open(int bauds = 115200);
64  bool setGroupPerm(const char *groupName);
73  int available();
79  int read();
86  size_t write(uint8_t b);
94  size_t write(const uint8_t *buffer, size_t size);
103  int peek();
107  void flush();
111  void end();
112 };
113 
114 #endif
SerialPort::read
int read()
Reads 1 byte of incoming serial data.
SerialPort::available
int available()
Get the number of bytes available.
SerialPort::open
bool open(int bauds=115200)
Open the serial port and set the data rate in bits per second (baud).
SerialPort::write
size_t write(uint8_t b)
Writes a single byte to the serial port.
SerialPort::setGroupPerm
bool setGroupPerm(const char *groupName)
Grant access to the specified system group for the serial device.
SerialPort::peek
int peek()
Returns the next byte (character) of incoming serial data without removing it from the internal seria...
SerialPort::end
void end()
Disables serial communication.
SerialPort
Definition: SerialPort.h:31
SerialPort::flush
void flush()
Remove any data remaining on the serial buffer.
SerialPort::begin
void begin(int bauds)
Open the serial port and set the data rate in bits per second (baud).
SerialPort::SerialPort
SerialPort(const char *port, bool isPty=false)
SerialPort constructor.