E65
This commit is contained in:
parent
af1259c176
commit
561a466cdb
|
@ -14,6 +14,12 @@ void setEngineProteusBMW_N73_GDI() {
|
||||||
void setEngineProteusGearboxManInTheMiddle() {
|
void setEngineProteusGearboxManInTheMiddle() {
|
||||||
strncpy(config->luaScript, R"(
|
strncpy(config->luaScript, R"(
|
||||||
|
|
||||||
|
function twoBytes(data, offset, factor)
|
||||||
|
return (data[offset + 2] * 256 + data[offset + 1]) * factor
|
||||||
|
end
|
||||||
|
|
||||||
|
CAN_BMW_E90_TORQUE_1 = 0x0A8
|
||||||
|
CAN_BMW_E90_TORQUE_2 = 0x0A9
|
||||||
CAN_BMW_E90_RPM_THROTTLE = 0x0AA
|
CAN_BMW_E90_RPM_THROTTLE = 0x0AA
|
||||||
CAN_BMW_E90_TORQUE_DEMAND = 0x0B6
|
CAN_BMW_E90_TORQUE_DEMAND = 0x0B6
|
||||||
CAN_BMW_E90_IGNITION_KEY = 0x130
|
CAN_BMW_E90_IGNITION_KEY = 0x130
|
||||||
|
@ -57,6 +63,18 @@ function onCanRx(bus, id, dlc, data)
|
||||||
if id == CAN_BMW_E90_IGNITION_KEY then
|
if id == CAN_BMW_E90_IGNITION_KEY then
|
||||||
print('!!!!!!!!!!!!! CAN_BMW_E90_IGNITION_KEY')
|
print('!!!!!!!!!!!!! CAN_BMW_E90_IGNITION_KEY')
|
||||||
txCan(GEAR_BUS, id, 0, data) -- relay non-TCU message to TCU
|
txCan(GEAR_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||||
|
elseif id == CAN_BMW_E90_TORQUE_1 then
|
||||||
|
print('CAN_BMW_E90_TORQUE_1')
|
||||||
|
txCan(GEAR_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||||
|
elseif id == CAN_BMW_E90_TORQUE_2 then
|
||||||
|
print('CAN_BMW_E90_TORQUE_2')
|
||||||
|
txCan(GEAR_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||||
|
elseif id == CAN_BMW_E90_TORQUE_DEMAND then
|
||||||
|
print('CAN_BMW_E90_TORQUE_DEMAND')
|
||||||
|
txCan(GEAR_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||||
|
elseif id == CAN_BMW_E90_DASH_ON then
|
||||||
|
print('CAN_BMW_E90_DASH_ON')
|
||||||
|
txCan(GEAR_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||||
elseif id == CAN_BMW_E65_GEAR_SELECTOR then
|
elseif id == CAN_BMW_E65_GEAR_SELECTOR then
|
||||||
print('CAN_BMW_E65_GEAR_SELECTOR')
|
print('CAN_BMW_E65_GEAR_SELECTOR')
|
||||||
txCan(GEAR_BUS, id, 0, data) -- relay non-TCU message to TCU
|
txCan(GEAR_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||||
|
@ -64,7 +82,8 @@ function onCanRx(bus, id, dlc, data)
|
||||||
print('CAN_BMW_E65_GEAR_SELECTOR')
|
print('CAN_BMW_E65_GEAR_SELECTOR')
|
||||||
txCan(GEAR_BUS, id, 0, data) -- relay non-TCU message to TCU
|
txCan(GEAR_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||||
elseif id == CAN_BMW_E90_RPM_THROTTLE then
|
elseif id == CAN_BMW_E90_RPM_THROTTLE then
|
||||||
print('CAN_BMW_E90_RPM_THROTTLE 2')
|
rpm = twoBytes(data, 4, 0.25)
|
||||||
|
print('CAN_BMW_E90_RPM_THROTTLE ' .. rpm)
|
||||||
txCan(GEAR_BUS, id, 0, data) -- relay non-TCU message to TCU
|
txCan(GEAR_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||||
elseif id == CAN_BMW_E90_COOLANT then
|
elseif id == CAN_BMW_E90_COOLANT then
|
||||||
print('CAN_BMW_E90_COOLANT')
|
print('CAN_BMW_E90_COOLANT')
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
#define CAN_BMW_E90_GEARBOX_DATA_2 0x1A2
|
#define CAN_BMW_E90_GEARBOX_DATA_2 0x1A2
|
||||||
|
|
||||||
// Engine data
|
// Engine data
|
||||||
|
// https://github.com/HeinrichG-V12/E65_ReverseEngineering/blob/main/docs/0x1D0.md
|
||||||
#define CAN_BMW_E90_COOLANT 0x1D0
|
#define CAN_BMW_E90_COOLANT 0x1D0
|
||||||
// MECH Anzeige Getriebedaten
|
// MECH Anzeige Getriebedaten
|
||||||
#define CAN_BMW_E90_TRANSMISSION_DISP 0x1D2
|
#define CAN_BMW_E90_TRANSMISSION_DISP 0x1D2
|
||||||
|
@ -72,4 +73,5 @@
|
||||||
// MECH Getriebedaten 3 0x3B1
|
// MECH Getriebedaten 3 0x3B1
|
||||||
|
|
||||||
// https://www.loopybunny.co.uk/CarPC/can/3B4.html
|
// https://www.loopybunny.co.uk/CarPC/can/3B4.html
|
||||||
// Operating voltage #3B4
|
// Powermanagement Batteriespannung
|
||||||
|
#define CAN_BMW_E90_VOLTAGE 0x3B4
|
||||||
|
|
|
@ -1,20 +1,30 @@
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "rusefi_lua.h"
|
#include "rusefi_lua.h"
|
||||||
|
|
||||||
|
#define TWO_BYTES "function twoBytes(data, offset, factor) \
|
||||||
|
return (data[offset + 2] * 256 + data[offset + 1]) * factor \
|
||||||
|
end"
|
||||||
|
|
||||||
|
// https://github.com/HeinrichG-V12/E65_ReverseEngineering/blob/main/docs/0x3B4.md
|
||||||
TEST(LuaE65, Battery) {
|
TEST(LuaE65, Battery) {
|
||||||
const char* realdata = R"(
|
const char* realdata = TWO_BYTES R"(
|
||||||
function twoBytes(data, offset, factor)
|
|
||||||
return (data[offset + 1] * 256 + data[offset]) * factor
|
|
||||||
end
|
|
||||||
|
|
||||||
function testFunc()
|
function testFunc()
|
||||||
data = {0xdc, 0x03, 0x00, 0x53, 0xFE, 0xD3, 0x04, 0x00}
|
data = {0xdc, 0x03, 0x00, 0x53, 0xFE, 0xD3, 0x04, 0x00}
|
||||||
return twoBytes(data, 1, 0.0147)
|
return twoBytes(data, 0, 0.0147)
|
||||||
end
|
end)";
|
||||||
|
|
||||||
)";
|
|
||||||
|
|
||||||
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(realdata).value_or(0), 14.5236);
|
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(realdata).value_or(0), 14.5236);
|
||||||
|
}
|
||||||
|
|
||||||
|
// http://loopybunny.co.uk/CarPC/can/0AA.html
|
||||||
|
TEST(LuaE65, Rpm) {
|
||||||
|
const char* realdata = TWO_BYTES R"(
|
||||||
|
|
||||||
|
function testFunc()
|
||||||
|
data = {0x5F, 0x59, 0xFF, 0x00, 0x34, 0x0D, 0x80, 0x99}
|
||||||
|
return twoBytes(data, 4, 0.25)
|
||||||
|
end)";
|
||||||
|
|
||||||
|
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(realdata).value_or(0), 845);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue