diff options
Diffstat (limited to 'devicemon.erl')
-rw-r--r-- | devicemon.erl | 9 |
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 |