parent
b5fd4c5759
commit
bf3b0d61d6
|
@ -77,7 +77,7 @@ void setHyundaiPb() {
|
|||
#endif // HW_PROTEUS
|
||||
|
||||
#if HW_PROTEUS
|
||||
strncpy(config->luaScript, TWO_BYTES_LSB PRINT_ARRAY SET_TWO_BYTES HYUNDAI_SUM_NIBBLES R"(
|
||||
strncpy(config->luaScript, TWO_BYTES_LSB PRINT_ARRAY SET_TWO_BYTES_LSB HYUNDAI_SUM_NIBBLES R"(
|
||||
|
||||
GDI4_BASE_ADDRESS = 0xBB20
|
||||
GDI_CHANGE_ADDRESS = GDI4_BASE_ADDRESS + 0x10
|
||||
|
@ -146,9 +146,7 @@ function onTick()
|
|||
txCan(1, GDI_CHANGE_ADDRESS + 3, 1, data_set_settings)
|
||||
|
||||
setTwoBytesLsb(data_set_settings, 1, pumpHoldCurrent * FIXED_POINT)
|
||||
outputCanID = 0
|
||||
outputCanID = GDI4_BASE_ADDRESS
|
||||
setTwoBytesLsb(data_set_settings, 3, outputCanID)
|
||||
setTwoBytesLsb(data_set_settings, 3, GDI4_BASE_ADDRESS)
|
||||
print('Will be sending ' ..arrayToString(data_set_settings))
|
||||
txCan(1, GDI_CHANGE_ADDRESS + 4, 1, data_set_settings)
|
||||
|
||||
|
|
|
@ -56,26 +56,26 @@ function arrayToString(arr) \
|
|||
local index = 1 \
|
||||
while arr[index] ~= nil do \
|
||||
str = str..\" \"..toHexString(math.floor(arr[index])) \
|
||||
index = index + 1 \
|
||||
end \
|
||||
return str \
|
||||
end \
|
||||
\
|
||||
index = index + 1\
|
||||
end\
|
||||
return str\
|
||||
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"
|
||||
#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) \n\
|
||||
data[offset + 2] = value >> 8 \n\
|
||||
data[offset + 1] = value & 0xff \n\
|
||||
#define SET_TWO_BYTES_LSB " function setTwoBytesLsb(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) \
|
||||
|
@ -87,8 +87,8 @@ end \
|
|||
value = math.floor(value) \
|
||||
data[offset + 1] = value >> 8 \
|
||||
data[offset + 2] = value & 0xff \
|
||||
end \
|
||||
"
|
||||
end\
|
||||
"
|
||||
|
||||
// one day we shall get Preprocessor macros with C++11 raw string literals
|
||||
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55971
|
||||
|
@ -132,6 +132,6 @@ function hyuindaiSumNibbles(data, seed) \n\
|
|||
sum = sum + (b % 16) + math.floor(b / 16) \
|
||||
end \
|
||||
return (16 - sum) % 16 \
|
||||
end \
|
||||
end\
|
||||
"
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ TEST(LuaKia, idleRpm1) {
|
|||
|
||||
TEST(LuaKia, packRpm) {
|
||||
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(
|
||||
TWO_BYTES_MSB ARRAY_EQUALS SET_TWO_BYTES PRINT_ARRAY R"(
|
||||
TWO_BYTES_MSB ARRAY_EQUALS SET_TWO_BYTES_LSB PRINT_ARRAY R"(
|
||||
rpm = 990
|
||||
function testFunc()
|
||||
canEngine = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
|
|
|
@ -33,7 +33,7 @@ TEST(LuaVag, Checksum) {
|
|||
|
||||
// LSB (Least Significant Byte comes first) "Intel"
|
||||
TEST(LuaVag, packMotor1) {
|
||||
const char* realdata = PRINT_ARRAY ARRAY_EQUALS SET_TWO_BYTES R"(
|
||||
const char* realdata = PRINT_ARRAY ARRAY_EQUALS SET_TWO_BYTES_LSB R"(
|
||||
|
||||
function testFunc()
|
||||
engineTorque = 15.21
|
||||
|
@ -134,7 +134,7 @@ TEST(LuaVag, unpackMotor1_torq_req) {
|
|||
#define realMotor3Packet "\ndata = { 0x00, 0x62, 0xFA, 0xDA, 0x22, 0x00, 0x00, 0xFA}\n "
|
||||
|
||||
TEST(LuaVag, packMotor3) {
|
||||
const char* script = SET_BIT_RANGE_LSB PRINT_ARRAY ARRAY_EQUALS SET_TWO_BYTES R"(
|
||||
const char* script = SET_BIT_RANGE_LSB PRINT_ARRAY ARRAY_EQUALS SET_TWO_BYTES_LSB R"(
|
||||
|
||||
function testFunc()
|
||||
tps = 100
|
||||
|
|
Loading…
Reference in New Issue