Treehopper C++ API
Uart Class Referenceabstract

#include <Uart.h>

Inheritance diagram for Uart:
HardwareUart

Public Member Functions

virtual void startUart ()=0
 Start the UART with the specified baud More...
 
virtual void send (std::vector< uint8_t > dataToSend)=0
 Send data More...
 
virtual std::vector< uint8_t > receive ()=0
 Receive bytes from the UART in UART mode More...
 
virtual void baud (int baud)=0
 Sets the baud of the UART. More...
 
virtual int baud ()=0
 Gets the baud of the UART. More...
 

Member Function Documentation

◆ baud() [1/2]

virtual void baud ( int  baud)
pure virtual

Baud can range from 7813 - 2400000 baud, but values less than 2000000 (2 Mbaud) are recommended.

Implemented in HardwareUart.

◆ baud() [2/2]

virtual int baud ( )
pure virtual

Implemented in HardwareUart.

◆ receive()

virtual std::vector<uint8_t> receive ( )
pure virtual
Returns
The bytes received

As soon as the UART is enabled, any received byte will be added to a 32-byte buffer. Calling this Receive() function does two things:

  • sends the current contents of this buffer to this function.
  • reset the pointer in the buffer to the 0th element, effectively resetting it. If the buffer fills before the Receive() function is called, the existing buffer will be reset — discarding all data in the buffer. Consequently, it's important to call the Receive() function frequently when expecting data.

Owing to how it is implemented, you can clear the buffer at any point by calling Receive(). It's common to empty the buffer before requesting data from the device attached to the UART; this way, you do not have to worry about existing gibberish data that might have been inadvertently received.

Implemented in HardwareUart.

◆ send()

virtual void send ( std::vector< uint8_t >  dataToSend)
pure virtual
Parameters
dataToSendThe data to send
Returns
An awaitable task that completes upon transmission of the data

Implemented in HardwareUart.

◆ startUart()

virtual void startUart ( )
pure virtual

Implemented in HardwareUart.


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