microRusEFI used as Body Control Module BCM BCU

This commit is contained in:
rusefi 2020-09-06 23:19:32 -04:00
parent c6c0bcbd1a
commit b04a4ec04c
3 changed files with 17 additions and 17 deletions

View File

@ -467,7 +467,7 @@ extern HIP9011 instance;
void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ENGINE_PARAMETER_SUFFIX) { void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ENGINE_PARAMETER_SUFFIX) {
#if EFI_SHAFT_POSITION_INPUT #if EFI_SHAFT_POSITION_INPUT
int rpm = GET_RPM(); int rpm = Sensor::get(SensorType::Rpm).Value;
#else /* EFI_SHAFT_POSITION_INPUT */ #else /* EFI_SHAFT_POSITION_INPUT */
int rpm = 0; int rpm = 0;
#endif /* EFI_SHAFT_POSITION_INPUT */ #endif /* EFI_SHAFT_POSITION_INPUT */

View File

@ -79,11 +79,11 @@ private:
const uint8_t m_offset; const uint8_t m_offset;
}; };
template <typename TStorage, int TScale> template <int Size, int TScale>
class ObdCanSensor: public CanSensorBase { class ObdCanSensor: public CanSensorBase {
public: public:
ObdCanSensor(uint32_t eid, int PID, SensorType type, efitick_t timeout) : ObdCanSensor(int PID, SensorType type, efitick_t timeout) :
CanSensorBase(eid, type, timeout) { CanSensorBase(OBD_TEST_RESPONSE, type, timeout) {
this->PID = PID; this->PID = PID;
} }
@ -91,15 +91,16 @@ public:
if (frame.data8[2] != PID) { if (frame.data8[2] != PID) {
return; return;
} }
// Compute the location of our data within the frame
const uint8_t* dataLocation = &frame.data8[0];
// Reinterpret as a scaled_channel - it already has the logic for decoding a scaled integer to a float int iValue;
const auto scaler = reinterpret_cast<const scaled_channel<TStorage, TScale>*>(dataLocation); if (Size == 2) {
iValue = frame.data8[3] * 256 + frame.data8[4];
} else {
iValue = frame.data8[3];
}
// Actually do the conversion float fValue = 1.0 * iValue / TScale;
float value = *scaler; setValidValue(fValue, nowNt);
setValidValue(value, nowNt);
} }
CanSensorBase* request() override { CanSensorBase* request() override {
@ -107,8 +108,7 @@ public:
CanTxMessage msg(OBD_TEST_REQUEST); CanTxMessage msg(OBD_TEST_REQUEST);
msg[0] = _OBD_2; msg[0] = _OBD_2;
msg[1] = OBD_CURRENT_DATA; msg[1] = OBD_CURRENT_DATA;
msg[2] = getEid(); msg[2] = PID;
} }
return m_next; return m_next;
} }

View File

@ -22,13 +22,13 @@ CanSensor<int16_t, PACK_MULT_PERCENT> canPedalSensor(
SensorType::AcceleratorPedal, TIMEOUT SensorType::AcceleratorPedal, TIMEOUT
); );
ObdCanSensor<int16_t, ODB_RPM_MULT> obdRpmSensor( ObdCanSensor<2, ODB_RPM_MULT> obdRpmSensor(
OBD_TEST_RESPONSE, PID_RPM, PID_RPM,
SensorType::Rpm, TIMEOUT SensorType::Rpm, TIMEOUT
); );
ObdCanSensor<int16_t, 1> obdCltSensor( ObdCanSensor<1, 1> obdCltSensor(
OBD_TEST_RESPONSE, PID_COOLANT_TEMP, PID_COOLANT_TEMP,
SensorType::Clt, TIMEOUT SensorType::Clt, TIMEOUT
); );