more CAN verbose (#4402)

* add stuff

* don't read invalid value
This commit is contained in:
Matthew Kennedy 2022-08-01 12:27:06 -07:00 committed by GitHub
parent 517dee57f4
commit ed5f1b3d57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 9 deletions

View File

@ -525,11 +525,11 @@ static void updateLambda() {
static void updateFuelSensors() {
// Low pressure is directly in kpa
engine->outputChannels.lowFuelPressure = Sensor::get(SensorType::FuelPressureLow).value_or(0);
engine->outputChannels.lowFuelPressure = Sensor::getOrZero(SensorType::FuelPressureLow);
// High pressure is in bar, aka 100 kpa
engine->outputChannels.highFuelPressure = KPA2BAR(Sensor::get(SensorType::FuelPressureHigh).value_or(0));
engine->outputChannels.highFuelPressure = KPA2BAR(Sensor::getOrZero(SensorType::FuelPressureHigh));
engine->outputChannels.flexPercent = Sensor::get(SensorType::FuelEthanolPercent).value_or(0);
engine->outputChannels.flexPercent = Sensor::getOrZero(SensorType::FuelEthanolPercent);
engine->outputChannels.fuelTankLevel = Sensor::getOrZero(SensorType::FuelLevel);
}
@ -582,10 +582,10 @@ static void updateRawSensors() {
static void updatePressures() {
engine->outputChannels.baroPressure = Sensor::getOrZero(SensorType::BarometricPressure);
engine->outputChannels.MAPValue = Sensor::getOrZero(SensorType::Map);
engine->outputChannels.oilPressure = Sensor::get(SensorType::OilPressure).value_or(0);
engine->outputChannels.oilPressure = Sensor::getOrZero(SensorType::OilPressure);
engine->outputChannels.auxLinear1 = Sensor::get(SensorType::AuxLinear1).value_or(0);
engine->outputChannels.auxLinear2 = Sensor::get(SensorType::AuxLinear2).value_or(0);
engine->outputChannels.auxLinear1 = Sensor::getOrZero(SensorType::AuxLinear1);
engine->outputChannels.auxLinear2 = Sensor::getOrZero(SensorType::AuxLinear2);
}
static void updateMiscSensors() {

View File

@ -49,7 +49,7 @@ struct Speeds {
scaled_channel<uint8_t, 2> injDuty;
scaled_channel<uint8_t, 2> coilDuty;
scaled_channel<uint8_t> vssKph;
uint8_t pad[1];
uint8_t EthanolPercent;
};
static void populateFrame(Speeds& msg) {
@ -63,6 +63,8 @@ static void populateFrame(Speeds& msg) {
msg.coilDuty = getCoilDutyCycle(rpm);
msg.vssKph = Sensor::getOrZero(SensorType::VehicleSpeed);
msg.EthanolPercent = Sensor::getOrZero(SensorType::FuelEthanolPercent);
}
struct PedalAndTps {
@ -106,9 +108,9 @@ static void populateFrame(Sensors1& msg) {
}
struct Sensors2 {
scaled_afr afr;
scaled_afr afr; // deprecated
scaled_pressure oilPressure;
scaled_angle vvtPos;
scaled_angle vvtPos; // deprecated
scaled_voltage vbatt;
};
@ -150,6 +152,44 @@ static void populateFrame(Fueling2& msg) {
}
}
struct Fueling3 {
scaled_channel<uint16_t, 10000> Lambda;
scaled_channel<uint16_t, 10000> Lambda2;
scaled_channel<int16_t, 30> FuelPressureLow;
scaled_channel<int16_t, 10> FuelPressureHigh;
};
static void populateFrame(Fueling3& msg) {
msg.Lambda = Sensor::getOrZero(SensorType::Lambda1);
msg.Lambda2 = Sensor::getOrZero(SensorType::Lambda2);
msg.FuelPressureLow = Sensor::getOrZero(SensorType::FuelPressureLow);
msg.FuelPressureHigh = KPA2BAR(Sensor::getOrZero(SensorType::FuelPressureHigh));
}
struct Cams {
int8_t Bank1IntakeActual;
int8_t Bank1IntakeTarget;
int8_t Bank1ExhaustActual;
int8_t Bank1ExhaustTarget;
int8_t Bank2IntakeActual;
int8_t Bank2IntakeTarget;
int8_t Bank2ExhaustActual;
int8_t Bank2ExhaustTarget;
};
static void populateFrame(Cams& msg) {
msg.Bank1IntakeActual = engine->triggerCentral.getVVTPosition(0, 0);
msg.Bank1ExhaustActual = engine->triggerCentral.getVVTPosition(0, 1);
msg.Bank2IntakeActual = engine->triggerCentral.getVVTPosition(1, 0);
msg.Bank2ExhaustActual = engine->triggerCentral.getVVTPosition(1, 1);
// TODO: maybe don't rely on outputChannels here
msg.Bank1IntakeTarget = engine->outputChannels.vvtTargets[0];
msg.Bank1ExhaustTarget = engine->outputChannels.vvtTargets[1];
msg.Bank2IntakeTarget = engine->outputChannels.vvtTargets[2];
msg.Bank2ExhaustTarget = engine->outputChannels.vvtTargets[3];
}
void sendCanVerbose() {
auto base = engineConfiguration->verboseCanBaseAddress;
auto isExt = engineConfiguration->rusefiVerbose29b;
@ -161,6 +201,8 @@ void sendCanVerbose() {
transmitStruct<Sensors2> (CanCategory::VERBOSE, base + 4, isExt);
transmitStruct<Fueling> (CanCategory::VERBOSE, base + 5, isExt);
transmitStruct<Fueling2> (CanCategory::VERBOSE, base + 6, isExt);
transmitStruct<Fueling3> (CanCategory::VERBOSE, base + 7, isExt);
transmitStruct<Cams> (CanCategory::VERBOSE, base + 8, isExt);
}
#endif // EFI_CAN_SUPPORT