Home » Eclipse Projects » Eclipse Titan » problem in RAW decoder with TAG of different length
problem in RAW decoder with TAG of different length [message #1768344] |
Mon, 17 July 2017 17:22 |
|
I've been using the RAW encoder/decoder successfully to describe several protocols that don't have a formal notation in order to use them from Eclipse Titan.
This has worked fine so far. However, when implementing LAPDm header parsing (3GPP TS 44.006) I think I found a bug in the RAW decoder.
Let's assume I have the following type declaration:
module LAPDm_Types {
type record LapdmCtrlI {
uint3_t n_r,
boolean p,
uint3_t n_s,
BIT1 spare
} with { variant "" };
type record LapdmCtrlS {
uint3_t n_r,
boolean p_f,
LapdmSBits s,
BIT2 spare
} with { variant "" };
type record LapdmCtrlU {
LapdmUBits u,
boolean p_f,
LapdmU2Bits u2,
BIT2 spare
} with { variant "" };
/* TS 44.006 Table 3 */
type union LapdmCtrl {
LapdmCtrlI i,
LapdmCtrlS s,
LapdmCtrlU u,
} with { variant "TAG(u, spare = '11'B;
s, spare = '01'B;
i, spare = '0'B)" };
} with { encode "RAW"; variant "FIELDORDER(msb)" }
Then encoding the LapdmCtrl union will work perfectly fine, but decoding it will fail.
My assumption is that the RAW decoder will take the input (e.g. '03'O), decode that LapdmCtrlU, extract the lower two bits as 'spare' and then match those against '11B', and hence decide that it is a U frame and populate the u member of the union.
If I directly dec_LapdmCtrlU('03'O), I get "{ u := '000'B, p_f := false, u2 := '00'B, spare := '11'B }
So the direct decode shows me that the definition of the LapdmCtrlU record correct and 'spare := '11'B' is decoded. From that, the RAW decoder should simply match the "TAG(u, spare = '11'B;". What am I missing here?
If I dec_LapdmCtrl('03'O), I get a "Dynamic test case error: While RAW-decoding type '@LAPDm_Types.LapdmCtrl': Can not decode type '@LAPDm_Types.LapdmCtrl', because invalid message was received"
If I add another choice with "OTHERWISE", then the decoder decodes it as OTHERWISE, despite the 'spare = '11'B should match: "{ other := 3 }"
/* TS 44.006 Table 3 */
type union LapdmCtrl {
LapdmCtrlS s,
LapdmCtrlU u,
LapdmCtrlI i,
uint8_t other
} with { variant "TAG(u, spare = '11'B;
s, spare = '01'B;
i, spare = '0'B;
other, OTHERWISE)" };
The full module (and its imports) can be found at git.osmocom.org/osmo-ttcn3-hacks/tree/lapd/LAPDm_Types.ttcn
I'm happy to hear your opinion on this. What am I missing? Or did I really find a bug in the decoder? Thanks!
|
|
|
Re: problem in RAW decoder with TAG of different length [message #1768472 is a reply to message #1768344] |
Wed, 19 July 2017 09:02 |
Gábor Szalai Messages: 134 Registered: December 2015 |
Senior Member |
|
|
yes, this is a bug in the RAW decoder.
As a workaround set the field length of the boolean field:
type record LapdmCtrlI {
uint3_t n_r,
boolean p,
uint3_t n_s,
BIT1 spare
} with { variant (p) "FIELDLENGTH(1)" };
type record LapdmCtrlS {
uint3_t n_r,
boolean p_f,
LapdmSBits s,
BIT2 spare
} with { variant (p_f) "FIELDLENGTH(1)" };
type record LapdmCtrlU {
LapdmUBits u,
boolean p_f,
LapdmU2Bits u2,
BIT2 spare
} with { variant (p_f) "FIELDLENGTH(1)" };
|
|
| |
Goto Forum:
Current Time: Tue Sep 24 05:35:46 GMT 2024
Powered by FUDForum. Page generated in 0.03794 seconds
|