summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--rose.erl15
-rw-r--r--status.erl5
-rw-r--r--tda.erl21
4 files changed, 32 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index b71a468..effc6c5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,6 @@
ASN1 = ACSE-1.asn1 \
CSTA-application-context-information-csta3.asn1 \
+ CSTA-system-status.asn1 \
Remote-Operations-Generic-ROS-PDUs.asn1 \
KME-specific-types.asn1 \
CSTA-device-identifiers.asn1 \
@@ -15,6 +16,7 @@ all: $(SRCS)
%.erl: lib/%.asn1
erlc $<
+ erlc $@
clean:
rm -f $(SRCS) $(HDRS) *.beam *.asn1db
diff --git a/rose.erl b/rose.erl
index 51a1ec9..093b372 100644
--- a/rose.erl
+++ b/rose.erl
@@ -1,16 +1,23 @@
-module(rose).
--export([decode/1, encode/3, dispatch/1]).
+-export([decode/1, return/3, invoke/3, dispatch/1]).
-include("Remote-Operations-Generic-ROS-PDUs.hrl").
decode(Msg) -> 'Remote-Operations-Generic-ROS-PDUs':decode('ROS', Msg).
-encode(Id, Op, Msg) -> 'Remote-Operations-Generic-ROS-PDUs':encode('ROS',
+return(Id, Op, Msg) -> 'Remote-Operations-Generic-ROS-PDUs':encode('ROS',
{returnResult, #'ReturnResult'{invokeId = Id,
result = #'ReturnResult_result'{opcode = Op, result = Msg}}}).
+invoke(Id, Op, Msg) -> 'Remote-Operations-Generic-ROS-PDUs':encode('ROS',
+ {invoke, #'Invoke'{invokeId = Id, opcode = Op, argument = Msg}}).
+
dispatch({invoke, #'Invoke'{invokeId = Id, opcode = Op}}) ->
case Op of
- {local, 211} -> encode(Id, Op, <<5,0>>)
- end.
+ {local, 211} ->
+ {ok, Status} = status:status(),
+ return(Id, Op, Status);
+ {local, 51} -> ok
+ end;
+dispatch({returnResult, #'ReturnResult'{result = #'ReturnResult_result'{result = Msg}}}) -> {result, Msg}.
diff --git a/status.erl b/status.erl
new file mode 100644
index 0000000..8cd01dd
--- /dev/null
+++ b/status.erl
@@ -0,0 +1,5 @@
+-module(status).
+-export([status/0]).
+
+status() ->
+ 'CSTA-system-status':encode('SystemStatusRes', {noData, []}).
diff --git a/tda.erl b/tda.erl
index 293fb32..7578bb8 100644
--- a/tda.erl
+++ b/tda.erl
@@ -8,10 +8,10 @@
-define(HOST, "192.168.240.20").
-define(PORT, 33333).
-start() -> register(tda_client, spawn(?MODULE, client, [{dial, ?HOST, ?PORT}])).
+start() -> register(tdaPid, spawn(?MODULE, client, [{dial, ?HOST, ?PORT}])).
-stop() -> tda_client ! {logout}.
-ext() -> tda_client ! {ext}.
+stop() -> tdaPid ! {logout}.
+ext() -> tdaPid ! {ext}.
client({dial, Host, Port}) ->
io:format("Dial ~p:~p~n", [Host, Port]),
@@ -21,7 +21,7 @@ client({dial, Host, Port}) ->
client(Conn);
client({ok, Sock}) ->
io:format("Connected~n", []),
- tda_client ! {login},
+ tdaPid ! {login},
loop(Sock);
client({error, Reason}) ->
io:format("Error: ~p~n", [Reason]),
@@ -44,7 +44,8 @@ loop(Sock) ->
{ext} ->
io:format("Request Ext lines~n", []),
{ok, Ext} = csta:ext_lines(),
- {ok, Rq} = rose:encode({present, 10}, {local, 51}, Ext),
+ {ok, Rq} = rose:invoke({present, 2}, {local, 51}, Ext),
+ io:format("Send: ~p~n", [Rq]),
gen_tcp:send(Sock, Rq),
loop(Sock);
{tcp, Sock, Msg} ->
@@ -67,8 +68,14 @@ decode(Sock, Msg) ->
rose ->
{ok, Rose} = rose:decode(Msg),
io:format("ROSE> ~p~n", [Rose]),
- {ok, Result} = rose:dispatch(Rose),
- gen_tcp:send(Sock, Result);
+ case rose:dispatch(Rose) of
+ {ok, Result} ->
+ gen_tcp:send(Sock, Result);
+ {result, Msg} ->
+ io:format("Result: ~p~n", [Msg]),
+ ok;
+ {ok} -> ok
+ end;
acse ->
{ok, Acse} = acse:decode(Msg),
io:format("ACSE> ~p~n", [Acse]),