This commit is contained in:
parent
8ce57d5599
commit
954ddacd96
|
@ -77,7 +77,8 @@ end \
|
|||
// MOTOROLA order, MSB (Most Significant Byte/Big Endian) comes first.
|
||||
#define TWO_BYTES_MSB "function getTwoBytesMSB(data, offset, factor) \
|
||||
return (data[offset + 1] * 256 + data[offset + 2]) * factor \
|
||||
end"
|
||||
end \
|
||||
"
|
||||
|
||||
#define SET_TWO_BYTES_MSB " function setTwoBytesMsb(data, offset, value) \
|
||||
value = math.floor(value) \
|
||||
|
|
|
@ -38,6 +38,22 @@ TEST(LuaE38, tps) {
|
|||
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(script).value_or(0), 5.881);
|
||||
}
|
||||
|
||||
TEST(LuaE38, packECMEngineStatus) {
|
||||
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(
|
||||
TWO_BYTES_MSB ARRAY_EQUALS PRINT_ARRAY R"(
|
||||
tps = 5.881
|
||||
function testFunc()
|
||||
canEngine = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
canEngine[5] = tps / 0.3921
|
||||
|
||||
print(arrayToString(canEngine))
|
||||
expected = { 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00 }
|
||||
return equals(canEngine, expected)
|
||||
end
|
||||
)"
|
||||
).value_or(0), 0);
|
||||
}
|
||||
|
||||
#define ECMEngineCoolantTemp "\ndata = { 0x00, 0xCA, 0x69, 0x3F, 0x6A, 0x00, 0x00, 0x00}\n "
|
||||
|
||||
TEST(LuaE38, clt) {
|
||||
|
@ -51,3 +67,18 @@ TEST(LuaE38, clt) {
|
|||
).value_or(0), 65);
|
||||
}
|
||||
|
||||
TEST(LuaE38, packECMEngineCoolantTemp) {
|
||||
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(
|
||||
TWO_BYTES_MSB ARRAY_EQUALS PRINT_ARRAY R"(
|
||||
clt = 65
|
||||
function testFunc()
|
||||
canEngine = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
canEngine[3] = clt + 40
|
||||
|
||||
print(arrayToString(canEngine))
|
||||
expected = { 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
return equals(canEngine, expected)
|
||||
end
|
||||
)"
|
||||
).value_or(0), 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue