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: 133
Registered: December 2015
Senior 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: 60
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:State of the Osmocom TTCN-3 Test Suites
Goto Forum:
  


Current Time: Thu Apr 25 23:29:14 GMT 2024

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

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

Back to the top