CAN progress

This commit is contained in:
rusEfi 2020-03-31 20:57:52 -04:00
parent b7618dbed1
commit 96828ae017
3 changed files with 15 additions and 0 deletions

View File

@ -37,9 +37,11 @@ void processCanRxMessage(const CANRxFrame& frame, Logging* logger) {
uint16_t lambdaInt = SWAP_UINT16(frame.data16[0]);
aemXSeriesLambda = 0.0001f * lambdaInt;
} else if (frame.EID == CONFIG(verboseCanBaseAddress) + CAN_PEDAL_TPS_OFFSET) {
obdOnCanPacketRx(frame);
int16_t pedalScaled = *reinterpret_cast<const uint16_t*>(&frame.data8[0]);
canPedal = pedalScaled / (1.0 * PACK_MULT_PERCENT);
} else if (frame.EID == CONFIG(verboseCanBaseAddress) + CAN_SENSOR_1_OFFSET) {
obdOnCanPacketRx(frame);
int16_t mapScaled = *reinterpret_cast<const uint16_t*>(&frame.data8[0]);
canMap = mapScaled / (1.0 * PACK_MULT_PRESSURE);
} else {

View File

@ -12,7 +12,10 @@
#if EFI_CAN_SUPPORT
#include "can_msg_tx.h"
#include "engine_configuration.h"
EXTERN_CONFIG
extern LoggingWithStorage sharedLogger;
/*static*/ CANDriver* CanTxMessage::s_device = nullptr;
@ -36,6 +39,14 @@ CanTxMessage::~CanTxMessage() {
return;
}
if (CONFIG(debugMode) == DBG_CAN) {
scheduleMsg(&sharedLogger, "Sending CAN message: SID %x/%x %x %x %x %x %x %x %x %x", m_frame.SID, m_frame.DLC,
m_frame.data8[0], m_frame.data8[1],
m_frame.data8[2], m_frame.data8[3],
m_frame.data8[4], m_frame.data8[5],
m_frame.data8[6], m_frame.data8[7]);
}
// 100 ms timeout
canTransmit(device, CAN_ANY_MAILBOX, &m_frame, TIME_MS2I(100));
}

View File

@ -93,5 +93,7 @@ template <typename TData>
void transmitStruct(uint32_t eid)
{
CanTxTyped<TData> frame(eid);
// Destruction of an instance of CanTxMessage will transmit the message over the wire.
// see CanTxMessage::~CanTxMessage()
populateFrame(frame.get());
}