PicoLC Arduino Library
Arduino library for PicoLC hardware
Loading...
Searching...
No Matches
PicoLCSerial Class Reference

Provides Arduino Stream-compatible access to the PicoLC RS-485 port. More...

#include <PicoLCSerial.h>

Inheritance diagram for PicoLCSerial:

Public Member Functions

void begin (uint32_t baud, uint16_t config=SERIAL_8N1)
 Initializes the RS-485 UART and transceiver-control pins.
void end ()
 Releases PicoLC control of the UART and transceiver-control pins.
int available () override
 Returns the number of received bytes available to read.
int read () override
 Reads the next received byte.
int peek () override
 Returns the next received byte without removing it.
size_t write (uint8_t byte) override
 Transmits one byte over RS-485.
size_t write (const uint8_t *data, size_t length) override
 Transmits a buffer over RS-485.
void flush () override
 Waits for pending UART transmission to complete.
bool started () const
 Reports whether the RS-485 interface is initialized.

Friends

class PicoLC

Detailed Description

Provides Arduino Stream-compatible access to the PicoLC RS-485 port.

PicoLCSerial wraps the hardware UART and RS-485 transmit/receive control pins. The current implementation is blocking: write operations do not return until the requested data has been transmitted and the interface has returned to receive mode.

Instances are created and owned by PicoLC.

Definition at line 15 of file PicoLCSerial.h.

Member Function Documentation

◆ available()

int PicoLCSerial::available()
override

Returns the number of received bytes available to read.

Returns
Number of available bytes, or 0 when the interface is not started.

Definition at line 29 of file PicoLCSerial.cpp.

◆ begin()

void PicoLCSerial::begin(uint32_tbaud,
uint16_tconfig = SERIAL_8N1 )

Initializes the RS-485 UART and transceiver-control pins.

Calling begin() after end() reinitializes the UART and associated pins.

Parameters
baudSerial baud rate.
configArduino serial framing configuration.

Definition at line 9 of file PicoLCSerial.cpp.

◆ end()

void PicoLCSerial::end()

Releases PicoLC control of the UART and transceiver-control pins.

Received data already present in the UART receive buffer is retained. A later call to begin() reinitializes the interface.

Definition at line 22 of file PicoLCSerial.cpp.

◆ flush()

void PicoLCSerial::flush()
override

Waits for pending UART transmission to complete.

This method wraps the underlying Arduino serial implementation. It does nothing when the interface is not started.

Definition at line 53 of file PicoLCSerial.cpp.

◆ peek()

int PicoLCSerial::peek()
override

Returns the next received byte without removing it.

Returns
The next byte as an unsigned value, or -1 when no data is available or the interface is not started.

Definition at line 31 of file PicoLCSerial.cpp.

◆ read()

int PicoLCSerial::read()
override

Reads the next received byte.

Returns
The next byte as an unsigned value, or -1 when no data is available or the interface is not started.

Definition at line 30 of file PicoLCSerial.cpp.

◆ started()

bool PicoLCSerial::started()const

Reports whether the RS-485 interface is initialized.

Returns
true after begin() and until end() is called.

Definition at line 70 of file PicoLCSerial.cpp.

◆ write() [1/2]

size_t PicoLCSerial::write(const uint8_t *data,
size_tlength )
override

Transmits a buffer over RS-485.

This operation is blocking and returns after the complete buffer has been transmitted and the transceiver has returned to receive mode.

Parameters
dataPointer to the data to transmit.
lengthNumber of bytes to transmit.
Returns
Number of bytes written, or 0 when the interface is not started.

Definition at line 43 of file PicoLCSerial.cpp.

◆ write() [2/2]

size_t PicoLCSerial::write(uint8_tbyte)
override

Transmits one byte over RS-485.

This operation is blocking and returns after transmission completes and the transceiver has returned to receive mode.

Parameters
byteByte to transmit.
Returns
Number of bytes written, or 0 when the interface is not started.

Definition at line 33 of file PicoLCSerial.cpp.

◆ PicoLC

friend class PicoLC
friend

Definition at line 16 of file PicoLCSerial.h.


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