summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-10-23 20:04:10 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-10-23 20:04:10 +0200
commit0838872bfca4d28a99109010ef84d72fe2046597 (patch)
tree82bf4415ae2037e0d97eae0ca00e3af023b40193
parent97a86ed6adb02f1cd78eda0bb9ae11974046becb (diff)
Add pdu
-rw-r--r--tda.erl19
1 files changed, 18 insertions, 1 deletions
diff --git a/tda.erl b/tda.erl
index 3d1b60f..e3b45cc 100644
--- a/tda.erl
+++ b/tda.erl
@@ -4,6 +4,7 @@
-export([release_request/0, release_result/1]).
-export([associate_abort/1]).
-export([system_status/0, system_status/1]).
+-export([pdu/1, strip/1]).
-include("acse.hrl").
-include("rose.hrl").
@@ -42,10 +43,19 @@ associate_abort(Bin) ->
% <<162,11,2,1,1,48,6,2,2,0,211,5,0>>
system_status(Bin) ->
case rose:decode('ROS', Bin) of
- {ok, {invoke, Invoke}} -> Invoke;
+ {ok, {invoke, Invoke}} ->
+ {id(Invoke), opcode(Invoke), arg(Invoke)};
{error, Reason} -> Reason
end.
+opcode(#'Invoke'{opcode = {local, Opcode}}) -> Opcode;
+opcode(Any) -> {local, Any}.
+
+id(#'Invoke'{invokeId = {present, Id}}) -> Id;
+id(Any) -> {present, Any}.
+
+arg(#'Invoke'{argument = Arg}) -> Arg.
+
system_status() ->
RR = #'ReturnResult_result'{opcode = {local, 211}, result = <<5,0>>},
R = #'ReturnResult'{invokeId = {present, 1}, result = RR},
@@ -54,3 +64,10 @@ system_status() ->
{ok, Invoke} -> Invoke;
{error, Reason} -> Reason
end.
+
+pdu(<<Bits/binary>>) ->
+ Len = byte_size(Bits),
+ Head = <<Len:16/big>>,
+ <<Head/binary, Bits/binary>>.
+
+strip(<<_:16/big, Rest/binary>>) -> Rest.