OBD CAN sensors #1733

This commit is contained in:
rusefi 2020-08-31 04:39:27 -04:00
parent 6a9cdec89f
commit f18f7741ca
3 changed files with 22 additions and 4 deletions

View File

@ -30,10 +30,10 @@ static void printPacket(const CANRxFrame& rx, Logging* logger) {
volatile float aemXSeriesLambda = 0;
volatile float canMap = 0;
static CanSensorBase* s_head = nullptr;
CanSensorBase* cansensors_head = nullptr;
void serviceCanSubscribers(const CANRxFrame& frame, efitick_t nowNt) {
CanSensorBase* current = s_head;
CanSensorBase* current = cansensors_head;
while (current) {
current = current->processFrame(frame, nowNt);
@ -41,8 +41,8 @@ void serviceCanSubscribers(const CANRxFrame& frame, efitick_t nowNt) {
}
void registerCanSensor(CanSensorBase& sensor) {
sensor.setNext(s_head);
s_head = &sensor;
sensor.setNext(cansensors_head);
cansensors_head = &sensor;
}
void processCanRxMessage(const CANRxFrame& frame, Logging* logger, efitick_t nowNt) {

View File

@ -15,9 +15,12 @@
#include "can_hw.h"
#include "can_dash.h"
#include "obd2.h"
#include "can_sensor.h"
EXTERN_ENGINE;
extern CanSensorBase* cansensors_head;
CanWrite::CanWrite()
: PeriodicController("CAN TX", NORMALPRIO, 50)
{
@ -31,6 +34,12 @@ void CanWrite::PeriodicTask(efitime_t nowNt) {
sendCanVerbose();
}
CanSensorBase* current = cansensors_head;
while (current) {
current = current->request();
}
// Transmit dash data, if enabled
switch (CONFIG(canNbcType)) {
case CAN_BUS_NBC_BMW:

View File

@ -22,6 +22,10 @@ public:
{
}
virtual CanSensorBase* request() {
return m_next;
}
void showInfo(Logging* logger, const char* sensorName) const override;
CanSensorBase* processFrame(const CANRxFrame& frame, efitick_t nowNt) {
@ -68,3 +72,8 @@ public:
private:
const uint8_t m_offset;
};
class ObdCanSensor : public CanSensorBase {
ObdCanSensor(SensorType type);
};