refactoring + MAP broadcast consumption
This commit is contained in:
parent
67f01ff9c7
commit
8a3e47d9e6
|
@ -681,7 +681,7 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
engineConfiguration->canNbcType = CAN_BUS_MAZDA_RX8;
|
||||
|
||||
// Don't enable, but set default address
|
||||
engineConfiguration->verboseCanBaseAddress = 0x200;
|
||||
engineConfiguration->verboseCanBaseAddress = CAN_DEFAULT_BASE;
|
||||
|
||||
engineConfiguration->sdCardPeriodMs = 50;
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
|
||||
#include "periodic_thread_controller.h"
|
||||
|
||||
#define CAN_PEDAL_TPS_OFFSET 2
|
||||
#define CAN_SENSOR_1_OFFSET 3
|
||||
|
||||
class Logging;
|
||||
void processCanRxMessage(const CANRxFrame& msg, Logging* logger);
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ static void printPacket(const CANRxFrame& rx, Logging* logger) {
|
|||
|
||||
volatile float aemXSeriesLambda = 0;
|
||||
volatile float canPedal = 0;
|
||||
volatile float canMap = 0;
|
||||
|
||||
void processCanRxMessage(const CANRxFrame& frame, Logging* logger) {
|
||||
// TODO: if/when we support multiple lambda sensors, sensor N
|
||||
|
@ -35,9 +36,12 @@ void processCanRxMessage(const CANRxFrame& frame, Logging* logger) {
|
|||
// AEM x-series lambda sensor reports in 0.0001 lambda per bit
|
||||
uint16_t lambdaInt = SWAP_UINT16(frame.data16[0]);
|
||||
aemXSeriesLambda = 0.0001f * lambdaInt;
|
||||
} else if (frame.EID == 0x202) {
|
||||
} else if (frame.EID == CONFIG(verboseCanBaseAddress) + CAN_PEDAL_TPS_OFFSET) {
|
||||
int16_t pedalScaled = *reinterpret_cast<const uint16_t*>(&frame.data8[0]);
|
||||
canPedal = pedalScaled * 0.01f;
|
||||
canPedal = pedalScaled / (1.0 * PACK_MULT_PERCENT);
|
||||
} else if (frame.EID == CONFIG(verboseCanBaseAddress) + CAN_SENSOR_1_OFFSET) {
|
||||
int16_t mapScaled = *reinterpret_cast<const uint16_t*>(&frame.data8[0]);
|
||||
canMap = mapScaled / (1.0 * PACK_MULT_PRESSURE);
|
||||
} else {
|
||||
printPacket(frame, logger);
|
||||
obdOnCanPacketRx(frame);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "scaled_channel.h"
|
||||
#include "can_msg_tx.h"
|
||||
#include "sensor.h"
|
||||
#include "can.h"
|
||||
#include "allsensors.h"
|
||||
#include "fuel_math.h"
|
||||
#include "spark_logic.h"
|
||||
|
@ -137,8 +138,8 @@ void sendCanVerbose() {
|
|||
|
||||
transmitStruct<Status> (base + 0);
|
||||
transmitStruct<Speeds> (base + 1);
|
||||
transmitStruct<PedalAndTps> (base + 2);
|
||||
transmitStruct<Sensors1> (base + 3);
|
||||
transmitStruct<PedalAndTps> (base + CAN_PEDAL_TPS_OFFSET);
|
||||
transmitStruct<Sensors1> (base + CAN_SENSOR_1_OFFSET);
|
||||
transmitStruct<Sensors2> (base + 4);
|
||||
transmitStruct<Fueling> (base + 5);
|
||||
}
|
||||
|
|
|
@ -124,6 +124,8 @@ struct_no_prefix engine_configuration_s
|
|||
#define BOOST_LOAD_COUNT 8
|
||||
#define PEDAL_TO_TPS_SIZE 8
|
||||
|
||||
#define CAN_DEFAULT_BASE 0x200
|
||||
|
||||
|
||||
!
|
||||
! all the xxx_PACKING_xxx constants are about persisting tables in compact for, for example packing RPM with 50 increment in a byte
|
||||
|
|
Loading…
Reference in New Issue