Description | Using this ASN...
Test DEFINITIONS ::=
BEGIN
MyEnum ::= ENUMERATED {a,b,c}
T-Thing ::= CHOICE {
alt1 INTEGER,
alt2 MyEnum
}
T-ThingHolder ::= SEQUENCE {
random INTEGER,
thing T-Thing
}
END
... with this ACN ...
Test DEFINITIONS ::=
BEGIN
T-ThingHolder [] {
random [],
thing [],
selector INTEGER [encoding pos-int, size 32]
}
T-Thing [] {
alt1 [present-when selector == 1],
alt2 [present-when selector == 10]
}
END
... I get an ACN Decoder that compiles but which crashes at runtime. The problem is that the code generator expects the key field "selector" to be located before the "thing" in the encoded packet.
flag T_ThingHolder_ACN_Decode(T_ThingHolder* pVal, BitStream* pBitStrm, int* pErrCode)
{
flag ret = TRUE;
asn1SccUint T_ThingHolder_selector;
asn1SccUint intVal;
/*Decode random */
ret = BitStream_DecodeUnConstraintWholeNumber(pBitStrm, (&(pVal->random)));
*pErrCode = ret ? 0 : ERR_ACN_DECODE_T_THINGHOLDER_RANDOM;
if (ret) {
/*Decode thing */
*pErrCode = 0;
if ((T_ThingHolder_selector == 1)) { <<<<<<<<<<<<<<<<<<<< uninitialised!
pVal->thing.kind = alt1_PRESENT;
ret = BitStream_DecodeUnConstraintWholeNumber(pBitStrm, (&(pVal->thing.u.alt1)));
*pErrCode = ret ? 0 : ERR_ACN_DECODE_T_THINGHOLDER_THING_ALT1;
}
else if ((T_ThingHolder_selector == 10)) {
pVal->thing.kind = alt2_PRESENT;
ret = BitStream_DecodeConstraintPosWholeNumber(pBitStrm, (&(intVal)), 0, 2);
*pErrCode = ret ? 0 : ERR_ACN_DECODE_T_THINGHOLDER_THING_ALT2;
if (ret) {
switch (intVal) {
case 0:
pVal->thing.u.alt2 = a;
break;
case 1:
pVal->thing.u.alt2 = b;
break;
case 2:
pVal->thing.u.alt2 = c;
break;
default:
ret = FALSE; /*COVERAGE_IGNORE*/
*pErrCode = ERR_ACN_DECODE_T_THINGHOLDER_THING_ALT2; /*COVERAGE_IGNORE*/
}
}
}
else {
*pErrCode = ERR_ACN_DECODE_T_THINGHOLDER_THING; /*COVERAGE_IGNORE*/
ret = FALSE; /*COVERAGE_IGNORE*/
}
if (ret) {
/*Decode T_ThingHolder_selector */
ret = Acn_Dec_Int_PositiveInteger_ConstSize_big_endian_32(pBitStrm, (&(T_ThingHolder_selector)));
*pErrCode = ret ? 0 : ERR_ACN_DECODE_T_THINGHOLDER_SELECTOR;
}
}
return ret && T_ThingHolder_IsConstraintValid(pVal, pErrCode);
}
|