Go to the documentation of this file.
17 #error "Hosted::Serial can be used only on the Host architecture!"
20 #include <SerialLib.h>
36 transport.closeDevice();
41 return transport.DTR(on);
46 return transport.RTS(on);
52 bool begin(uint32_t baud = 9600)
54 char result = transport.openDevice(ttyDevice.
c_str(), baud);
65 if(transport.writeChar(c)) {
74 return transport.available();
80 int result = transport.readChar(
reinterpret_cast<char*
>(&ch), 1);
88 size_t readBytes(
char* buffer,
size_t length)
override
90 int result = transport.readBytes(buffer, length, 100, 100);
100 char result = transport.writeBytes(buffer, size);
113 void flush()
override
Base Stream class.
Definition: Wiring/Stream.h:32
bool begin(uint32_t baud=9600)
Initialise the serial port.
Definition: Components/Hosted/include/Hosted/Serial.h:74
void flush() override
Definition: Components/Hosted/include/Hosted/Serial.h:135
bool setDtr(bool on)
Definition: Components/Hosted/include/Hosted/Serial.h:61
The String class.
Definition: WString.h:136
size_t readBytes(char *buffer, size_t length) override
Read chars from stream into buffer.
Definition: Components/Hosted/include/Hosted/Serial.h:110
Definition: Components/Hosted/include/Hosted/Client.h:31
int available() override
Definition: Components/Hosted/include/Hosted/Serial.h:94
size_t write(uint8_t c) override
Writes a single character to output stream.
Definition: Components/Hosted/include/Hosted/Serial.h:85
#define host_debug_w(fmt,...)
Definition: hostmsg.h:50
HardwareSerial Serial
Global instance of serial port UART0.
const char * c_str() const
Get a constant (un-modifiable) pointer to String content.
Definition: WString.h:616
int peek() override
Definition: Components/Hosted/include/Hosted/Serial.h:130
Serial(const String &ttyDevice)
Definition: Components/Hosted/include/Hosted/Serial.h:52
int read() override
Definition: Components/Hosted/include/Hosted/Serial.h:99
~Serial()
Definition: Components/Hosted/include/Hosted/Serial.h:56
bool setRts(bool on)
Definition: Components/Hosted/include/Hosted/Serial.h:66