RAW decoding with variant "TAG" doesn't work [message #1842000] |
Mon, 07 June 2021 01:20 |
Anton Kozhemyachenko Messages: 15 Registered: June 2021 |
Junior Member |
|
|
Hello,
I'm trying to use variant "TAG" from the example as following:
In TTCN file:
module Test {
type integer INT1 (0..255) with { variant "FIELDLENGTH(8)" };
type octetstring OCT1 length(1) with { variant "FIELDLENGTH(1)" };
type octetstring OCT3 length(3) with { variant "FIELDLENGTH(3)" };
type record InnerRec {
INT1 tag optional,
OCT3 field
//} with {
//variant "PRESENCE(tag=1)"
}
type record MyRec {
OCT1 header,
InnerRec field1 optional
} with {
variant (field1) "TAG(field1, tag=1)"
}
} with { encode "RAW" }
In C++ file:
TTCN_Buffer buf_rec1, buf_rec2;
Test::MyRec a_rec1, a_rec2;
a_rec1.header() = str2oct("00");
a_rec1.field1()().tag()() = 1;
a_rec1.field1()().field() = str2oct("000000");
a_rec1.encode(*a_rec1.get_descriptor(), buf_rec1, TTCN_EncDec::CT_RAW);
buf_rec2.put_string(str2oct("0002000000"));
a_rec2.decode(*a_rec2.get_descriptor(), buf_rec2, TTCN_EncDec::CT_RAW);
TTCN_Logger::begin_event(TTCN_ERROR);
TTCN_Logger::log_event("### A_REC1:\n");
a_rec1.log();
TTCN_Logger::log_event("### A_REC2:\n");
a_rec2.log();
TTCN_Logger::end_event();
Unfortunately, the variant "TAG(field1, tag=1)" is not applied, and 'field1' in 'MyRec' is decoded always, here is the log output:
### A_REC1:
{ header := '00'O, field1 := { tag := 1, field := '000000'O } }
### A_REC2:
{ header := '00'O, field1 := { tag := 2, field := '000000'O } }
Is something wrong in my usage? If I use variant "PRESENCE(tag=1)" in InnerRec, the behavior is correct, however I need to specify field presence outside of the structure (i.e. in MyRec)
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03810 seconds