[spid + fsync] add support for commit command

This commit is contained in:
Bart Van Der Meerssche 2011-02-12 12:36:53 +01:00
parent 849c671175
commit 7fba026ddb
3 changed files with 14 additions and 1 deletions

View File

@ -154,6 +154,14 @@ function tx(msg, cdev)
end
end
function wait(msg, short, long)
if msg.parsed.cmd and msg.parsed.cmd == 'ct' then
nixio.nanosleep(0, long)
else
nixio.nanosleep(0, short)
end
end
function rx(msg, cdev)
local hextonum = nixio.bin.hextonum

View File

@ -111,6 +111,7 @@ local SET_ENABLE = 'se %d %d'
local SET_PHY_TO_LOG = 'sp' -- with [1..MAX_SENSORS] arguments
local SET_METERCONST = 'sm %d %d'
local SET_COUNTER = 'sc %d %d'
local COMMIT = 'ct'
-- check hardware version
local hw_major, hw_minor = send(ctrl, GET_HW_VERSION):match(GET_HW_VERSION_R)
@ -216,6 +217,10 @@ for i = 1, MAX_SENSORS do
end
end
-- commit changes
send(ctrl, COMMIT)
-- clean up
ctrl.fdin:close()
ctrl.fdout:close()

View File

@ -111,7 +111,7 @@ while true do
msg:encode()
msg:tx(spidev)
nixio.nanosleep(0, SPI_TX_RX_DELAY_NS)
msg:wait(SPI_TX_RX_DELAY_NS, SPI_CT_DELAY_NS)
end
if poll >= 0 then