BMW 6HP gatewy #3954
This commit is contained in:
parent
5d846b64e4
commit
0130933dd7
|
@ -175,7 +175,9 @@ function onCanRx(bus, id, dlc, data)
|
|||
print('CAN_BMW_E90_RPM_THROTTLE rpm=' .. rpm .. ' pedal=' .. pedal)
|
||||
|
||||
output = {0, 0, 0, data [1 + 3], data [1 + 4], data [1 + 5], 0, 0}
|
||||
|
||||
counterCAN_BMW_E90_RPM_THROTTLE = (counterCAN_BMW_E90_RPM_THROTTLE + 1) % 15
|
||||
output[2] = counterCAN_BMW_E90_RPM_THROTTLE
|
||||
output[1] = bmwChecksum(CAN_BMW_E90_RPM_THROTTLE, output, 2, 7)
|
||||
|
||||
relayToTcu(id, data)
|
||||
elseif id == CAN_BMW_E90_DSC_TORQUE_DEMAND then
|
||||
|
|
|
@ -15,6 +15,21 @@
|
|||
return (data[offset + 2] * 256 + data[offset + 1]) * factor \
|
||||
end"
|
||||
|
||||
#define ARRAY_EQUALS "function equals(data1, data2) \
|
||||
\
|
||||
local index = 1 \
|
||||
while data1[index] ~= nil do \
|
||||
if data1[index] ~= data1[index] then \
|
||||
return -1 - index \
|
||||
end \
|
||||
index = index + 1 \
|
||||
end \
|
||||
if nil ~= data2[index] then \
|
||||
return -1 - index \
|
||||
end \
|
||||
return 0 \
|
||||
end \
|
||||
"
|
||||
|
||||
#define GET_BIT_RANGE "function getBitRange(data, bitIndex, bitWidth) \
|
||||
byteIndex = bitIndex >> 3 \
|
||||
|
@ -74,6 +89,20 @@ TEST(LuaE65, gear) {
|
|||
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(realdata).value_or(0), 8);
|
||||
}
|
||||
|
||||
TEST(LuaE65, repackAA) {
|
||||
const char* realdata = ARRAY_EQUALS TWO_BYTES R"(
|
||||
|
||||
function testFunc()
|
||||
rpm = 673.75
|
||||
pedal = 50
|
||||
data = {0x58, 12, 14}
|
||||
expected = {0x58, 12, 14}
|
||||
return equals(data, expected)
|
||||
end)";
|
||||
|
||||
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(realdata).value_or(0), 0);
|
||||
}
|
||||
|
||||
TEST(LuaE65, gearTorque) {
|
||||
const char* realdata = GET_BIT_RANGE R"(
|
||||
|
||||
|
|
Loading…
Reference in New Issue