extract method

This commit is contained in:
Andrey 2021-12-27 21:09:28 -05:00
parent c516d95525
commit ae5dbd63a4
1 changed files with 13 additions and 4 deletions

View File

@ -36,11 +36,20 @@ TEST(LuaE65, sumChecksum) {
const char* realdata = R"(
function testFunc()
canID = 0xA8
data = { 0xAD, 0x05, 0xA0, 0x05, 0x0F, 0x00, 0x02 }
checksum = data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7] + canID
function bmwChecksum(canID, data, offset, length)
checksum = canID
for i = offset, offset + length - 1,1
do
checksum = checksum + data[i]
end
checksum = math.floor (checksum / 0x100) + (checksum & 0xff)
return checksum
end
function testFunc()
canID = 0xA8
data = { 0xAD, 0x05, 0xA0, 0x05, 0x0F, 0x00, 0x02 }
checksum = bmwChecksum(canID, data, 1, 7)
return checksum;
end)";