Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib/support/drivers/temp.lua
blob: 09ffe9f436778b6440cef036381d51222ef8bceb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
local device = _G

api={}
api.getTemp = {}
api.getTemp.parameters = {} -- -- no input parameters
api.getTemp.returns = {[1]={rname="par1", rtype="int"}} 
api.getTemp.call = function ()
	device:send(string.char(0x00)) -- codigo de operacion 0
	local sen_anl_response = device:read(3) 
	local raw_val	
	if not sen_anl_response or string.byte(sen_anl_response or "00000000", 2) == nil or string.byte(sen_anl_response or "00000000", 3) == nil
	then 
		raw_val = "nil value"
	else
		raw_val = string.byte(sen_anl_response, 2)* 256 + string.byte(sen_anl_response, 3)

		local aux = (raw_val * 500) / 1024  --- obtengo la temperatura en grados

                if aux > 180 then
                	raw_val = (raw_val * 45) / 1024 
                else 
			raw_val = aux
		end
                
	end	
	return raw_val 
	
end