N73
This commit is contained in:
parent
8120182151
commit
dc824f0c42
|
@ -5,6 +5,18 @@
|
|||
return (data[offset + 2] * 256 + data[offset + 1]) * factor \
|
||||
end"
|
||||
|
||||
|
||||
#define GET_BIT_RANGE "function getBitRange(data, bitIndex, bitWidth) \
|
||||
byteIndex = bitIndex >> 3 \
|
||||
shift = bitIndex - byteIndex * 8 \
|
||||
value = data[1 + byteIndex] \
|
||||
if (shift + bitIndex > 8) then \
|
||||
value = value + data[2 + byteIndex] * 256 \
|
||||
end \
|
||||
mask = (1 << bitWidth) - 1 \
|
||||
return (value >> shift) & mask \
|
||||
end"
|
||||
|
||||
// https://github.com/HeinrichG-V12/E65_ReverseEngineering/blob/main/docs/0x3B4.md
|
||||
TEST(LuaE65, Battery) {
|
||||
const char* realdata = TWO_BYTES R"(
|
||||
|
@ -52,6 +64,18 @@ TEST(LuaE65, gear) {
|
|||
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(realdata).value_or(0), 8);
|
||||
}
|
||||
|
||||
TEST(LuaE65, gearTorque) {
|
||||
const char* realdata = GET_BIT_RANGE R"(
|
||||
|
||||
function testFunc()
|
||||
data = {0x9F, 0x01, 0x32, 0x20, 0x23, 0x30, 0xFF, 0x43}
|
||||
return getBitRange(data, 12, 12)
|
||||
end)";
|
||||
|
||||
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(realdata).value_or(0), 800);
|
||||
}
|
||||
|
||||
|
||||
TEST(LuaE65, sumChecksum) {
|
||||
// checksum is first byte
|
||||
// id = A8, packet:
|
||||
|
|
Loading…
Reference in New Issue