summaryrefslogtreecommitdiff
path: root/Remote-Operations-Generic-ROS-PDUs.erl
diff options
context:
space:
mode:
Diffstat (limited to 'Remote-Operations-Generic-ROS-PDUs.erl')
-rw-r--r--Remote-Operations-Generic-ROS-PDUs.erl392
1 files changed, 392 insertions, 0 deletions
diff --git a/Remote-Operations-Generic-ROS-PDUs.erl b/Remote-Operations-Generic-ROS-PDUs.erl
index 63d06ea..1e8eb90 100644
--- a/Remote-Operations-Generic-ROS-PDUs.erl
+++ b/Remote-Operations-Generic-ROS-PDUs.erl
@@ -17,6 +17,10 @@
legacy_erlang_types/0]).
-export(['dialyzer-suppressions'/1]).
-export([
+'enc_ROS'/2,
+'enc_Invoke'/2,
+'enc_ReturnResult'/2,
+'enc_ReturnError'/2,
'enc_Reject'/2,
'enc_GeneralProblem'/2,
'enc_InvokeProblem'/2,
@@ -27,6 +31,10 @@
]).
-export([
+'dec_ROS'/2,
+'dec_Invoke'/2,
+'dec_ReturnResult'/2,
+'dec_ReturnError'/2,
'dec_Reject'/2,
'dec_GeneralProblem'/2,
'dec_InvokeProblem'/2,
@@ -79,6 +87,10 @@ try decode_disp(Type, element(1, ber_decode_nif(Data))) of
end
end.
+encode_disp('ROS',Data) -> 'enc_ROS'(Data);
+encode_disp('Invoke',Data) -> 'enc_Invoke'(Data);
+encode_disp('ReturnResult',Data) -> 'enc_ReturnResult'(Data);
+encode_disp('ReturnError',Data) -> 'enc_ReturnError'(Data);
encode_disp('Reject',Data) -> 'enc_Reject'(Data);
encode_disp('GeneralProblem',Data) -> 'enc_GeneralProblem'(Data);
encode_disp('InvokeProblem',Data) -> 'enc_InvokeProblem'(Data);
@@ -89,6 +101,10 @@ encode_disp('InvokeId',Data) -> 'enc_InvokeId'(Data);
encode_disp(Type,_Data) -> exit({error,{asn1,{undefined_type,Type}}}).
+decode_disp('ROS',Data) -> 'dec_ROS'(Data);
+decode_disp('Invoke',Data) -> 'dec_Invoke'(Data);
+decode_disp('ReturnResult',Data) -> 'dec_ReturnResult'(Data);
+decode_disp('ReturnError',Data) -> 'dec_ReturnError'(Data);
decode_disp('Reject',Data) -> 'dec_Reject'(Data);
decode_disp('GeneralProblem',Data) -> 'dec_GeneralProblem'(Data);
decode_disp('InvokeProblem',Data) -> 'dec_InvokeProblem'(Data);
@@ -116,6 +132,367 @@ info() ->
%%================================
+%% ROS
+%%================================
+'enc_ROS'(Val) ->
+ 'enc_ROS'(Val, []).
+
+'enc_ROS'(Val, TagIn) ->
+ {EncBytes,EncLen} = case element(1,Val) of
+ invoke ->
+ 'enc_Invoke'(element(2,Val), [<<161>>]);
+ returnResult ->
+ 'enc_ReturnResult'(element(2,Val), [<<162>>]);
+ returnError ->
+ 'enc_ReturnError'(element(2,Val), [<<163>>]);
+ reject ->
+ 'enc_Reject'(element(2,Val), [<<164>>]);
+ Else ->
+ exit({error,{asn1,{invalid_choice_type,Else}}})
+ end,
+
+encode_tags(TagIn, EncBytes, EncLen).
+
+
+
+
+'dec_ROS'(Tlv) ->
+ 'dec_ROS'(Tlv, []).
+
+'dec_ROS'(Tlv, TagIn) ->
+Tlv1 = match_tags(Tlv, TagIn),
+case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
+
+%% 'invoke'
+ {131073, V1} ->
+ {invoke, 'dec_Invoke'(V1, [])};
+
+
+%% 'returnResult'
+ {131074, V1} ->
+ {returnResult, 'dec_ReturnResult'(V1, [])};
+
+
+%% 'returnError'
+ {131075, V1} ->
+ {returnError, 'dec_ReturnError'(V1, [])};
+
+
+%% 'reject'
+ {131076, V1} ->
+ {reject, 'dec_Reject'(V1, [])};
+
+ Else ->
+ exit({error,{asn1,{invalid_choice_tag,Else}}})
+ end
+.
+
+
+%%================================
+%% Invoke
+%%================================
+'enc_Invoke'(Val) ->
+ 'enc_Invoke'(Val, [<<48>>]).
+
+'enc_Invoke'(Val, TagIn) ->
+{_,Cindex1, Cindex2, Cindex3, Cindex4} = Val,
+
+%%-------------------------------------------------
+%% attribute invokeId(1) External Remote-Operations-Generic-ROS-PDUs:InvokeId
+%%-------------------------------------------------
+ {EncBytes1,EncLen1} = 'enc_InvokeId'(Cindex1, []),
+
+%%-------------------------------------------------
+%% attribute linkedId(2) with type CHOICE OPTIONAL
+%%-------------------------------------------------
+ {EncBytes2,EncLen2} = case Cindex2 of
+ asn1_NOVALUE -> {<<>>,0};
+ _ ->
+ 'enc_Invoke_linkedId'(Cindex2, [])
+ end,
+
+%%-------------------------------------------------
+%% attribute opcode(3) External Remote-Operations-Information-Objects:Code
+%%-------------------------------------------------
+ {EncBytes3,EncLen3} = 'Remote-Operations-Information-Objects':'enc_Code'(Cindex3, []),
+
+%%-------------------------------------------------
+%% attribute argument(4) with type ASN1_OPEN_TYPE OPTIONAL
+%%-------------------------------------------------
+ {EncBytes4,EncLen4} = case Cindex4 of
+ asn1_NOVALUE -> {<<>>,0};
+ _ ->
+ encode_open_type(Cindex4, [])
+ end,
+
+ BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
+LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
+encode_tags(TagIn, BytesSoFar, LenSoFar).
+
+
+
+%%================================
+%% Invoke_linkedId
+%%================================
+'enc_Invoke_linkedId'(Val, TagIn) ->
+ {EncBytes,EncLen} = case element(1,Val) of
+ present ->
+ encode_integer(element(2,Val), [<<128>>]);
+ absent ->
+ encode_null(element(2,Val), [<<129>>]);
+ Else ->
+ exit({error,{asn1,{invalid_choice_type,Else}}})
+ end,
+
+encode_tags(TagIn, EncBytes, EncLen).
+
+
+
+
+'dec_Invoke'(Tlv) ->
+ 'dec_Invoke'(Tlv, [16]).
+
+'dec_Invoke'(Tlv, TagIn) ->
+ %%-------------------------------------------------
+ %% decode tag and length
+ %%-------------------------------------------------
+Tlv1 = match_tags(Tlv, TagIn),
+
+%%-------------------------------------------------
+%% attribute invokeId(1) External Remote-Operations-Generic-ROS-PDUs:InvokeId
+%%-------------------------------------------------
+[V1|Tlv2] = Tlv1,
+Term1 = 'dec_InvokeId'(V1, []),
+
+%%-------------------------------------------------
+%% attribute linkedId(2) with type CHOICE OPTIONAL
+%%-------------------------------------------------
+{Term2,Tlv3} = case Tlv2 of
+[V2 = {131072,_}|TempTlv3] ->
+ {'dec_Invoke_linkedId'(V2, []), TempTlv3};
+[V2 = {131073,_}|TempTlv3] ->
+ {'dec_Invoke_linkedId'(V2, []), TempTlv3};
+ _ ->
+ { asn1_NOVALUE, Tlv2}
+end,
+
+%%-------------------------------------------------
+%% attribute opcode(3) External Remote-Operations-Information-Objects:Code
+%%-------------------------------------------------
+[V3|Tlv4] = Tlv3,
+Term3 = 'Remote-Operations-Information-Objects':'dec_Code'(V3, []),
+
+%%-------------------------------------------------
+%% attribute argument(4) with type ASN1_OPEN_TYPE OPTIONAL
+%%-------------------------------------------------
+{Term4,Tlv5} = case Tlv4 of
+[V4|TempTlv5] ->
+ {decode_open_type_as_binary(V4, []), TempTlv5};
+ _ ->
+ { asn1_NOVALUE, Tlv4}
+end,
+
+case Tlv5 of
+[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed
+end,
+ {'Invoke', Term1, Term2, Term3, Term4}.
+
+'dec_Invoke_linkedId'(Tlv, TagIn) ->
+Tlv1 = match_tags(Tlv, TagIn),
+case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
+
+%% 'present'
+ {131072, V1} ->
+ {present, decode_integer(V1, [])};
+
+
+%% 'absent'
+ {131073, V1} ->
+ {absent, decode_null(V1, [])};
+
+ Else ->
+ exit({error,{asn1,{invalid_choice_tag,Else}}})
+ end
+.
+
+
+%%================================
+%% ReturnResult
+%%================================
+'enc_ReturnResult'(Val) ->
+ 'enc_ReturnResult'(Val, [<<48>>]).
+
+'enc_ReturnResult'(Val, TagIn) ->
+{_,Cindex1, Cindex2} = Val,
+
+%%-------------------------------------------------
+%% attribute invokeId(1) External Remote-Operations-Generic-ROS-PDUs:InvokeId
+%%-------------------------------------------------
+ {EncBytes1,EncLen1} = 'enc_InvokeId'(Cindex1, []),
+
+%%-------------------------------------------------
+%% attribute result(2) with type SEQUENCE OPTIONAL
+%%-------------------------------------------------
+ {EncBytes2,EncLen2} = case Cindex2 of
+ asn1_NOVALUE -> {<<>>,0};
+ _ ->
+ 'enc_ReturnResult_result'(Cindex2, [<<48>>])
+ end,
+
+ BytesSoFar = [EncBytes1, EncBytes2],
+LenSoFar = EncLen1 + EncLen2,
+encode_tags(TagIn, BytesSoFar, LenSoFar).
+
+
+
+%%================================
+%% ReturnResult_result
+%%================================
+'enc_ReturnResult_result'(Val, TagIn) ->
+ {_,Cindex1, Cindex2} = Val,
+
+%%-------------------------------------------------
+%% attribute opcode(1) External Remote-Operations-Information-Objects:Code
+%%-------------------------------------------------
+ {EncBytes1,EncLen1} = 'Remote-Operations-Information-Objects':'enc_Code'(Cindex1, []),
+
+%%-------------------------------------------------
+%% attribute result(2) with type ASN1_OPEN_TYPE
+%%-------------------------------------------------
+ {EncBytes2,EncLen2} = encode_open_type(Cindex2, []),
+
+ BytesSoFar = [EncBytes1, EncBytes2],
+LenSoFar = EncLen1 + EncLen2,
+encode_tags(TagIn, BytesSoFar, LenSoFar).
+
+
+'dec_ReturnResult'(Tlv) ->
+ 'dec_ReturnResult'(Tlv, [16]).
+
+'dec_ReturnResult'(Tlv, TagIn) ->
+ %%-------------------------------------------------
+ %% decode tag and length
+ %%-------------------------------------------------
+Tlv1 = match_tags(Tlv, TagIn),
+
+%%-------------------------------------------------
+%% attribute invokeId(1) External Remote-Operations-Generic-ROS-PDUs:InvokeId
+%%-------------------------------------------------
+[V1|Tlv2] = Tlv1,
+Term1 = 'dec_InvokeId'(V1, []),
+
+%%-------------------------------------------------
+%% attribute result(2) with type SEQUENCE OPTIONAL
+%%-------------------------------------------------
+{Term2,Tlv3} = case Tlv2 of
+[{16,V2}|TempTlv3] ->
+ {'dec_ReturnResult_result'(V2, []), TempTlv3};
+ _ ->
+ { asn1_NOVALUE, Tlv2}
+end,
+
+case Tlv3 of
+[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
+end,
+ {'ReturnResult', Term1, Term2}.
+
+'dec_ReturnResult_result'(Tlv, TagIn) ->
+ %%-------------------------------------------------
+ %% decode tag and length
+ %%-------------------------------------------------
+Tlv1 = match_tags(Tlv, TagIn),
+
+%%-------------------------------------------------
+%% attribute opcode(1) External Remote-Operations-Information-Objects:Code
+%%-------------------------------------------------
+[V1|Tlv2] = Tlv1,
+Term1 = 'Remote-Operations-Information-Objects':'dec_Code'(V1, []),
+
+%%-------------------------------------------------
+%% attribute result(2) with type ASN1_OPEN_TYPE
+%%-------------------------------------------------
+[V2|Tlv3] = Tlv2,
+Term2 = decode_open_type_as_binary(V2, []),
+
+case Tlv3 of
+[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
+end,
+ {'ReturnResult_result', Term1, Term2}.
+
+
+
+%%================================
+%% ReturnError
+%%================================
+'enc_ReturnError'(Val) ->
+ 'enc_ReturnError'(Val, [<<48>>]).
+
+'enc_ReturnError'(Val, TagIn) ->
+{_,Cindex1, Cindex2, Cindex3} = Val,
+
+%%-------------------------------------------------
+%% attribute invokeId(1) External Remote-Operations-Generic-ROS-PDUs:InvokeId
+%%-------------------------------------------------
+ {EncBytes1,EncLen1} = 'enc_InvokeId'(Cindex1, []),
+
+%%-------------------------------------------------
+%% attribute errcode(2) External Remote-Operations-Information-Objects:Code
+%%-------------------------------------------------
+ {EncBytes2,EncLen2} = 'Remote-Operations-Information-Objects':'enc_Code'(Cindex2, []),
+
+%%-------------------------------------------------
+%% attribute parameter(3) with type ASN1_OPEN_TYPE OPTIONAL
+%%-------------------------------------------------
+ {EncBytes3,EncLen3} = case Cindex3 of
+ asn1_NOVALUE -> {<<>>,0};
+ _ ->
+ encode_open_type(Cindex3, [])
+ end,
+
+ BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
+LenSoFar = EncLen1 + EncLen2 + EncLen3,
+encode_tags(TagIn, BytesSoFar, LenSoFar).
+
+
+'dec_ReturnError'(Tlv) ->
+ 'dec_ReturnError'(Tlv, [16]).
+
+'dec_ReturnError'(Tlv, TagIn) ->
+ %%-------------------------------------------------
+ %% decode tag and length
+ %%-------------------------------------------------
+Tlv1 = match_tags(Tlv, TagIn),
+
+%%-------------------------------------------------
+%% attribute invokeId(1) External Remote-Operations-Generic-ROS-PDUs:InvokeId
+%%-------------------------------------------------
+[V1|Tlv2] = Tlv1,
+Term1 = 'dec_InvokeId'(V1, []),
+
+%%-------------------------------------------------
+%% attribute errcode(2) External Remote-Operations-Information-Objects:Code
+%%-------------------------------------------------
+[V2|Tlv3] = Tlv2,
+Term2 = 'Remote-Operations-Information-Objects':'dec_Code'(V2, []),
+
+%%-------------------------------------------------
+%% attribute parameter(3) with type ASN1_OPEN_TYPE OPTIONAL
+%%-------------------------------------------------
+{Term3,Tlv4} = case Tlv3 of
+[V3|TempTlv4] ->
+ {decode_open_type_as_binary(V3, []), TempTlv4};
+ _ ->
+ { asn1_NOVALUE, Tlv3}
+end,
+
+case Tlv4 of
+[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed
+end,
+ {'ReturnError', Term1, Term2, Term3}.
+
+
+
+%%================================
%% Reject
%%================================
'enc_Reject'(Val) ->
@@ -398,6 +775,13 @@ case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
ber_decode_nif(B) ->
asn1rt_nif:decode_ber_tlv(B).
+ber_encode([Tlv]) ->
+ ber_encode(Tlv);
+ber_encode(Tlv) when is_binary(Tlv) ->
+ Tlv;
+ber_encode(Tlv) ->
+ asn1rt_nif:encode_ber_tlv(Tlv).
+
decode_integer(Tlv, TagIn) ->
Bin = match_tags(Tlv, TagIn),
Len = byte_size(Bin),
@@ -413,6 +797,9 @@ decode_null(Tlv, Tags) ->
exit({error,{asn1,{decode_null,Val}}})
end.
+decode_open_type_as_binary(Tlv, TagIn) ->
+ ber_encode(match_tags(Tlv, TagIn)).
+
encode_integer(Val) ->
Bytes =
if
@@ -463,6 +850,11 @@ encode_length(L) ->
encode_null(_Val, TagIn) ->
encode_tags(TagIn, [], 0).
+encode_open_type(Val, T) when is_list(Val) ->
+ encode_open_type(list_to_binary(Val), T);
+encode_open_type(Val, Tag) ->
+ encode_tags(Tag, Val, byte_size(Val)).
+
encode_tags(TagIn, {BytesSoFar,LenSoFar}) ->
encode_tags(TagIn, BytesSoFar, LenSoFar).