From 0838872bfca4d28a99109010ef84d72fe2046597 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 23 Oct 2015 20:04:10 +0200 Subject: Add pdu --- tda.erl | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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(<>) -> + Len = byte_size(Bits), + Head = <>, + <>. + +strip(<<_:16/big, Rest/binary>>) -> Rest. -- cgit v1.2.3