Formula Student Electronics & Software
The code for the embedded software
Loading...
Searching...
No Matches
Communicator Class Reference

Class that contains definitions of typical messages to send via CAN It serves only as an example of the usage of the strategy pattern, where the communicator is the strategy. More...

#include <communicator.hpp>

Collaboration diagram for Communicator:
Collaboration graph

Public Member Functions

 Communicator (SystemData *systemdata)
 Constructor for the Communicator class Initializes the Communicator with the given system data instance.
 
void init ()
 Initializes the CAN bus.
 

Static Public Member Functions

static void parse_message (const CAN_message_t &msg)
 Parses the message received from the CAN bus.
 
template<std::size_t N>
static int send_message (unsigned len, const std::array< uint8_t, N > &buffer, unsigned id)
 Sends a message to the CAN bus.
 
static void pc_callback (const uint8_t *buf)
 Callback for message from AS CU.
 
static void c1_callback (const uint8_t *buf)
 Callback for data from C1 Teensy.
 
static void res_state_callback (const uint8_t *buf)
 Callback RES default callback.
 
static void res_ready_callback ()
 Callback for RES activation.
 
static void bamocar_callback (const uint8_t *buf)
 Callback from inversor, for alive signal and data.
 
static void steering_callback ()
 Callback for steering actuator information.
 
static int publish_state (int state_id)
 Publish AS State to CAN.
 
static int publish_mission (int mission_id)
 Publish AS Mission to CAN.
 
static int publish_debug_log (SystemData system_data, uint8_t sate, uint8_t state_checkup)
 Publish AS Mission to CAN.
 
static int publish_left_wheel_rpm (double value)
 Publish rl wheel rpm to CAN.
 

Static Public Attributes

static SystemData_systemData = nullptr
 

Detailed Description

Class that contains definitions of typical messages to send via CAN It serves only as an example of the usage of the strategy pattern, where the communicator is the strategy.

Definition at line 39 of file communicator.hpp.

Constructor & Destructor Documentation

◆ Communicator()

Communicator::Communicator ( SystemData systemdata)
inlineexplicit

Constructor for the Communicator class Initializes the Communicator with the given system data instance.

Parameters
system_dataPointer to the SystemData instance.

Definition at line 126 of file communicator.hpp.

Member Function Documentation

◆ bamocar_callback()

void Communicator::bamocar_callback ( const uint8_t *  buf)
inlinestatic

Callback from inversor, for alive signal and data.

Definition at line 202 of file communicator.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c1_callback()

void Communicator::c1_callback ( const uint8_t *  buf)
inlinestatic

Callback for data from C1 Teensy.

Definition at line 152 of file communicator.hpp.

Here is the caller graph for this function:

◆ init()

void Communicator::init ( )

Initializes the CAN bus.

Definition at line 128 of file communicator.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_message()

void Communicator::parse_message ( const CAN_message_t &  msg)
inlinestatic

Parses the message received from the CAN bus.

Definition at line 248 of file communicator.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pc_callback()

void Communicator::pc_callback ( const uint8_t *  buf)
inlinestatic

Callback for message from AS CU.

Definition at line 231 of file communicator.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publish_debug_log()

int Communicator::publish_debug_log ( SystemData  system_data,
uint8_t  sate,
uint8_t  state_checkup 
)
inlinestatic

Publish AS Mission to CAN.

Definition at line 285 of file communicator.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publish_left_wheel_rpm()

int Communicator::publish_left_wheel_rpm ( double  value)
inlinestatic

Publish rl wheel rpm to CAN.

Definition at line 333 of file communicator.hpp.

Here is the call graph for this function:

◆ publish_mission()

int Communicator::publish_mission ( int  mission_id)
inlinestatic

Publish AS Mission to CAN.

Definition at line 278 of file communicator.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publish_state()

int Communicator::publish_state ( int  state_id)
inlinestatic

Publish AS State to CAN.

Definition at line 272 of file communicator.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ res_ready_callback()

void Communicator::res_ready_callback ( )
inlinestatic

Callback for RES activation.

Definition at line 193 of file communicator.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ res_state_callback()

void Communicator::res_state_callback ( const uint8_t *  buf)
inlinestatic

Callback RES default callback.

Definition at line 166 of file communicator.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_message()

template<std::size_t N>
int Communicator::send_message ( unsigned  len,
const std::array< uint8_t, N > &  buffer,
unsigned  id 
)
inlinestatic

Sends a message to the CAN bus.

Parameters
lenLength of the message
bufferBuffer containing the message
idID of the message
Returns
0 if successful

Definition at line 342 of file communicator.hpp.

Here is the caller graph for this function:

◆ steering_callback()

void Communicator::steering_callback ( )
inlinestatic

Callback for steering actuator information.

Definition at line 244 of file communicator.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _systemData

SystemData* Communicator::_systemData = nullptr
inlinestatic

Definition at line 46 of file communicator.hpp.


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