diff --git a/mote/v2/openwrt/package/flukso/luasrc/flukso/spi.lua b/mote/v2/openwrt/package/flukso/luasrc/flukso/spi.lua index 7855278..50faeb6 100644 --- a/mote/v2/openwrt/package/flukso/luasrc/flukso/spi.lua +++ b/mote/v2/openwrt/package/flukso/luasrc/flukso/spi.lua @@ -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 diff --git a/mote/v2/openwrt/package/flukso/luasrc/fsync.lua b/mote/v2/openwrt/package/flukso/luasrc/fsync.lua index 7bbe721..b20c09f 100755 --- a/mote/v2/openwrt/package/flukso/luasrc/fsync.lua +++ b/mote/v2/openwrt/package/flukso/luasrc/fsync.lua @@ -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() diff --git a/mote/v2/openwrt/package/flukso/luasrc/spid.lua b/mote/v2/openwrt/package/flukso/luasrc/spid.lua index 91895c9..9678910 100755 --- a/mote/v2/openwrt/package/flukso/luasrc/spid.lua +++ b/mote/v2/openwrt/package/flukso/luasrc/spid.lua @@ -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