Skip to main content



      Home
Home » Eclipse Projects » Eclipse Titan » [Solved] Incorrect bit order Bitstring (ITS project)
[Solved] Incorrect bit order Bitstring [message #1772971] Tue, 19 September 2017 11:17 Go to next message
Eclipse UserFriend
Hi everyone,

I work on ITS project (European project on connected cars), and we want to run ITS test on Titan. To do this, I develop a System Adapter.

In this SA, I have a message (a CAM) which contain a exteriorLights set to 20.
When I print the message value I have :
exteriorLights: 20


This exteriorLight is define in a ASN.1 (from asn1c), so we have a Bit_string which is a structure which contain :
- uint8_t *buf; /* BIT STRING body */
- int size; /* Size of the above buffer (number of bytes)*/
- int bits_unused;/* Unused trailing bits in the last octet (0..7) */
- asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */

but when I want to put this value in the test structure, in a Titan BITSTRING. I obtain this error :

Matching on port camPort .msgIn.cam.camParameters.lowFrequencyContainer.basicVehicleContainerLowFrequency.exteriorLights := '00000100'B with '??1*'B length (8) unmatched: Fi


Because, in the BITSTRING corresponding to Titan exteriorLight I have :
exteriorLights := '00000100'B


To obtain this, I used the BITSTRING constructor like this :
...
cam.cam().camParameters().lowFrequencyContainer()().basicVehicleContainerLowFrequency().exteriorLights()=BITSTRING(tmpLights.size * 8 - tmpLights.bits_unused, tmpLights.buf)
...


So I think that the Titan BITSTRING contructor swap a half of the buffer with the other.

Do you think that it's a problem with my code ? Or with the Titan BITSTRING Constructor ?

Best Regards,
Kevin.

[Updated on: Wed, 20 September 2017 04:19] by Moderator

Re: Incorrect bit order Bitstring [message #1772984 is a reply to message #1772971] Tue, 19 September 2017 13:01 Go to previous messageGo to next message
Eclipse UserFriend
That is how the TITAN stores the bitstring internally.

The first bit is stored in the LSB of the first octet.

                 Last bit.
'00000100'B
 ^
This is the first bit.


Internally stored in the reversed order, as the bits are filled with from LSB.


You can try:
substr(oct2bit(OCTETSTRING(tmpLights.size,tmpLights.buf)),0,tmpLights.size * 8 - tmpLights.bits_unused)
Re: Incorrect bit order Bitstring [message #1773009 is a reply to message #1772984] Wed, 20 September 2017 04:17 Go to previous message
Eclipse UserFriend
Hi Gábor,

It works ! Thanks a lot !

Best Regards,
Kevin.
Previous Topic:Help needed on Structure UDP Example
Next Topic:Fuzzing of BER-encoded protocols in Titan
Goto Forum:
  


Current Time: Wed Jul 23 16:40:33 EDT 2025

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

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

Back to the top