modm API documentation
xpcc::CanConnector< Driver > Class Template Reference

The CAN connector to the XPCC communication. More...

#include <modm/communication/xpcc/backend/can/connector.hpp>

Inheritance diagram for xpcc::CanConnector< Driver >:
xpcc::CanConnectorBase xpcc::BackendInterface

Classes

class  ReceiveListItem
 
class  SendListItem
 

Public Member Functions

 CanConnector (Driver *driver)
 
virtual void sendPacket (const Header &header, modm::SmartPointer payload)
 Send a Message.
 
virtual bool isPacketAvailable () const
 Check if a new packet was received by the backend.
 
virtual const HeadergetPacketHeader () const
 Access the packet.
 
virtual const modm::SmartPointer getPacketPayload () const
 
virtual void dropPacket ()
 
virtual void update ()
 

Protected Typedefs

typedef modm::LinkedList< SendListItemSendList
 
typedef modm::LinkedList< ReceiveListItemReceiveList
 

Protected Member Functions

 CanConnector (const CanConnector &)
 
CanConnector & operator= (const CanConnector &)
 
bool sendMessage (const uint32_t &identifier, const uint8_t *data, uint8_t size)
 Try to send a CAN message via CAN Driver. More...
 
void sendWaitingMessages ()
 
bool retrieveMessage ()
 

Static Protected Member Functions

static bool convertToHeader (const uint32_t &identifier, Header &header)
 Convert a can identifier to a packet header. More...
 
static uint32_t convertToIdentifier (const Header &header, bool fragmentated)
 Convert a packet header to a can identifier.
 
static uint8_t getNumberOfFragments (uint8_t messageSize)
 Calculate the number of fragments needed to send a message with a length of messageSize.
 
static bool isFragment (const uint32_t &identifier)
 

Protected Attributes

SendList sendList
 
ReceiveList pendingMessages
 
ReceiveList receivedMessages
 
Driver * canDriver
 

Static Protected Attributes

static uint8_t messageCounter = 0
 

Detailed Description

template<typename Driver>
class xpcc::CanConnector< Driver >

The CAN connector to the XPCC communication.

The Needed Interface

The interface of the per template parameter given driver has to provide the following static methods.

static bool
isMessageAvailable();
static bool
getMessage(can::Message& message);
/// The CAN controller has a free slot to send a new message.
/// \return true if a slot is available, false otherwise
static bool
isReadyToSend();
/// Send a message over the CAN.
/// \return true if the message was send, false otherwise
static bool
sendMessage(const can::Message& message);

Definition of the structure of a CAN message

Changes in the highest 4 bits:

  • 2 bit: Action [0], Response [1], Neg. Response [2], not used [3]
  • 1 bit: Request [0], Acknowledge [1] (NACK implicit in the payload)
  • 1 bit: Message Counter active [1] / not active [1]

Every event is send with the destination identifier 0x00.

Member Function Documentation

bool xpcc::CanConnectorBase::convertToHeader ( const uint32_t &  identifier,
xpcc::Header header 
)
inheritedstatic

Convert a can identifier to a packet header.

Parameters
[in]identifier29-bit CAN identifier
[out]headerPacket header
Returns
true if the message is part of a fragmented packet, false otherwise.
template<typename Driver >
bool xpcc::CanConnector< Driver >::sendMessage ( const uint32_t &  identifier,
const uint8_t *  data,
uint8_t  size 
)
protected

Try to send a CAN message via CAN Driver.

Returns
true if the message could be send, false otherwise

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