Herunterladen Diese Seite drucken

Beispiel 16.5. I2C-Lua-Scriptbeispiel Sequence - Optelec ClearNote HD Bedienungsanleitung

Vorschau ausblenden Andere Handbücher für ClearNote HD:

Werbung

LS_I2CWriteDigital(nHandle, 0)
LS_I2CCloseDevice(nHandle)
end
Beispiel 16.4. I2C - Lua Scriptbeispiel I2C-Direkt
3. Beispiel
• Sequenz an Anagate I2C Device senden
--**************************************************
local function printf(...)
io.write(string.format(...))
io.flush()
end
--**************************************************
function main()
local aSendData = {}
for i = 1, 128, 1 do
table.insert(aSendData, i-1)
end
local nRC, nHandle = LS_I2COpenDevice(1000000, "10.1.2.162", 5000)
if nRC ~= 0 then
print(LS_I2CErrorMessage(nRC))
os.exit()
end
--Sequence
local aData = {0xa2, 0x00,
0x02, 0x00,
0x00, 0x00,
0xa3, 0x00,
0x30, 0x00,
0xa3, 0x00,
0x20, 0x00}
local CountRead, LastError, Value
nRC, CountRead, LastError, Value = LS_I2CSequence(nHandle, aData, #aData, 0x0050)
printf("CountRead:%02X
for i, v in ipairs(Value) do
printf("%02X ", v)
end
printf("\n")
LS_I2CWriteDigital(nHandle, 0)
LS_I2CCloseDevice(nHandle)
end

Beispiel 16.5. I2C-Lua-Scriptbeispiel Sequence

Lua-Programmier-Beispiele
--SLA
--Laenge Schreibkommando
--Daten Schreibkommando
--SLA 1. Lesekommando
--Laenge 1. Lesekommando
--SLA 2. Lesekommando
--Laenge 2. Lesekommando
LastError:%02X\n", CountRead, LastError)
171
© 2007-2015 Analytica GmbH

Werbung

loading