Red Bird Racing VCU v2
 
Loading...
Searching...
No Matches
Telemetry.cpp
Go to the documentation of this file.
1/**
2 * @file Telemetry.cpp
3 * @author Planeson, Red Bird Racing
4 * @brief Implementation of the Telemetry class for sending telemetry data over CAN bus
5 * @version 1.0
6 * @date 2026-01-26
7 * @see Telemetry.hpp
8 */
9
10#include "Telemetry.hpp"
11
12/**
13 * @brief Construct a new Telemetry object
14 * @param mcp2515_ Reference to MCP2515 for sending CAN messages
15 * @param car_ Reference to CarState
16 */
17Telemetry::Telemetry(MCP2515 &mcp2515_, CarState &car_)
18 : mcp2515(mcp2515_), car(car_)
19{
20}
21
22/**
23 * @brief Internal helper to get and send the Pedal telemetry frame
24 */
26{
27 can_frame pedal_frame = car.pedal.toCanFrame();
28 mcp2515.sendMessage(&pedal_frame);
29}
30
31/**
32 * @brief Internal helper to get and send the motor telemetry frame
33 */
35{
36 can_frame motor_frame = car.motor.toCanFrame();
37 mcp2515.sendMessage(&motor_frame);
38}
39
40/**
41 * @brief Internal helper to get and send the BMS telemetry frame
42 */
44{
45 can_frame bms_frame = car.bms.toCanFrame();
46 mcp2515.sendMessage(&bms_frame);
47}
Declaration of the Telemetry class for sending telemetry data over CAN bus.
void sendMotor()
Internal helper to get and send the motor telemetry frame.
Definition: Telemetry.cpp:34
Telemetry(MCP2515 &mcp2515_, CarState &car_)
Construct a new Telemetry object.
Definition: Telemetry.cpp:17
CarState & car
Definition: Telemetry.hpp:36
void sendPedal()
Internal helper to get and send the Pedal telemetry frame.
Definition: Telemetry.cpp:25
void sendBms()
Internal helper to get and send the BMS telemetry frame.
Definition: Telemetry.cpp:43
MCP2515 & mcp2515
Definition: Telemetry.hpp:35
struct CarState car
Global car state structure.
Definition: main.cpp:65
Represents the state of the car. Holds telemetry data and status, used as central data sharing struct...
Definition: CarState.hpp:158
TelemetryFramePedal pedal
Definition: CarState.hpp:159
TelemetryFrameMotor motor
Definition: CarState.hpp:160
TelemetryFrameBms bms
Definition: CarState.hpp:161
constexpr can_frame toCanFrame() const
Converts the TelemetryFrameBms to a CAN frame.
Definition: CarState.hpp:135
constexpr can_frame toCanFrame() const
Converts the TelemetryFrameMotor to a CAN frame.
Definition: CarState.hpp:107
constexpr can_frame toCanFrame() const
Converts the TelemetryFramePedal to a CAN frame.
Definition: CarState.hpp:77