nissan BCM
This commit is contained in:
parent
7edbe65029
commit
965cdd466c
|
@ -38,8 +38,14 @@ function arrayToString(arr)
|
|||
return str
|
||||
end
|
||||
|
||||
function getTwoBytesLSB(data, offset, factor)
|
||||
return (data[offset + 2] * 256 + data[offset + 1]) * factor
|
||||
end
|
||||
|
||||
function onRpmData(bus, id, dlc, data)
|
||||
-- print('onRpmData ' ..arrayToString(data))
|
||||
rpm = getTwoBytesLSB(data, 3, 3.15)
|
||||
print ('RPM ' .. rpm)
|
||||
end
|
||||
|
||||
function onSpeedData(bus, id, dlc, data)
|
||||
|
|
|
@ -13,3 +13,15 @@ TEST(LuaNissan, wheelSpeed) {
|
|||
|
||||
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(script).value_or(0), 32.54);
|
||||
}
|
||||
|
||||
TEST(LuaNissan, rpm) {
|
||||
#define realRpmPacket "\ndata = { 0x63, 0x00, 0x00, 0x1B, 0x01, 0xCC, 0x00, 0x70}\n "
|
||||
const char* script = TWO_BYTES_LSB realRpmPacket R"(
|
||||
function testFunc()
|
||||
engineTorque = getTwoBytesLSB(data, 3, 3.15)
|
||||
return engineTorque
|
||||
end
|
||||
)";
|
||||
|
||||
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(script).value_or(0), 891.45);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue