Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000465Taste[All Projects] ASN.1 Compilerpublic2015-09-25 15:442019-09-24 13:04
Assigned Togmamais 
PlatformOSOS Version

present-when expression seems not supported anymore


In the attached file, you had sent me an example of the present-when property using an expression with operands that are not only ==:

intChoice[present-when intSeq.b>=2]

However this seems not supported anymore in the latest version of the compiler.
Could it be added again?


TagsNo tags attached.
Attached Files? file icon 001.acn [^] (2,862 bytes) 2015-09-25 15:44
? file icon 001.asn1 [^] (3,519 bytes) 2015-09-25 15:45

- Relationships
parent of 0000822closedgmamais 

Support present-when with expressions


-  Notes
gmamais (developer)
2015-09-26 15:24

Functionality is there. Have a look at

It is one of the test cases.

the syntax is
intChoice[present-when present-when fld1 == constant1 fld2 == constant2 ...]

you can specify multiple fields in the present when attribute but each one should be equal with a constant integer or string value.
You may also use boolean fields where in this case the equal sign and the constant part must not be there. An example follows
intChoice[present-when present-when strFld == "Maxime" sq.intFld == 1 boolFld1 ].

In your example there is an inequality intSeq.b>=2
This is not supported. This would be fine for encoding but there would be a problem during decoding; asn1scc must automatically populate the value of the fieds used in the present-when attribute. Field intSeq.b in this case. In you example there multiple values that satisfy the inequality (2,3,4 etc). So, what value shoud asn1scc chooce for field intSeq.b?

I do not know how you got this grammar but asn1scc never supported inequalities in present-when attributes.

Perhaps it is sample grammar created at the very beggining in order to show how acn would like and when ACN was not implemented yet.

maxime (administrator)
2015-09-26 15:40
edited on: 2015-09-26 15:40

(I found this grammar in the attachement of a mail you sent me, indeed perhaps before the tool was fully implemented).

However, I am not sure to understand the problem at decoding.

When you receive an encoded packet, intSeq.b has a value. This is the discriminant for the CHOICE (or the OPTIONAL field).

Seq ::= SEQUENCE {
Seq[] {
 b []
 c [] { x [present-when b<10], y [present-when b>=10] }

when you receive a packet, you get {b, c}
You have b so you can decide if the choice in c is x or y

In the encoding side however, if "b" is a field added in the ACN grammar, you may need to choose randomly a value <10 or >=10.

Am I missing something?

gmamais (developer)
2015-09-28 20:01

I am sorry my bad. The problem is during encoding not decoding.

When you encode Seq asn1scc must automatically update field b based on whether x or y are present in choice. Please note the field b which acts as choice present determinant is not allowed to be part of the ASN.1 grammar but it must be inserted in the ACN spec. Therefore user code cannot access field b.
So, in this case if x is present what is the correct value? 9, 8, 7 etc;

I hope this clarifies my point.

maxime (administrator)
2015-09-28 20:18

Richard do you know what is the exact use case for this in EDS?

In what situations would there be a range of values used as choice discriminant?

richard.melvin (reporter)
2015-10-02 11:25

An example could be where there are several TM packets, but some had the same structure, perhaps because they represented redundant hardware.

so it would be:

packet type 1: housekeeping
packet type 2,3,4: sun sensor data 1,2,3 respectively

Note that this implies the packet type flag would have to be readable after decoding, and set before encoding.

maxime (administrator)
2015-10-23 15:10

You cannot ask to the user to set a value manually in a discriminant field, otherwise it may be inconsistent with the value he puts in the field itself. Only the encoding function can set the correct value (to guarantee the correctness by construction).
But if you write present-when b>=10, what value is the encoder supposed to choose?

richard.melvin (reporter)
2015-10-23 15:24

Realistically this feature would only be used for decoding. Of course, the ASN.1 model is symmetrical for encoding and decoding, and there is no formal restriction that stops anyone from using it when specifying data to be encoded. So just to cover this case, you could either:

  1. pick the lowest value from the range.
  2. make user specify a value, if it is not within the range report an error.
gmamais (developer)
2019-05-26 15:28

Resolved. Please see issue 822

maxime (administrator)
2019-09-24 13:04

Thanks! closing

- Issue History
Date Modified Username Field Change
2015-09-25 15:44 maxime New Issue
2015-09-25 15:44 maxime Status

new => assigned

2015-09-25 15:44 maxime Assigned To

=> gmamais

2015-09-25 15:44 maxime File Added: 001.acn
2015-09-25 15:45 maxime Summary

present-when seems not supported anymore => present-when expression seems not supported anymore

2015-09-25 15:45 maxime File Added: 001.asn1
2015-09-26 15:24 gmamais Note Added: 0002465
2015-09-26 15:40 maxime Note Added: 0002466
2015-09-26 15:40 maxime Note Edited: 0002466 View Revisions
2015-09-28 20:01 gmamais Note Added: 0002473
2015-09-28 20:18 maxime Note Added: 0002474
2015-10-02 11:25 richard.melvin Note Added: 0002477
2015-10-23 15:10 maxime Note Added: 0002494
2015-10-23 15:24 richard.melvin Note Added: 0002495
2018-12-12 19:31 maxime Relationship added

parent of 0000822

2019-05-26 15:28 gmamais Note Added: 0003644
2019-05-26 15:28 gmamais Status

assigned => resolved

2019-05-26 15:28 gmamais Resolution

open => fixed

2019-09-24 13:04 maxime Note Added: 0003651
2019-09-24 13:04 maxime Status

resolved => closed

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker