Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000894Taste[All Projects] ASN.1 Compiler v4public2019-11-25 16:292019-11-26 15:58
Reportershd01 
Assigned Togmamais 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Summary0000894:

ASN1Scc generates broken ACN encoder for combination of nested CHOICE and OPTIONAL types

Description

The following ASN.1 + ACM generates a file DataView.c that fails to compile.

******************* ACN file **********************************

TASTE-Dataview DEFINITIONS ::=
BEGIN

T-S-Rx ::= CHOICE {
dlI T-S-DLI,
ulI T-S-ULI,
dlSg T-S-DLSg,
ulSg T-S-ULSg
}

T-S-Tx ::= CHOICE {
ulIR T-S-ULIR,
dlIR T-S-DLIR,
dlSgR T-S-DLSgR,
ulSgR T-S-ULSgR
}

T-Header ::= SEQUENCE {
func INTEGER(0..7),
nID INTEGER(0..127),
rtr INTEGER(0..1),
dlc INTEGER(0..1)
}

T-S-Payload ::= CHOICE {
stx T-S-Tx,
srx T-S-Rx
}

T-Frame ::= SEQUENCE {
header T-Header,
payload T-S-Payload
}

UINT8 ::= INTEGER(0..255)

T-GP ::= SEQUENCE (SIZE (4)) OF UINT8
T-SP ::= SEQUENCE (SIZE (4)) OF UINT8

T-D-Payload ::= CHOICE {
a T-GP,
b INTEGER(0..32000)
}

T-S-DLI ::= SEQUENCE {
co INTEGER(0..255),
oI INTEGER(0..65535),
oS INTEGER(0..255),
payload T-D-Payload
}

T-S-DLIR ::= SEQUENCE {
co INTEGER(0..255),
oI INTEGER(0..65535),
oS INTEGER(0..255),
payload T-GP OPTIONAL
}

T-S-ULI ::= SEQUENCE {
co INTEGER(0..255),
oI INTEGER(0..65535),
oS INTEGER(0..255),
payload T-GP OPTIONAL
}

T-S-ULIR ::= SEQUENCE {
co INTEGER(0..255),
oI INTEGER(0..65535),
oS INTEGER(0..255),
payload T-D-Payload
}

T-S-ULSg ::= SEQUENCE {
co INTEGER(0..255),
payload T-SP OPTIONAL
}

T-S-ULSgR ::= SEQUENCE {
co INTEGER(0..255),
payload T-SP OPTIONAL
}

T-S-DLSg ::= SEQUENCE {
co INTEGER(0..255),
payload T-SP OPTIONAL
}

T-S-DLSgR ::= SEQUENCE {
co INTEGER(0..255),
reserved T-SP OPTIONAL
}

END

******************* ACN file **********************************

TASTE-Dataview DEFINITIONS ::= BEGIN

T-S-Rx<INTEGER:fsel,INTEGER:esel> [] {
dlI [present-when fsel == 200],
ulI [present-when fsel == 201],
dlSg [present-when fsel == 202],
ulSg [present-when fsel == 203]
}

T-S-Tx<INTEGER:fsel,INTEGER:esel> [] {
ulIR [present-when fsel == 200],
dlIR [present-when fsel == 201],
dlSgR [present-when fsel == 202],
ulSgR [present-when fsel == 203]
}

T-S-Payload<INTEGER:fsel,INTEGER:psel,INTEGER:esel> [] {
stx<fsel,esel> [present-when psel==100],
srx<fsel,esel> [present-when psel==101]
}

T-Frame [] {
header [],
fsel INTEGER [encoding pos-int, size 8],
psel INTEGER [encoding pos-int, size 8],
esel INTEGER [encoding pos-int, size 8],
payload<fsel,psel,esel> []
}

T-D-Payload [] {
a [present-when esel == 0],
b [present-when esel == 1]
}

T-S-DLI [] {
co [],
oI [],
oS [],
payload []
}

T-S-DLIR [] {
co [],
oI [],
oS [],
payload [present-when e==1]
}

T-S-ULI [] {
co [],
oI [],
oS [],
payload [present-when e==1]
}

T-S-ULIR [] {
co [],
oI [],
oS [],
payload []
}

T-S-ULSg [] {
co [],
payload [present-when e==1]
}

T-S-ULSgR [] {
co [],
payload [present-when e==1]
}

T-S-DLSg [] {
co [],
payload [present-when e==1]
}

T-S-DLSgR [] {
co [],
reserved [present-when e==1]
}

END

The compilation error is:

DataView.c: In function ‘T_Frame_ACN_Encode’:
DataView.c:3069:50: error: ‘ERR_ACN_ENCODE_UPDATE_T_FRAME_PAYLOAD_SRX_ESEL’ undeclared (first use in this function)
*pErrCode = ERR_ACN_ENCODE_UPDATE_T_FRAME_PAYLOAD_SRX_ESEL;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DataView.c:3069:50: note: each undeclared identifier is reported only once for each function it appears in
DataView.c:3113:50: error: ‘ERR_ACN_ENCODE_UPDATE_T_FRAME_PAYLOAD_STX_ESEL’ undeclared (first use in this function)
*pErrCode = ERR_ACN_ENCODE_UPDATE_T_FRAME_PAYLOAD_STX_ESEL;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have attached the project to aid in reproducing the problem.

TagsNo tags attached.
Attached Filestgz file icon taste_bug7.tgz [^] (33,293 bytes) 2019-11-25 16:29

- Relationships

-  Notes
(0003690)
shd01 (reporter)
2019-11-25 16:30

The first file is of course the ASN.1 file, not the ACN file as the comment implies.

(0003691)
shd01 (reporter)
2019-11-25 17:14

And once again the mantis input window has eaten the parameter definitions - look at the attached files, not the pasted ACN.

(0003692)
gmamais (developer)
2019-11-26 15:58

Problem fixed in the latest GitHub commit.
There is an error in the ACN grammar which was not reported by ASN1SCC (which then produced invalid code).

The problem is the following

T-S-DLSgR [] {
  co             [],
  reserved       [present-when e==1]
}

reserved is an optional field.
So, you can say:
reserved [present-when e] -- where in this case e is an ACN field or ACN parameter
OR
reserved [present-when (e==1)] -- boolean expression where in this case e must be an ASN.1 field (i.e. the value must be provided by the programmer).


- Issue History
Date Modified Username Field Change
2019-11-25 16:29 shd01 New Issue
2019-11-25 16:29 shd01 Status

new => assigned

2019-11-25 16:29 shd01 Assigned To

=> gmamais

2019-11-25 16:29 shd01 File Added: taste_bug7.tgz
2019-11-25 16:30 shd01 Note Added: 0003690
2019-11-25 17:14 shd01 Note Added: 0003691
2019-11-26 15:58 gmamais Note Added: 0003692
2019-11-26 15:58 gmamais Status

assigned => resolved

2019-11-26 15:58 gmamais Resolution

open => fixed



Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker