Barionet 500 IO
Callback and direct access functions for the digital inputs and outputs of the Barionet 500
Library
barionet-io.lua
Functions
Initialisation
dio = require "barionet-io.lua"
Set Output
dio.setio(function, value)
function: IO pin (1,2,3,4 for the relays)
value: 0 or 1 for off/on
Get Input Value
x = dio.iostate(function)
function: IO pin (201,202,203,204 for the digital inputs)
return value: 0 (off) or 1 (on)
Start monitoring (for callback)
dio.start(tim,iocallback)
tim: poll time for the io (in ms)
iocallback: function to be called when an input changes its value
Callback Function
This function is called from the background when an input has changed
iocallback(function,val) -- this is the function you have to give to the start monitoring call
function: is the input address which changes
val: is the new value of the input pin
Example program
x
local uv = require 'luv'
local dio = require 'barionet-io'
function iocallback(adr,val)
print(string.format("io callback adr %u val %u",adr,val))
dio.setio(adr-200,val)
end
dio.start(100,iocallback)
uv.run();