summaryrefslogtreecommitdiff
path: root/devicemon.erl
diff options
context:
space:
mode:
authorJoe Zhao <ztuowen@gmail.com>2014-06-09 20:24:43 +0800
committerJoe Zhao <ztuowen@gmail.com>2014-06-09 20:24:43 +0800
commit9adcb32af31d22a046881f5d690d068e232be773 (patch)
treecb18e4a25e1313946326cfbfe23b6f2d6aed288b /devicemon.erl
parent6b768801841204ad2a173470201dbcc98bbd9aa6 (diff)
downloadlocal-9adcb32af31d22a046881f5d690d068e232be773.tar.gz
local-9adcb32af31d22a046881f5d690d068e232be773.tar.bz2
local-9adcb32af31d22a046881f5d690d068e232be773.zip
Comments & maintenance
Diffstat (limited to 'devicemon.erl')
-rw-r--r--devicemon.erl9
1 files changed, 7 insertions, 2 deletions
diff --git a/devicemon.erl b/devicemon.erl
index 703dca5..d56043b 100644
--- a/devicemon.erl
+++ b/devicemon.erl
@@ -18,7 +18,10 @@
%% API
%% -export([]).
+%% @todo This module is not fault-safe, abrupt death will halt all operations
+
-define(QTOUT,100).
+-define(STNULL,[0,255,0,0,0]).
cleanloop() ->
%% Cleanup the message queue -> Don't call it
@@ -56,8 +59,10 @@ deviceloop(Devices) ->
Pid ! {self(),comm,orddict:fold(fun(Key,Val,Acc) -> [Key,Val#device.type]++Val#device.state++Acc end, [],Devices)},
deviceloop(Devices);
{Pid,comm,[0,Addr]} -> % Specific query, this also shouldn't happen.
- Dev=orddict:fetch(Addr,Devices),
- Pid ! {self(),comm,[Dev#device.type]++Dev#device.state},
+ case orddict:find(Addr,Devices) of
+ error -> Pid ! {self(),comm,[Addr]++?STNULL};
+ {ok,Value} -> Pid ! {self(),comm,[Addr,Value#device.type]++Value#device.state}
+ end,
deviceloop(Devices);
%% Messages received from rsbus