only:kia CAN
This commit is contained in:
parent
1ac874bc72
commit
24763c4a62
|
@ -123,4 +123,15 @@ function setBitRange(data, totalBitIndex, bitWidth, value) \
|
||||||
end \
|
end \
|
||||||
"
|
"
|
||||||
|
|
||||||
|
#define HYUNDAI_SUM_NIBBLES "\
|
||||||
|
function hyuindaiSumNibbles(seed) \
|
||||||
|
local sum = seed \
|
||||||
|
for i = 1, 7, 1 \
|
||||||
|
do \
|
||||||
|
b = data[i] \
|
||||||
|
sum = sum + (b % 16) + math.floor(b / 16) \
|
||||||
|
end \
|
||||||
|
return (16 - sum) % 16 \
|
||||||
|
end \
|
||||||
|
"
|
||||||
|
|
||||||
|
|
|
@ -29,3 +29,13 @@ rpm = 990
|
||||||
)"
|
)"
|
||||||
).value_or(0), 0);
|
).value_or(0), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(LuaKia, calcSumOfNibbles) {
|
||||||
|
#define real81Packet "\ndata = { 0x40, 0x85, 0x5F, 0x00, 0x00, 0x00, 0x00, 0xED}\n "
|
||||||
|
const char* script = HYUNDAI_SUM_NIBBLES real81Packet R"(
|
||||||
|
function testFunc()
|
||||||
|
return hyuindaiSumNibbles(0xD)
|
||||||
|
end
|
||||||
|
)";
|
||||||
|
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(script).value_or(0), 0xE);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue