the doubt about the function encvalue() [message #1850894] |
Mon, 21 March 2022 12:12 |
lou ban 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 #1850908 is a reply to message #1850895] |
Tue, 22 March 2022 01:39 |
lou ban 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 #1851002 is a reply to message #1850913] |
Thu, 24 March 2022 11:02 |
lou ban 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!
|
|
|
Powered by
FUDForum. Page generated in 0.04281 seconds