send voltage and heater enable to WBO controller (#2956)

* add info send function

* fatal if CAN not configured correctly

* build

* s

* 20hz

* update wideband firmware

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2021-07-13 04:32:41 -07:00 committed by GitHub
parent dd095404bc
commit e3ed413e06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 38 additions and 10 deletions

1
.gitmodules vendored
View File

@ -21,6 +21,7 @@
[submodule "firmware/controllers/can/wideband_firmware"]
path = firmware/controllers/can/wideband_firmware
url = https://github.com/mck1117/wideband
branch = master
[submodule "firmware/ext/uzlib"]
path = firmware/ext/uzlib
url = https://github.com/pfalcon/uzlib

View File

@ -46,7 +46,7 @@
#include "microsecond_timer.h"
#if EFI_WIDEBAND_FIRMWARE_UPDATE
#include "can.h"
#include "rusefi_wideband.h"
#endif // EFI_WIDEBAND_FIRMWARE_UPDATE
#if EFI_PROD_CODE

View File

@ -45,13 +45,6 @@ void processCanRxMessage(const CANRxFrame& msg, efitick_t nowNt);
void registerCanListener(CanListener& listener);
void registerCanSensor(CanSensorBase& sensor);
// Indicate that an ack response was received from the wideband bootloader
void handleWidebandBootloaderAck();
// Update the firmware on any connected wideband controller
void updateWidebandFirmware();
// Set the CAN index offset of any attached wideband controller
void setWidebandOffset(uint8_t index);
class CanWrite final : public PeriodicController<512> {
public:
CanWrite();

View File

@ -59,6 +59,7 @@ bool acceptCanRx(int sid DECLARE_ENGINE_PARAMETER_SUFFIX) {
#include "engine.h"
#include "can_sensor.h"
#include "can_vss.h"
#include "rusefi_wideband.h"
/**
* this build-in CAN sniffer is very basic but that's our CAN sniffer

View File

@ -17,6 +17,7 @@
#include "obd2.h"
#include "can_sensor.h"
#include "thread_priority.h"
#include "rusefi_wideband.h"
EXTERN_ENGINE;
@ -57,6 +58,10 @@ void CanWrite::PeriodicTask(efitime_t nowNt) {
updateDash(cycle);
if (CONFIG(enableAemXSeries) && cycle.isInterval(CI::_50ms)) {
sendWidebandInfo();
}
cycleCount++;
}

View File

@ -4,6 +4,8 @@
#include "ch.h"
#include "can_msg_tx.h"
#include "rusefi_wideband.h"
#include "sensor.h"
// This file contains an array called build_wideband_noboot_bin
// This array contains the firmware image for the wideband contoller
@ -119,4 +121,15 @@ void setWidebandOffset(uint8_t index) {
waitingBootloaderThread = nullptr;
}
void sendWidebandInfo() {
CanTxMessage m(0xEF5'0000, 2, true);
float vbatt = Sensor::get(SensorType::BatteryVoltage).value_or(0) * 10;
m[0] = vbatt;
// TODO: send real enable bit!
m[1] = 0x1;
}
#endif // EFI_WIDEBAND_FIRMWARE_UPDATE && HAL_USE_CAN

View File

@ -0,0 +1,10 @@
#pragma once
// Indicate that an ack response was received from the wideband bootloader
void handleWidebandBootloaderAck();
// Update the firmware on any connected wideband controller
void updateWidebandFirmware();
// Set the CAN index offset of any attached wideband controller
void setWidebandOffset(uint8_t index);
// Send info to the wideband controller like battery voltage, heater enable bit, etc.
void sendWidebandInfo();

@ -1 +1 @@
Subproject commit 158be23b578423328eb3ab5907eb09698f2359f0
Subproject commit 902be081e7c8f89516edc133aada5564abcb9bff

View File

@ -45,7 +45,7 @@ CONTROLLERS_SRC_CPP = \
$(CONTROLLERS_DIR)/can/obd2.cpp \
$(CONTROLLERS_DIR)/can/can_verbose.cpp \
$(CONTROLLERS_DIR)/can/can_rx.cpp \
$(CONTORLLERS_DIR)/can/wideband_bootloader.cpp \
$(CONTORLLERS_DIR)/can/rusefi_wideband.cpp \
$(CONTROLLERS_DIR)/can/can_tx.cpp \
$(CONTROLLERS_DIR)/can/can_dash.cpp \
$(CONTROLLERS_DIR)/can/can_vss.cpp \

View File

@ -34,6 +34,11 @@ void initLambda(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if EFI_CAN_SUPPORT
if (CONFIG(enableAemXSeries)) {
if (!CONFIG(canWriteEnabled) || !CONFIG(canReadEnabled)) {
firmwareError(OBD_PCM_Processor_Fault, "CAN read and write are required to use CAN wideband.");
return;
}
registerCanSensor(aem1);
registerCanSensor(aem2);