modm API documentation
modm::sab2::Interface< Device, N > Class Template Reference

SAB2 interface. More...

#include <modm/communication/sab2/interface.hpp>

Public Typedefs

using Index = std::conditional_t< (N >=255), uint16_t, uint8_t >
 
using Size = Index
 

Static Public Member Functions

static void initialize ()
 Initialize the interface. More...
 
static void sendMessage (uint8_t address, Flags flags, uint8_t command, const void *payload, Size payloadLength)
 Send a message. More...
 
template<typename T >
static void sendMessage (uint8_t address, Flags flags, uint8_t command, const T &payload)
 Send a message.
 
static void sendMessage (uint8_t address, Flags flags, uint8_t command)
 Send a empty message.
 
static bool isMessageAvailable ()
 Check if a message was received. More...
 
static uint8_t getAddress ()
 
static uint8_t getCommand ()
 
static bool isResponse ()
 
static bool isAcknowledge ()
 Check if the message is an ACK or NACK. More...
 
static const uint8_t * getPayload ()
 Access the data of a received message. More...
 
static Size getPayloadLength ()
 
static void dropMessage ()
 End procession of the current message.
 
static void update ()
 Update internal status. More...
 

Detailed Description

template<typename Device, std::size_t N = maxPayloadLength>
class modm::sab2::Interface< Device, N >

SAB2 interface.

The framing is adapted from the HDLC asynchronous framing. See http://en.wikipedia.org/wiki/High-Level_Data_Link_Control#Asynchronous_framing

Author
Fabian Greif

Member Function Documentation

template<typename Device , std::size_t N = maxPayloadLength>
static const uint8_t* modm::sab2::Interface< Device, N >::getPayload ( )
inlinestatic

Access the data of a received message.

Data access is only valid after isMessageAvailable() returns true and before any call of dropMessage() or update()

template<typename Device , std::size_t N = maxPayloadLength>
static Size modm::sab2::Interface< Device, N >::getPayloadLength ( )
inlinestatic
Returns
Size of the received message. Zero if no message is available at the moment.
template<typename Device , std::size_t N = maxPayloadLength>
static void modm::sab2::Interface< Device, N >::initialize ( )
static

Initialize the interface.

The UART has the be configured before calling this method.

template<typename Device , std::size_t N = maxPayloadLength>
static bool modm::sab2::Interface< Device, N >::isAcknowledge ( )
inlinestatic

Check if the message is an ACK or NACK.

Returns
true if the message is an ACK, false on NACK.
template<typename Device , std::size_t N = maxPayloadLength>
static bool modm::sab2::Interface< Device, N >::isMessageAvailable ( )
inlinestatic

Check if a message was received.

Reset the status with a call of dropMessage().

template<typename Device , std::size_t N = maxPayloadLength>
static void modm::sab2::Interface< Device, N >::sendMessage ( uint8_t  address,
Flags  flags,
uint8_t  command,
const void *  payload,
Size  payloadLength 
)
static

Send a message.

Parameters
addressreceiver address
flagssee modm::sab::Flags
commandcommand byte
*payloaddata field
payloadLengthsize of the data field
template<typename Device , std::size_t N = maxPayloadLength>
static void modm::sab2::Interface< Device, N >::update ( )
static

Update internal status.

Has to be called periodically. Encodes received messages.


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