mirror of https://github.com/FOME-Tech/fome-fw.git
nissan
This commit is contained in:
parent
d0478250ff
commit
f32ae379f5
|
@ -1,6 +1,9 @@
|
||||||
// by definition this should be a copy-paste of https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/examples/350z-ac.txt
|
// by definition this should be a copy-paste of https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/examples/350z-ac.txt
|
||||||
strncpy(config->luaScript, R"(
|
strncpy(config->luaScript, R"(
|
||||||
canRxAdd(0x35d)
|
|
||||||
|
IN_284 = 0x284 -- 644
|
||||||
|
IN_285 = 0x285
|
||||||
|
IN_35D = 0x35d
|
||||||
|
|
||||||
OUT_1F9 = 0x1F9 -- 505
|
OUT_1F9 = 0x1F9 -- 505
|
||||||
OUT_233 = 0x233 -- 563
|
OUT_233 = 0x233 -- 563
|
||||||
|
@ -13,6 +16,10 @@ t : reset()
|
||||||
|
|
||||||
globalAcOut = 0
|
globalAcOut = 0
|
||||||
|
|
||||||
|
function getTwoBytesMSB(data, offset, factor)
|
||||||
|
return (data[offset + 1] * 256 + data[offset + 2]) * factor
|
||||||
|
end
|
||||||
|
|
||||||
function onTick()
|
function onTick()
|
||||||
local MAF = getSensor("MAF")
|
local MAF = getSensor("MAF")
|
||||||
MAF = (MAF == nil and 0 or MAF)
|
MAF = (MAF == nil and 0 or MAF)
|
||||||
|
@ -81,8 +88,11 @@ function onTick()
|
||||||
-- print('CLT temp' ..cltValue)
|
-- print('CLT temp' ..cltValue)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function onCanRxAbs1(bus, id, dlc, data)
|
||||||
|
kph = getTwoBytesMSB(data, 0, 0.005)
|
||||||
|
end
|
||||||
|
|
||||||
function onCanRx(bus, id, dlc, data)
|
function onCanRxAc(bus, id, dlc, data)
|
||||||
--print('got CAN id=' ..id ..' dlc=' ..dlc)
|
--print('got CAN id=' ..id ..' dlc=' ..dlc)
|
||||||
--print('ac value is= '..data[1])
|
--print('ac value is= '..data[1])
|
||||||
if data[1] == 193 then
|
if data[1] == 193 then
|
||||||
|
@ -96,4 +106,8 @@ function onCanRx(bus, id, dlc, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
canRxAdd(IN_35D, onCanRxAbs1)
|
||||||
|
canRxAdd(IN_35D, onCanRxAc)
|
||||||
|
|
||||||
)", efi::size(config->luaScript));
|
)", efi::size(config->luaScript));
|
||||||
|
|
|
@ -83,7 +83,10 @@ static time_msecs_t mph_ctr;
|
||||||
#define NISSAN_VEHICLE_SPEED_280 0x280
|
#define NISSAN_VEHICLE_SPEED_280 0x280
|
||||||
// wheel speed see "102 CAN Communication decoded"
|
// wheel speed see "102 CAN Communication decoded"
|
||||||
// 19500 value would be 100 kph
|
// 19500 value would be 100 kph
|
||||||
#define NISSAN_WHEEL_SPEED 0x285
|
// 644
|
||||||
|
#define NISSAN_WHEEL_SPEED1 0x284
|
||||||
|
// 645
|
||||||
|
#define NISSAN_WHEEL_SPEED2 0x285
|
||||||
|
|
||||||
// 670
|
// 670
|
||||||
#define NISSAN_UNKNOWN_4 0x29E
|
#define NISSAN_UNKNOWN_4 0x29E
|
||||||
|
|
|
@ -2,6 +2,14 @@
|
||||||
#include "rusefi_lua.h"
|
#include "rusefi_lua.h"
|
||||||
#include "lua_lib.h"
|
#include "lua_lib.h"
|
||||||
|
|
||||||
TEST(LuaNissan, pedalIdle) {
|
TEST(LuaNissan, wheelSpeed) {
|
||||||
|
#define realWheelPacket "\ndata = { 0x19, 0x6c, 0x19, 0x68, 0x0e, 0xb0, 0x37, 0x81}\n "
|
||||||
|
const char* script = TWO_BYTES_MSB realWheelPacket R"(
|
||||||
|
function testFunc()
|
||||||
|
engineTorque = getTwoBytesMSB(data, 0, 0.005)
|
||||||
|
return engineTorque
|
||||||
|
end
|
||||||
|
)";
|
||||||
|
|
||||||
|
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(script).value_or(0), 32.54);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue