diff options
Diffstat (limited to 'cmdiface.erl')
-rw-r--r-- | cmdiface.erl | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/cmdiface.erl b/cmdiface.erl new file mode 100644 index 0000000..0b7e84c --- /dev/null +++ b/cmdiface.erl @@ -0,0 +1,40 @@ +%%%------------------------------------------------------------------- +%%% @author Joe Zhao +%%% @copyright (C) 2014, <COMPANY> +%%% @doc +%%% +%%% @end +%%% Created : 10. May 2014 下午9:20 +%%%------------------------------------------------------------------- +-module(cmdiface). +-author("Joe Zhao"). + +-compile([debug_info,export_all]). + +%% API +%%-export([]). + +reg_feedbackOps(Addr,Name,T,MsgReq,MsgRes,To) -> + io:format("Logging new command: ~p ~n",[Name]), + Init=fun () -> rsbusserv ! {devicemon,Addr,MsgReq} end, + Exit= + fun () -> + rsbusserv ! {devicemon,Addr,[]} + end, + Pid = spawn(?MODULE,res_manip,[Init,Exit,To]), + Call = + fun () -> + Pid ! rsbusserv:rsbusreq(Addr,MsgRes) + end, + eventserv:reg_future(Call,T). + +invoke_cmd(Addr,Name,MsgReq) -> + io:format("Command: ~p ~n",[Name]), + rsbusserv! {devicemon,comm,Addr,MsgReq}. + +res_manip(Init,Exit,To) -> + Init(), + receive + Res -> To ! Res + end, + Exit().
\ No newline at end of file |