Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions lib/interfaces/include/IRTSSensor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifndef IRTSSENSORINTERFACE_H
#define IRTSSENSORINTERFACE_H

#include "FlexCAN_T4.h"
#include "SharedFirmwareTypes.h"

#define UNPACK_AND_POPULATE_TEMP(WHEEL, MSGNUM, CH1, CH2, CH3, CH4) \
WHEEL##_IRTS_##MSGNUM##_t unpacked_sensor_data; \
Unpack_##WHEEL##_IRTS_##MSGNUM##_hytech(&unpacked_sensor_data, msg.buf, msg.len); \
latest_sensor_data.infrared_temp[CH1 - 1] = unpacked_sensor_data.WHEEL##IRTS_T##CH1##_ro; \
latest_sensor_data.infrared_temp[CH1] = unpacked_sensor_data.WHEEL##IRTS_T##CH2##_ro; \
latest_sensor_data.infrared_temp[CH1 + 1] = unpacked_sensor_data.WHEEL##IRTS_T##CH3##_ro; \
latest_sensor_data.infrared_temp[CH1 + 2] = unpacked_sensor_data.WHEEL##IRTS_T##CH4##_ro; \

class IRTSSensorInterface
{
public:
// LF wheel
void receive_IRTS_sensor_temp_lf_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis);
void receive_IRTS_sensor_temp_lf_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis);
void receive_IRTS_sensor_temp_lf_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis);
void receive_IRTS_sensor_temp_lf_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis);

// RF wheel
void receive_IRTS_sensor_temp_rf_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis);
void receive_IRTS_sensor_temp_rf_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis);
void receive_IRTS_sensor_temp_rf_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis);
void receive_IRTS_sensor_temp_rf_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis);

// LR wheel
void receive_IRTS_sensor_temp_lr_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis);
void receive_IRTS_sensor_temp_lr_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis);
void receive_IRTS_sensor_temp_lr_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis);
void receive_IRTS_sensor_temp_lr_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis);

// RR wheel
void receive_IRTS_sensor_temp_rr_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis);
void receive_IRTS_sensor_temp_rr_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis);
void receive_IRTS_sensor_temp_rr_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis);
void receive_IRTS_sensor_temp_rr_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis);

IRTSSensorData_s get_latest_sensor_data() const;

private:
IRTSSensorData_s latest_sensor_data;
};

#endif
81 changes: 81 additions & 0 deletions lib/interfaces/src/IRTSSensor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include "IRTSSensorInterface.h"
#include "FlexCAN_T4.h"
#include "hytech.h"

// LF wheel
void IRTSSensorInterface::receive_IRTS_sensor_temp_lf_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(FL, 1, 1, 2, 3, 4);
}
void IRTSSensorInterface::receive_IRTS_sensor_temp_lf_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(FL, 2, 5, 6, 7, 8);
}
void IRTSSensorInterface::receive_IRTS_sensor_temp_lf_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(FL, 3, 9, 10, 11, 12);
}
void IRTSSensorInterface::receive_IRTS_sensor_temp_lf_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(FL, 4, 13, 14, 15, 16);
}

// RF wheel
void IRTSSensorInterface::receive_IRTS_sensor_temp_rf_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(RF, 1, 1, 2, 3, 4);
}
void IRTSSensorInterface::receive_IRTS_sensor_temp_rf_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(RF, 2, 5, 6, 7, 8);
}
void IRTSSensorInterface::receive_IRTS_sensor_temp_rf_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(RF, 3, 9, 10, 11, 12);
}
void IRTSSensorInterface::receive_IRTS_sensor_temp_rf_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(RF, 4, 13, 14, 15, 16);
}


// LFR wheel
void IRTSSensorInterface::receive_IRTS_sensor_temp_lr_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(LR, 1, 1, 2, 3, 4);
}
void IRTSSensorInterface::receive_IRTS_sensor_temp_lr_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(LR, 2, 5, 6, 7, 8);
}
void IRTSSensorInterface::receive_IRTS_sensor_temp_lr_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(LR, 3, 9, 10, 11, 12);
}
void IRTSSensorInterface::receive_IRTS_sensor_temp_lr_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(LR, 4, 13, 14, 15, 16);
}

// RR wheel
void IRTSSensorInterface::receive_IRTS_sensor_temp_rr_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(RR, 1, 1, 2, 3, 4);
}
void IRTSSensorInterface::receive_IRTS_sensor_temp_rr_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(RR, 2, 5, 6, 7, 8);
}
void IRTSSensorInterface::receive_IRTS_sensor_temp_rr_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(RR, 3, 9, 10, 11, 12);
}
void IRTSSensorInterface::receive_IRTS_sensor_temp_rr_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis)
{
UNPACK_AND_POPULATE_TEMP(RR, 4, 13, 14, 15, 16);
}

IRTSSensorData_s IRTSSensorInterface::get_latest_sensor_data() const
{
return latest_sensor_data;
}
Loading