Skip to content

Commit

Permalink
Added implementation in TelemetryInterface and updated .ini file
Browse files Browse the repository at this point in the history
  • Loading branch information
CL16gtgh committed May 20, 2024
1 parent 3a1f493 commit 1e5326a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 19 deletions.
56 changes: 38 additions & 18 deletions lib/interfaces/src/TelemetryInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void TelemetryInterface::update_front_thermistors_CAN_msg(const AnalogConversion
const AnalogConversion_s &therm_fr) {

FRONT_THERMISTORS_t front_thermistors_;
front_thermistors_.thermistor_motor_fl = therm_fl.raw;
front_thermistors_.thermistor_motor_fr = therm_fr.raw;
front_thermistors_.thermistor_motor_fl_ro = HYTECH_thermistor_motor_fl_ro_toS(therm_fl.raw);
front_thermistors_.thermistor_motor_fr_ro = HYTECH_thermistor_motor_fr_ro_toS(therm_fr.raw);

enqueue_new_CAN<FRONT_THERMISTORS_t>(&front_thermistors_, &Pack_FRONT_THERMISTORS_hytech);
}
Expand Down Expand Up @@ -194,6 +194,42 @@ void TelemetryInterface::update_penthouse_accum_CAN_msg(const AnalogConversion_s
enqueue_new_CAN<PENTHOUSE_ACCUM_MSG_t>(&message, &Pack_PENTHOUSE_ACCUM_MSG_hytech);
}

void TelemetryInterface::update_TCMux_status_CAN_msg(const TCMuxStatus_s &tcMuxStatus)
{
TCMUX_STATUS_REPORT_t msg;

msg.speed_above_thresh = tcMuxStatus.speedPreventsModeChange;
msg.torque_delta_above_thresh = tcMuxStatus.torqueDeltaPreventsModeChange;
msg.tc_not_ready = tcMuxStatus.controllerNotReadyPreventsModeChange;
msg.steering_system_has_err = tcMuxStatus.steeringSystemError;
msg.mode_intended = tcMuxStatus.modeIntended;
msg.mode_actual = tcMuxStatus.modeActual;
msg.dash_dial_mode = tcMuxStatus.dialMode;
msg.torque_mode = tcMuxStatus.torqueMode;
msg.torque_limit_ro = HYTECH_torque_limit_ro_toS(tcMuxStatus.maxTorque);

enqueue_new_CAN<TCMUX_STATUS_REPORT_t>(&msg, &Pack_TCMUX_STATUS_REPORT_hytech);
}

void TelemetryInterface::update_steering_status_CAN_msg(const float steering_system_angle,
const float filtered_angle_encoder,
const float filtered_angle_analog,
const uint8_t steering_system_status,
const uint8_t steering_encoder_status,
const uint8_t steering_analog_status)
{
STEERING_SYSTEM_REPORT_t msg;

msg.steering_system_angle_ro = HYTECH_steering_system_angle_ro_toS(steering_system_angle);
msg.steering_encoder_angle_ro = HYTECH_steering_encoder_angle_ro_toS(filtered_angle_encoder);
msg.steering_analog_angle_ro = HYTECH_steering_analog_angle_ro_toS(filtered_angle_analog);
msg.steering_system_status = steering_system_status;
msg.steering_encoder_status = steering_encoder_status;
msg.steering_analog_status = steering_analog_status;

enqueue_new_CAN<STEERING_SYSTEM_REPORT_t>(&msg, &Pack_STEERING_SYSTEM_REPORT_hytech);
}

/* Send CAN messages */
template<typename T>
void TelemetryInterface::enqueue_CAN(T msg_class, uint32_t id) {
Expand Down Expand Up @@ -237,22 +273,6 @@ void TelemetryInterface::enqeue_controller_CAN_msg(const PIDTVTorqueControllerDa

}

void TelemetryInterface::update_TCMux_status_CAN_msg(const TCMuxStatus_s &tcMuxStatus)
{

}

void TelemetryInterface::update_steering_status_CAN_msg(const float steering_system_angle,
const float filtered_angle_encoder,
const float filtered_angle_analog,
const uint8_t steering_system_status,
const uint8_t steering_encoder_status,
const uint8_t steering_analog_status)
{

}


/* Tick SysClock */
void TelemetryInterface::tick(const AnalogConversionPacket_s<8> &adc1,
const AnalogConversionPacket_s<4> &adc2,
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ lib_deps =
https://github.com/RCMast3r/spi_libs
https://github.com/tonton81/FlexCAN_T4
https://github.com/RCMast3r/hytech_can#testing_new_inv_ids
https://github.com/hytech-racing/HT_CAN/releases/download/96/can_lib.tar.gz
https://github.com/hytech-racing/HT_CAN/releases/download/99/can_lib.tar.gz
git+ssh://git@github.com/hytech-racing/CASE_lib.git#v48

[env:test_can_on_teensy]
Expand Down

0 comments on commit 1e5326a

Please sign in to comment.