|
M5Unit-RS485 0.0.1 git rev:d5ba212
|
RS-485 unit using SP485 transceiver. More...
#include <unit_SP485.hpp>
Classes | |
| struct | config_t |
| Settings for begin. More... | |
Public Member Functions | |
| UnitSP485 () | |
| Constructor. | |
| virtual | ~UnitSP485 ()=default |
| Destructor. | |
| virtual bool | begin () override |
| Begin using the registered UART adapter. | |
Settings for begin | |
| config_t | config () |
| Gets the configuration. | |
| void | config (const config_t &cfg) |
| Sets the configuration. | |
Arduino Serial Compatibility API | |
| |
| operator bool () const | |
| Returns true if the unit is registered. | |
| int | available () |
| Returns the number of available bytes to read. | |
| int | availableForWrite () |
| Returns the number of bytes that can be written without blocking. | |
| int | peek () |
| Peeks the next incoming byte without removing it. | |
| int | read () |
| Reads one byte. | |
| size_t | read (uint8_t *buffer, const size_t size) |
| Reads up to size bytes into buffer. | |
| size_t | read (char *buffer, const size_t size) |
| Reads up to size bytes into buffer. | |
| size_t | readBytes (uint8_t *buffer, const size_t length) |
| Reads bytes with timeout defined by underlying Serial. | |
| size_t | readBytes (char *buffer, const size_t length) |
| Reads bytes with timeout defined by underlying Serial. | |
| void | flush () |
| Flushes the serial port. | |
| void | flush (const bool txOnly) |
| Flushes the serial port. | |
| size_t | write (const uint8_t d, const bool flush=true) |
| Writes one byte. | |
| size_t | write (const uint8_t *buffer, const size_t size, const bool flush=true) |
| Writes bytes from buffer. | |
| size_t | write (const char *buffer, const size_t size, const bool flush=true) |
| Writes bytes from buffer. | |
| size_t | write (const char *s, const bool flush=true) |
| Writes a null-terminated string. | |
Read/Write any value | |
| template<typename T , bool LittleEndian = true> | |
| bool | readValue (T &value) |
| Read the any number value. | |
| template<typename T , bool LittleEndian = true> | |
| bool | writeValue (const T value) |
| Write the any number value. | |
Protected Member Functions | |
| ISerial * | iserial () |
RS-485 unit using SP485 transceiver.
|
inline |
Returns the number of available bytes to read.
|
inline |
Returns the number of bytes that can be written without blocking.
|
overridevirtual |
Begin using the registered UART adapter.
|
inline |
Gets the configuration.
|
inline |
Sets the configuration.
| cfg | Configuration settings |
|
inline |
Flushes the serial port.
| txOnly | If true, flush only TX |
|
inline |
Peeks the next incoming byte without removing it.
|
inline |
Reads one byte.
|
inline |
Reads up to size bytes into buffer.
| buffer | Destination buffer |
| size | Maximum number of bytes to read |
|
inline |
Reads up to size bytes into buffer.
| buffer | Destination buffer |
| size | Maximum number of bytes to read |
|
inline |
Reads bytes with timeout defined by underlying Serial.
| buffer | Destination buffer |
| length | Number of bytes to read |
|
inline |
Reads bytes with timeout defined by underlying Serial.
| buffer | Destination buffer |
| length | Number of bytes to read |
|
inline |
Read the any number value.
| T | Type |
| LittleEndian | Incoming data is little-endian if true |
| value | Receive variable |
| size_t m5::unit::UnitSP485::write | ( | const char * | buffer, |
| const size_t | size, | ||
| const bool | flush = true ) |
Writes bytes from buffer.
| buffer | Source buffer |
| size | Number of bytes to write |
| flush | If true, flush TX before returning |
| size_t m5::unit::UnitSP485::write | ( | const char * | s, |
| const bool | flush = true ) |
Writes a null-terminated string.
| s | Null-terminated string |
| flush | If true, flush TX before returning |
| size_t m5::unit::UnitSP485::write | ( | const uint8_t * | buffer, |
| const size_t | size, | ||
| const bool | flush = true ) |
Writes bytes from buffer.
| buffer | Source buffer |
| size | Number of bytes to write |
| flush | If true, flush TX before returning |
| size_t m5::unit::UnitSP485::write | ( | const uint8_t | d, |
| const bool | flush = true ) |
Writes one byte.
| d | Byte to write |
| flush | If true, flush TX before returning |
|
inline |
Write the any number value.
| T | Type |
| LittleEndian | Outgoing data is little-endian if true |
| value | Value to write |