Re: [taste-users] ASN.1 encoding |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/taste-users Archives
]
Hi Michael,
I am not sure to understand exactly your problem.
For the first point, you have to trust GCC :-)
If the sizeof gives a value that does not look obvious, it is because GCC adds padding bytes to align the fields structures.
For the encoding issue, I am not sure to see what is wrong. Did you make a round trip example (fill the C structure, encode, then decode) and got a different result ?
Don't assume that True is decoded to the value 1.
In order to check the compiler output, use the options -atc -ACN, it will generate automatically some test cases for your grammar, with an encode-decode cycle for all your data types. I tried it and did not get any error with your grammar.
You can also check the encoding layout using the -icdAcn file.html option. (I recommend it for documentation purposes anyway).
Best regards,
Maxime
-----<Michael.Dumke@xxxxxx> wrote: -----
To: <taste-users@xxxxxxxxxxxxxxxxxxx>
From: <Michael.Dumke@xxxxxx>
Date: 10/17/2013 05:22PM
Subject: [taste-users] ASN.1 encoding
Hi everybody,
I have some problems with correctly encoding and decoding ASN.1 and/or ACN:
My ASN.1 definition is:
TASTE-Dataview DEFINITIONS ::=
BEGIN
BINARY ::= BOOLEAN
RADIANS ::= REAL (-1.0 ... 1.0)
ATTITUDE ::= SEQUENCE (SIZE(3)) OF RADIANS
ATTRATE ::= SEQUENCE (SIZE(3)) OF RADIANS
MEAS ::= SEQUENCE {att ATTITUDE, rate ATTRATE, simctrl SEQUENCE {simstart BOOLEAN, parm REAL (0.0 .. 1.0)}}
END
My ACN model is:
TASTE-Dataview DEFINITIONS ::= BEGIN
RADIANS[encoding IEEE754-1985-64, endianness little]
ATTITUDE []
ATTRATE []
MEAS[] {att [], rate [], simctrl [] {simstart [], parm [encoding IEEE754-1985-64, endianness little] }}
END
In a black box system the size of the MEAS is 57 bytes:
#define asn1SccMEAS_REQUIRED_BYTES_FOR_ACN_ENCODING 57
Which is correct 7*8 bytes for the real + 1* 1byte for the Boolean.
Giving a MEAS from a black box device to a c-function result in (in my opinion) a conversion error, also the sizes seem to be wrong:
sizeof(asn1SccMEAS)=64
sizeof(asn1SccMEAS_simctrl)=16
sizeof(asn1SccATTRATE)=24
sizeof(asn1SccATTITUDE)=24
the latter two make sense (3*8byte), but simctrl is a struct from a double and a "flag" which should be 9 bytes but 16 bytes is give during runtime.
"""
typedef double asn1SccMEAS_simctrl_parm;
typedef struct {
flag simstart;
asn1SccMEAS_simctrl_parm parm;
} asn1SccMEAS_simctrl;
"""
If I see it correctly, than there is some problem with ASN.1 BOOLEANs which are converted to c-type "flag".
An example of the conversion from the blackbox device to a c-function:
The MEAS encoded in ACN is (57 bytes):
3f, e4, c4,79, a6,85,36,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3f, e6,66,66,66,66,66,66,
converted to the c-struct in the c-function leads to a byte array (asn1SccMEAS, size 64byte):
10,36,85,a6,79,c4,e4,3f,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,cc,cc,cc,cc,cc,cc,7f,2,
The first "double" seems to be converted correctly (little/big endian conversion). The zeros are probably also correct, but the BOOL ("1") from the first array cannot be found inside the second array and the double afterwards is also incorrect. (Also that (again) there are 8 bytes for a BOOL is probably incorrect)
I am sorry for the long and (probably) confusion explanation, but I am unsure where the problem results from. May be I did something wrong in the ASN/ACN model, or the conversion function are broken.
Best regards
Michael Dumke
--------------------------
Deutsches Zentrum für Luft- und Raumfahrt e.V. (DLR)
German Aerospace Center
Institute of Space Systems | Robert-Hooke-Str. 7 | 28359 Bremen | Germany
Michael Dumke
Telephone +49 421 24420-1262 | Telefax +49 421 24420-1120 | michael.dumke@xxxxxx
www.DLR.de
This message and any attachments are intended for the use of the addressee or addressees only. The unauthorised disclosure, use, dissemination or copying (either in whole or in part) of its content is not permitted. If you received this message in error, please notify the sender and delete it from your system. Emails can be altered and their integrity cannot be guaranteed by the sender.
Please consider the environment before printing this email.