Print all rx packets in can debug mode (#1242)

* print packets in debug mode

* remove extra calls

* fix sign too
This commit is contained in:
Matthew Kennedy 2020-03-31 18:18:19 -07:00 committed by GitHub
parent 96828ae017
commit e5e243f0a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -30,6 +30,10 @@ volatile float canPedal = 0;
volatile float canMap = 0;
void processCanRxMessage(const CANRxFrame& frame, Logging* logger) {
if (CONFIG(debugMode) == DBG_CAN) {
printPacket(frame, logger);
}
// TODO: if/when we support multiple lambda sensors, sensor N
// has address 0x0180 + N where N = [0, 15]
if (frame.SID == 0x0180) {
@ -37,15 +41,12 @@ 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]);
int16_t pedalScaled = *reinterpret_cast<const int16_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]);
int16_t mapScaled = *reinterpret_cast<const int16_t*>(&frame.data8[0]);
canMap = mapScaled / (1.0 * PACK_MULT_PRESSURE);
} else {
printPacket(frame, logger);
obdOnCanPacketRx(frame);
}
}