TR-mbed 1.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CANHandler Class Reference

#include <CANHandler.h>

Public Types

enum  CANBus { CANBUS_1 , CANBUS_2 , NOBUS }
 

Public Member Functions

 CANHandler ()
 
 CANHandler (PinName canRx, PinName canTx)
 
void attach (Callback< void()> func, CAN::IrqType type=CAN::IrqType::RxIrq)
 
void updateCANs (PinName canRx, PinName canTx)
 
CAN * getCAN ()
 
void registerCallback (uint32_t id, std::function< void(const CANMsg *)> func)
 Add a callback for a specific id.
 
void registerCallback (uint32_t start_id, uint32_t end_id, std::function< void(const CANMsg *)> func)
 Add a callback for multiple ids.
 
void readAllCan ()
 Get feedback from all CAN devices, and send to relevant callbacks.
 
bool getFeedback (int *id, uint8_t bytes[], int canbus)
 Get feedback back from the motor.
 
bool rawRead (int *id, uint8_t bytes[], int length)
 
bool rawSend (int id, int8_t bytes[], int length=8)
 Raw sending of CAN Messages.
 

Static Public Member Functions

static void printMsg (CANMessage &msg)
 Prints a CANMessage nicely.
 

Public Attributes

CAN can
 
std::vector< ExactCallbackexact_
 
std::vector< RangeCallbackrange_
 
bool exists = false
 

Member Enumeration Documentation

◆ CANBus

Enumerator
CANBUS_1 
CANBUS_2 
NOBUS 

Constructor & Destructor Documentation

◆ CANHandler() [1/2]

CANHandler::CANHandler ( )
inline

◆ CANHandler() [2/2]

CANHandler::CANHandler ( PinName  canRx,
PinName  canTx 
)
inline

Member Function Documentation

◆ attach()

void CANHandler::attach ( Callback< void()>  func,
CAN::IrqType  type = CAN::IrqType::RxIrq 
)
inline

◆ getCAN()

CAN * CANHandler::getCAN ( )
inline

◆ getFeedback()

bool CANHandler::getFeedback ( int *  id,
uint8_t  bytes[],
int  canbus 
)
inline

Get feedback back from the motor.

◆ printMsg()

static void CANHandler::printMsg ( CANMessage &  msg)
inlinestatic

Prints a CANMessage nicely.

Parameters
msg

◆ rawRead()

bool CANHandler::rawRead ( int *  id,
uint8_t  bytes[],
int  length 
)
inline

◆ rawSend()

bool CANHandler::rawSend ( int  id,
int8_t  bytes[],
int  length = 8 
)
inline

Raw sending of CAN Messages.

Parameters
idthe CAN ID you're sending to
bytesthe bytes you're sending (8)
busthe bus you're sending the CAN messages to

◆ readAllCan()

void CANHandler::readAllCan ( )
inline

Get feedback from all CAN devices, and send to relevant callbacks.

◆ registerCallback() [1/2]

void CANHandler::registerCallback ( uint32_t  id,
std::function< void(const CANMsg *)>  func 
)
inline

Add a callback for a specific id.

Parameters
idCANMessage id
funcCallback function

◆ registerCallback() [2/2]

void CANHandler::registerCallback ( uint32_t  start_id,
uint32_t  end_id,
std::function< void(const CANMsg *)>  func 
)
inline

Add a callback for multiple ids.

Parameters
stard_idfirst CANMessage id
stard_idlast CANMessage id
funcCallback function

◆ updateCANs()

void CANHandler::updateCANs ( PinName  canRx,
PinName  canTx 
)
inline

Member Data Documentation

◆ can

CAN CANHandler::can

◆ exact_

std::vector<ExactCallback> CANHandler::exact_

◆ exists

bool CANHandler::exists = false

◆ range_

std::vector<RangeCallback> CANHandler::range_

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