TASTE bugtrack - Taste
View Issue Details
0000465Taste[All Projects] ASN.1 Compilerpublic2015-09-25 15:442019-09-24 13:04
maxime 
gmamais 
normalfeaturealways
closedfixed 
0000465: 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? Thanks!
No tags attached.
parent of 0000822closed gmamais Support present-when with expressions 
? 001.acn (2,862) 2015-09-25 15:44
https://taste.tuxfamily.org/mantis/file_download.php?file_id=219&type=bug
? 001.asn1 (3,519) 2015-09-25 15:45
https://taste.tuxfamily.org/mantis/file_download.php?file_id=220&type=bug
Issue History
2015-09-25 15:44maximeNew Issue
2015-09-25 15:44maximeStatusnew => assigned
2015-09-25 15:44maximeAssigned To => gmamais
2015-09-25 15:44maximeFile Added: 001.acn
2015-09-25 15:45maximeSummarypresent-when seems not supported anymore => present-when `expression` seems not supported anymore
2015-09-25 15:45maximeFile Added: 001.asn1
2015-09-26 15:24gmamaisNote Added: 0002465
2015-09-26 15:40maximeNote Added: 0002466
2015-09-26 15:40maximeNote Edited: 0002466View Revisions
2015-09-28 20:01gmamaisNote Added: 0002473
2015-09-28 20:18maximeNote Added: 0002474
2015-10-02 11:25richard.melvinNote Added: 0002477
2015-10-23 15:10maximeNote Added: 0002494
2015-10-23 15:24richard.melvinNote Added: 0002495
2018-12-12 19:31maximeRelationship addedparent of 0000822
2019-05-26 15:28gmamaisNote Added: 0003644
2019-05-26 15:28gmamaisStatusassigned => resolved
2019-05-26 15:28gmamaisResolutionopen => fixed
2019-09-24 13:04maximeNote Added: 0003651
2019-09-24 13:04maximeStatusresolved => closed

Notes
(0002465)
gmamais   
2015-09-26 15:24   
Functionality is there. Have a look at asn1scc/Tests/test-cases/acn/14-RealCases/01-robotic-arm.asn1 asn1scc/Tests/test-cases/acn/14-RealCases/01-robotic-arm.acn 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.
(0002466)
maxime   
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 { b INTEGER, c CHOICE { x BOOLEAN, y NULL } } ``` ``` 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?
(0002473)
gmamais   
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.
(0002474)
maxime   
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?
(0002477)
richard.melvin   
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 etc. Note that this implies the packet type flag would have to be readable after decoding, and set before encoding.
(0002494)
maxime   
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?
(0002495)
richard.melvin   
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.
(0003644)
gmamais   
2019-05-26 15:28   
Resolved. Please see issue 822
(0003651)
maxime   
2019-09-24 13:04   
Thanks! closing