Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » the doubt about the function encvalue()(encoding bitstring and octetstring differently)
the doubt about the function encvalue() [message #1850894] Mon, 21 March 2022 12:12 Go to next message
lou ban is currently offline lou banFriend
Messages: 17
Registered: June 2020
Junior Member
type record A{
bitstring iei optional,
B128_Type randValue
};

type record B{
B4_Type f1,
B4_Type f2,
B8_Type f3,
A f4
}with {
variant "FIELDORDER(msb)";
}
;

B b_val := {f1 := '0001'B, f2 := '0001'B, f3 := '10000001'B, A := {randValue := '0001001000110100......0110011110001001'B}};
(assume randValue has 128 Bitstring)

the result of bit2oct(encvalue(b_val)) is '11818967......3412'O;
but what I want is '11811234......6789'O.

---------------------------------------------------
after my test, I found when I modify the struct
type record A{
bitstring iei optional,
O16_Type randValue
};

then
B b_val_1 := {f1 := '0001'B, f2 := '0001'B, f3 := '10000001'B, A := {randValue := '1234......6789'O}}

now the result of bit2oct(encvalue(b_val_1)) is '11811234......6789'O,(that is what I want)

Q1: why this effect, the function encvalue() encoding bitstring and octetstring differently???

Q2: how can I get the result without changing the struct A???

Q3: the encvalue() is the built-in function in titan, then will it be involved in big and small endian issues?


Thank you very much!
Re: the doubt about the function encvalue() [message #1850895 is a reply to message #1850894] Mon, 21 March 2022 12:50 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 133
Registered: December 2015
Senior Member
The encvalue encodes according to the encoding variant and rules of the RAW encoder
The default byte order of the bitstring and the octetstring are different. You can set the it via BYTORDER variant.

type record A{
bitstring iei optional,
B128_Type randValue
} with {
variant (randValue) "BYTEORDER(last)"
}

Re: the doubt about the function encvalue() [message #1850908 is a reply to message #1850895] Tue, 22 March 2022 01:39 Go to previous messageGo to next message
lou ban is currently offline lou banFriend
Messages: 17
Registered: June 2020
Junior Member
HI!

I found this in doc:
//Example number 1)
type octetstring OCT
with {
variant "BYTEORDER(first)"
}
const OCT c_oct := '123456'O // tag1
//The encoded bitfield: 01010110 00110100 00010010 // tag2
// last octet^ ^first octet
The buffer will have the following content:
// 00010010
// 00110100
// 01010110
//The encoding will result in the octetstring '123456'O

tag1 --> tag2, why the the encoded bitfield is not 00010010 00110100 01010110

even though oct2bit('123456'O) is '00010010 00110100 01010110'B

[Updated on: Tue, 22 March 2022 01:42]

Report message to a moderator

Re: the doubt about the function encvalue() [message #1850913 is a reply to message #1850908] Tue, 22 March 2022 07:31 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 133
Registered: December 2015
Senior Member
The oct2bit and the RAW encoder are two completely different thing and use different rules. The RAW encoder can process almost any kind of bit-, field- and byte ordered encoding.

The RAW encoder rules are described in the documentation. It is true that its default behavior is not the same as the oct2bit, int2oct etc. The RAW encoder logic based on the internal data representation of the TITAN in order to be as effective as possible.

Re: the doubt about the function encvalue() [message #1850939 is a reply to message #1850913] Wed, 23 March 2022 02:24 Go to previous messageGo to next message
lou ban is currently offline lou banFriend
Messages: 17
Registered: June 2020
Junior Member
thanks!
Re: the doubt about the function encvalue() [message #1851002 is a reply to message #1850913] Thu, 24 March 2022 11:02 Go to previous message
lou ban is currently offline lou banFriend
Messages: 17
Registered: June 2020
Junior Member
I had a another problem

// all in RAW and FILEDORDER(msb)
type record f4_Type{
    O1_Type    iei,
    O1_Type   tmp
};

type record f5_Type{
    O1_Type    iei,
    O2_Type    tmp
};

type record f6_Type{
    B4_Type    iei,
    B4_Type    tmp
};

type record A{
    B4_Type f1,
    B4_Type f2,
    O4_Type f3,
    O2_Type f4        optional,
    O3_Type f5        optional,
    O1_Type  f6        optional
}with {
    variant "TAG(
        f4, iei = '12'O;
        f5, iei = '34'O;
        f6, iei = '5'H;
    )";
};


when decode, I hope '11223344553466771288'O give me a decode error log instead of A :={f1:='0001'B, f2:='0001'B, f3:='22334455'O, f4:={iei:='12'O, tmp:='6677'O}, f5:=omit, f6:=omit}

and I also want an error when optional fields are repeated, sach as '112233445512661277'O

what should I do?

THANKS!
Previous Topic:TAG in RAW
Next Topic:the PRESENCE useage
Goto Forum:
  


Current Time: Tue Apr 16 17:50:19 GMT 2024

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

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

Back to the top