diff options
Diffstat (limited to 'lib/support/drivers/hotplug/port.lua')
-rw-r--r-- | lib/support/drivers/hotplug/port.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/support/drivers/hotplug/port.lua b/lib/support/drivers/hotplug/port.lua new file mode 100644 index 0000000..331efb3 --- /dev/null +++ b/lib/support/drivers/hotplug/port.lua @@ -0,0 +1,19 @@ +local device = _G + +local RD_VERSION=string.char(0x00) +local string_byte=string.byte + +-- description: lets us know button module's version +api={} +api.getVersion = {} +api.getVersion.parameters = {} -- no input parameters +api.getVersion.returns = {[1]={rname="version", rtype="int"}} +api.getVersion.call = function () + device:send(RD_VERSION) -- operation code 0 = get version + local version_response = device:read(3) -- 3 bytes to read (opcode, data) + if not version_response or #version_response~=3 then return -1 end + local raw_val = (string_byte(version_response,2) or 0) + (string_byte(version_response,3) or 0)* 256 + return raw_val +end + + |