Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::can::Can Class Reference

#include <can.hpp>

Public Member Functions

 Can ()=default
 
mockable ~Can ()=default
 
mockable void initialize ()
 
mockable bool isMessageAvailable (CanBus bus) const
 
mockable bool getMessage (CanBus bus, modm::can::Message *message)
 
mockable bool isReadyToSend (CanBus bus) const
 
mockable bool sendMessage (CanBus bus, const modm::can::Message &message)
 

Detailed Description

A simple CAN wrapper class that handles I/O from both CAN bus 1 and 2.

Constructor & Destructor Documentation

◆ Can()

tap::can::Can::Can ( )
default

◆ ~Can()

mockable tap::can::Can::~Can ( )
default

Member Function Documentation

◆ getMessage()

bool tap::can::Can::getMessage ( CanBus  bus,
modm::can::Message *  message 
)

Checks the CanBus for a message and if a message is successfully acquired, returns true and places the message in the return parameter message.

Parameters
[in]busthe CanBus to acquire a message from.
[out]messagea return parameter which the message is placed in.
Returns
true if a valid message was placed in the parameter message. False otherwise.

◆ initialize()

void tap::can::Can::initialize ( )

Initializes CAN 1 and CAN 2 hardware to pins specific to the development board and sets up the CAN bus filters necessary for reading from the CAN bus.

Note
CAN 1 is connected to pins D0 (RX) and D1 (TX) and CAN 2 is connected to pins B12 (RX) and B12 (TX).
The CAN filters are set up to receive NOT extended identifier IDs.

◆ isMessageAvailable()

bool tap::can::Can::isMessageAvailable ( CanBus  bus) const

Checks the passed in CanBus to see if there is a message waiting and available.

Parameters
[in]busthe CanBus to check for a message.
Returns
true if a message is available, false otherwise.

◆ isReadyToSend()

bool tap::can::Can::isReadyToSend ( CanBus  bus) const

Checks the given CanBus to see if the CanBus is idle.

Parameters
[in]busthe CanBus to check.
Returns
true if the bus is not busy, false otherwise.

◆ sendMessage()

bool tap::can::Can::sendMessage ( CanBus  bus,
const modm::can::Message &  message 
)

Sends the passed in message over the CanBus. Returns whether or not the message succeeded.

Attention
modm::can::Message defaults to an extended message identifier. For all RoboMaster products we have, we do not want our messages to be extended. Be sure to be explicit when instantiating a message object and setting extended to false.
Parameters
[in]busthe CanBus for which the message should be sent across.
[in]messagethe message to send
Returns
true if the message was successfully sent, false otherwise.

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