Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » How to initialize OCTETSTRING from char* in an external function?
How to initialize OCTETSTRING from char* in an external function? [message #1786671] Wed, 09 May 2018 07:57 Go to next message
Dorian K is currently offline Dorian KFriend
Messages: 2
Registered: May 2018
Junior Member
HI,

I want to implement an external function that's retuning an OCTETSTRING. This function reads a HEX String as a char*. I want to turn this char* into an OCTETSTRING also representing this HEX-String. So chr2oct doesn't to the trick. Coming from a TTWB world I'm used to a constructor that allows to enter a String as Parameter to initialize an OCTETSTRING. How does it work in titan?

BR Dorian
Re: How to initialize OCTETSTRING from char* in an external function? [message #1786692 is a reply to message #1786671] Wed, 09 May 2018 14:00 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 27
Registered: December 2015
Junior Member
Hi,

Does the "HEX String" mean something like: "AA1245CB" ? string using hexadecimal characters? Does it stored as null terminated C string?

If yes you can use the str2oct() function directly.



Re: How to initialize OCTETSTRING from char* in an external function? [message #1786731 is a reply to message #1786671] Thu, 10 May 2018 05:30 Go to previous messageGo to next message
Kristof Szabados is currently offline Kristof SzabadosFriend
Messages: 32
Registered: July 2015
Member
Hi,

If your char* already contains the hex values you can also use the OCTETSTRING constructor.

for example if you have something like this in your code: "var octetstring temp := '12AB'O;"

Titan will generate a code like this for it:
unsigned char os_0_octets[] = { 18, 171 };
OCTETSTRING temp(2, os_0_octets);

Please note that the original text visible in TTCN-3 is already translated to char[] representation in advance. This is a fast way if you already have your characters like this.
Re: How to initialize OCTETSTRING from char* in an external function? [message #1786780 is a reply to message #1786731] Fri, 11 May 2018 09:33 Go to previous message
Dorian K is currently offline Dorian KFriend
Messages: 2
Registered: May 2018
Junior Member
Thanks for your answers.
str2oct worked in my case, I just had to replace the line break at the last position with the null terminator.
The hexstrings are being read from a text file and the lines are containing hexadecimal values like: "AA1245CB".
Previous Topic:OneM2MTester news
Next Topic:Porting 3gpp test suites to Titan
Goto Forum:
  


Current Time: Fri Nov 16 07:08:35 GMT 2018

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

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

Back to the top