only:GDI lua
This commit is contained in:
parent
abf8ea8753
commit
68aba455fe
|
@ -1,3 +1,5 @@
|
||||||
|
-- scriptname gdi4-communication.lua
|
||||||
|
|
||||||
-- communication with https://github.com/rusefi/rusefi-hardware/tree/main/GDI-4ch/firmware
|
-- communication with https://github.com/rusefi/rusefi-hardware/tree/main/GDI-4ch/firmware
|
||||||
-- hpfpbench
|
-- hpfpbench
|
||||||
|
|
||||||
|
@ -7,31 +9,8 @@ busIndex = 1
|
||||||
GDI4_BASE_ADDRESS = 0xBB20
|
GDI4_BASE_ADDRESS = 0xBB20
|
||||||
GDI_CHANGE_ADDRESS = GDI4_BASE_ADDRESS + 0x10
|
GDI_CHANGE_ADDRESS = GDI4_BASE_ADDRESS + 0x10
|
||||||
|
|
||||||
hexstr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F" }
|
-- include print-array.lua
|
||||||
|
-- endinclude
|
||||||
function toHexString(num)
|
|
||||||
if num == 0 then
|
|
||||||
return '0'
|
|
||||||
end
|
|
||||||
|
|
||||||
local result = ""
|
|
||||||
while num > 0 do
|
|
||||||
local n = num % 16
|
|
||||||
result = hexstr[n + 1] ..result
|
|
||||||
num = math.floor(num / 16)
|
|
||||||
end
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
function arrayToString(arr)
|
|
||||||
local str = ""
|
|
||||||
local index = 1
|
|
||||||
while arr[index] ~= nil do
|
|
||||||
str = str.." "..toHexString(arr[index])
|
|
||||||
index = index + 1
|
|
||||||
end
|
|
||||||
return str
|
|
||||||
end
|
|
||||||
|
|
||||||
function printPacket(bus, id, dlc, data)
|
function printPacket(bus, id, dlc, data)
|
||||||
-- print('Received status packet ' ..arrayToString(data))
|
-- print('Received status packet ' ..arrayToString(data))
|
|
@ -1,31 +1,10 @@
|
||||||
|
-- scriptname gdi8-pressure-input.lua
|
||||||
|
|
||||||
sensor = Sensor.new("FuelPressureHigh")
|
sensor = Sensor.new("FuelPressureHigh")
|
||||||
sensor : setTimeout(1000)
|
sensor : setTimeout(1000)
|
||||||
|
|
||||||
hexstr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F" }
|
-- include print-array.lua
|
||||||
|
-- endinclude
|
||||||
function toHexString(num)
|
|
||||||
if num == 0 then
|
|
||||||
return '0'
|
|
||||||
end
|
|
||||||
|
|
||||||
local result = ""
|
|
||||||
while num > 0 do
|
|
||||||
local n = num % 16
|
|
||||||
result = hexstr[n + 1] ..result
|
|
||||||
num = math.floor(num / 16)
|
|
||||||
end
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
function arrayToString(arr)
|
|
||||||
local str = ""
|
|
||||||
local index = 1
|
|
||||||
while arr[index] ~= nil do
|
|
||||||
str = str.." "..toHexString(arr[index])
|
|
||||||
index = index + 1
|
|
||||||
end
|
|
||||||
return str
|
|
||||||
end
|
|
||||||
|
|
||||||
function getTwoBytesLSB(data, offset, factor)
|
function getTwoBytesLSB(data, offset, factor)
|
||||||
return (data[offset + 2] * 256 + data[offset + 1]) * factor
|
return (data[offset + 2] * 256 + data[offset + 1]) * factor
|
|
@ -0,0 +1,25 @@
|
||||||
|
hexstr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F" }
|
||||||
|
|
||||||
|
function toHexString(num)
|
||||||
|
if num == 0 then
|
||||||
|
return '0'
|
||||||
|
end
|
||||||
|
|
||||||
|
local result = ""
|
||||||
|
while num > 0 do
|
||||||
|
local n = num % 16
|
||||||
|
result = hexstr[n + 1] ..result
|
||||||
|
num = math.floor(num / 16)
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
function arrayToString(arr)
|
||||||
|
local str = ""
|
||||||
|
local index = 1
|
||||||
|
while arr[index] ~= nil do
|
||||||
|
str = str.." "..toHexString(arr[index])
|
||||||
|
index = index + 1
|
||||||
|
end
|
||||||
|
return str
|
||||||
|
end
|
Loading…
Reference in New Issue