Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » RAW decoding with variant "TAG" doesn't work
RAW decoding with variant "TAG" doesn't work [message #1842000] Mon, 07 June 2021 01:20 Go to next message
Anton Kozhemyachenko is currently offline Anton KozhemyachenkoFriend
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)
Re: RAW decoding with variant "TAG" doesn't work [message #1842008 is a reply to message #1842000] Mon, 07 June 2021 07:12 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 134
Registered: December 2015
Senior Member
Sorry, the example in the reference guide is wrong.

the correct definition of the MyRec is:

type record MyRec {
    OCT1 header,
    InnerRec field1 optional
  } with {
    variant  "TAG(field1, tag=1)"
 }


The (field1) is not needed.
Re: RAW decoding with variant "TAG" doesn't work [message #1842012 is a reply to message #1842008] Mon, 07 June 2021 08:21 Go to previous message
Anton Kozhemyachenko is currently offline Anton KozhemyachenkoFriend
Messages: 15
Registered: June 2021
Junior Member
Thanks, it works.
Previous Topic:TTCN-3 typing for RFC 7946 (GeoJSON)
Next Topic:Ericsson support for titan lower?
Goto Forum:
  


Current Time: Sun Oct 13 19:52:11 GMT 2024

Powered by FUDForum. Page generated in 0.03810 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top