12 #include <RHGenericDriver.h>
21 #define RH_SERIAL_MAX_PAYLOAD_LEN 64
25 #define RH_SERIAL_HEADER_LEN 4
32 #ifndef RH_SERIAL_MAX_MESSAGE_LEN
33 #define RH_SERIAL_MAX_MESSAGE_LEN (RH_SERIAL_MAX_PAYLOAD_LEN - RH_SERIAL_HEADER_LEN)
36 #if (RH_PLATFORM == RH_PLATFORM_STM32F2)
37 #define HardwareSerial USARTSerial
38 #elif (RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined(ARDUINO_attinyxy6)
40 #define HardwareSerial UartClass
189 virtual bool recv(uint8_t* buf, uint8_t* len);
197 virtual bool send(
const uint8_t* data, uint8_t len);
249 uint8_t
_rxBuf[RH_SERIAL_MAX_PAYLOAD_LEN];
@ RxStateData
Receiving data.
Definition: RH_Serial.h:212
volatile uint16_t _rxGood
Count of the number of successfully transmitted messaged.
Definition: RHGenericDriver.h:292
@ RxStateDLE
Waiting for the DLE after STX.
Definition: RH_Serial.h:211
RxState _rxState
The current state of the Rx state machine.
Definition: RH_Serial.h:240
volatile uint8_t _rxHeaderFrom
FROM header in the last received mesasge.
Definition: RHGenericDriver.h:265
virtual bool waitAvailableTimeout(uint16_t timeout)
Definition: RHGenericDriver.cpp:38
HardwareSerial & serial()
volatile uint16_t _rxBad
Count of the number of bad messages (eg bad checksum etc) received.
Definition: RHGenericDriver.h:289
Driver to send and receive unaddressed, unreliable datagrams via a serial connection.
Definition: RH_Serial.h:148
volatile uint8_t _rxHeaderTo
TO header in the last received mesasge.
Definition: RHGenericDriver.h:262
RxState
Defines different receiver states in teh receiver state machine.
Definition: RH_Serial.h:207
uint8_t _txHeaderFrom
FROM header to send in all messages.
Definition: RHGenericDriver.h:277
Abstract base class for a RadioHead driver.
Definition: RHGenericDriver.h:41
uint16_t _txFcs
FCS for transmitted data.
Definition: RH_Serial.h:258
@ RxStateWaitFCS2
Waiting for second FCS octet.
Definition: RH_Serial.h:215
void handleRx(uint8_t ch)
uint8_t _thisAddress
This node id.
Definition: RHGenericDriver.h:256
@ RxStateEscape
Got a DLE while receiving data.
Definition: RH_Serial.h:213
void clearRxBuf()
Empties the Rx buffer.
bool _promiscuous
Whether the transport is in promiscuous mode.
Definition: RHGenericDriver.h:259
HardwareSerial & _serial
Reference to the HardwareSerial port we will use.
Definition: RH_Serial.h:237
volatile uint8_t _rxHeaderFlags
FLAGS header in the last received mesasge.
Definition: RHGenericDriver.h:271
bool _rxBufValid
True if the data in the Rx buffer is value and uncorrupted and complete message is available for coll...
Definition: RH_Serial.h:255
uint8_t _rxBufLen
Current length of data in the Rx buffer.
Definition: RH_Serial.h:252
virtual bool waitAvailableTimeout(uint16_t timeout)
virtual uint8_t maxMessageLength()
uint8_t _txHeaderId
ID header to send in all messages.
Definition: RHGenericDriver.h:280
@ RxStateIdle
Waiting for an STX.
Definition: RH_Serial.h:210
virtual bool recv(uint8_t *buf, uint8_t *len)
uint8_t _txHeaderTo
TO header to send in all messages.
Definition: RHGenericDriver.h:274
uint8_t _rxBuf[RH_SERIAL_MAX_PAYLOAD_LEN]
The Rx buffer.
Definition: RH_Serial.h:249
@ RxStateInitialising
Before init() is called.
Definition: RH_Serial.h:209
virtual bool init()
Definition: RHGenericDriver.cpp:23
uint8_t _txHeaderFlags
FLAGS header to send in all messages.
Definition: RHGenericDriver.h:283
@ RxStateWaitFCS1
Got DLE ETX, waiting for first FCS octet.
Definition: RH_Serial.h:214
void appendRxBuf(uint8_t ch)
Adds a charater to the Rx buffer.
uint16_t _rxFcs
Progressive FCS calc (CCITT CRC-16 covering all received data (but not stuffed DLEs),...
Definition: RH_Serial.h:243
virtual bool send(const uint8_t *data, uint8_t len)
virtual void waitAvailable()
volatile uint8_t _rxHeaderId
ID header in the last received mesasge.
Definition: RHGenericDriver.h:268
uint16_t _rxRecdFcs
The received FCS at the end of the current message.
Definition: RH_Serial.h:246
RH_Serial(HardwareSerial &serial)
virtual void waitAvailable()
Definition: RHGenericDriver.cpp:29
virtual bool waitCAD()
Definition: RHGenericDriver.cpp:72