From d9514d447955a86d8fc17a9fbfb7ab5bffde0575 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sun, 19 Jun 2022 20:06:03 -0400 Subject: [PATCH] B6 shutdown Lua and else --- firmware/config/engines/vw_b6.cpp | 30 +++++++++++++++++++++++++++ firmware/controllers/can/can_dash.cpp | 1 + 2 files changed, 31 insertions(+) diff --git a/firmware/config/engines/vw_b6.cpp b/firmware/config/engines/vw_b6.cpp index ef4441a288..5eed80c0ab 100644 --- a/firmware/config/engines/vw_b6.cpp +++ b/firmware/config/engines/vw_b6.cpp @@ -82,6 +82,7 @@ static void commonPassatB6() { gppwm_channel *coolantControl = &engineConfiguration->gppwm[0]; strcpy(engineConfiguration->gpPwmNote[0], "Rad Fan"); + coolantControl->loadAxis = GPPWM_Clt; coolantControl->pwmFrequency = 25; coolantControl->loadAxis = GPPWM_FuelLoad; @@ -125,6 +126,35 @@ static void commonPassatB6() { engineConfiguration->useETBforIdleControl = true; engineConfiguration->injectionMode = IM_SEQUENTIAL; engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL; + + strncpy(config->luaScript, R"( +canRxAdd(0x050) + +shallSleep = Timer.new(); + +-- we want to turn on with hardware switch while ignition key is off +hadIgnitionEvent = false; + +function onCanRx(bus, id, dlc, data) + print('got CAN id=' ..id ..' dlc=' ..dlc) + id11 = id % 2048 + if id11 == 0x050 then + -- looks like we have ignition key do not sleep! + shallSleep:reset(); + hadIgnitionEvent = true; + end +end + +function onTick() + + if hadIgnitionEvent and shallSleep:getElapsedSeconds() > 3 then + -- looks like ignition key was removed + mcu_standby() + end +end + +)", efi::size(config->luaScript)); +#endif } /** diff --git a/firmware/controllers/can/can_dash.cpp b/firmware/controllers/can/can_dash.cpp index 08eb862640..8ac14ed2db 100644 --- a/firmware/controllers/can/can_dash.cpp +++ b/firmware/controllers/can/can_dash.cpp @@ -230,6 +230,7 @@ void canDashboardFiat(CanCycle cycle) { void canDashboardVAG(CanCycle cycle) { if (cycle.isInterval(CI::_10ms)) { { + // https://github.com/commaai/opendbc/blob/57c8340a180dd8c75139b18050eb17c72c9cb6e4/vw_golf_mk4.dbc#L394 //VAG Dashboard CanTxMessage msg(CanCategory::NBC, CAN_VAG_Motor_1); msg.setShortValue(Sensor::getOrZero(SensorType::Rpm) * 4, 2); //RPM