ECU to Mainline DynoLog Data Protocol #4319

This commit is contained in:
rusefillc 2022-08-12 23:53:48 -04:00
parent 37881f0076
commit 69d582a674
5 changed files with 41 additions and 12 deletions

View File

@ -0,0 +1,23 @@
DYNOLOG_BASE = 0x680
setTickRate(5) -- set tick rate to 5hz
protocolPacket = { 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
protocolBase1 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
function setTwoBytesMsb(data, offset, value)
value = math.floor(value)
data[offset + 1] = value >> 8
data[offset + 2] = value & 0xff
end
function onTick()
local RPM = getSensor("RPM")
local MAP = getSensor("MAP")
local TPS = getSensor("TPS1")
local IAT = getSensor("IAT")
txCan(1, DYNOLOG_BASE + 0, 0, protocolPacket)
end

View File

@ -14,10 +14,27 @@
end \
"
// LSB (Least Significant Byte comes first) "Intel"
#define TWO_BYTES_LSB "function getTwoBytesLSB(data, offset, factor) \
return (data[offset + 2] * 256 + data[offset + 1]) * factor \
end"
// Little-endian System, "Intel"
#define SET_TWO_BYTES " function setTwoBytes(data, offset, value) \
value = math.floor(value) \
data[offset + 2] = value >> 8 \
data[offset + 1] = value & 0xff \
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"
#define SET_TWO_BYTES_MSB " function setTwoBytesMsb(data, offset, value) \
value = math.floor(value) \
data[offset + 1] = value >> 8 \
data[offset + 2] = value & 0xff \
end \
"

View File

@ -12,12 +12,6 @@
return checksum \
end "
// LSB (Least Significant Byte comes first)
#define TWO_BYTES_LSB "function getTwoBytesLSB(data, offset, factor) \
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 \

View File

@ -2,12 +2,6 @@
#include "rusefi_lua.h"
#include "lua_lib.h"
// 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"
TEST(LuaFordFocusII, PPS_low) {
const char* realdata = TWO_BYTES_MSB R"(

View File

@ -19,6 +19,7 @@ TEST(LuaVag, Checksum) {
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(realdata).value_or(0), 0x60);
}
// LSB (Least Significant Byte comes first) "Intel"
TEST(LuaVag, packMotor1) {
const char* realdata = ARRAY_EQUALS SET_TWO_BYTES R"(