Asn1.c compiler was able to generate the header/C files from the DSRC ASN definition file
I use the following command:
asn1c -fcompound-name DSRC_R36_Source.ASN
Then create a simple decode-bsm C program and shows multiple errors:
cc -I. -o AlaCarte.o -c AlaCarte.c
In file included from Intersection.h:78:0,
from AllInclusive.h:521,
from AlaCarte.h:15,
from AlaCarte.c:7:
SignalControlZone.h:49:5: warning: anonymous struct declared inside parameter list [enabled by default]
SignalControlZone.h:49:5: warning: ‘struct enclosed’ declared inside parameter list [enabled by default]
SignalControlZone.h:49:5: warning: ‘struct SignalControlZone__data__zones__Member’ declared inside parameter list [enabled by default]
In file included from AllInclusive.h:523:0,
from AlaCarte.h:15,
from AlaCarte.c:7:
ExitService.h:34:2: warning: ‘union item_u’ declared inside parameter list [enabled by default]
ExitService.h:34:2: warning: ‘struct item’ declared inside parameter list [enabled by default]
ExitService.h:34:2: warning: ‘struct ExitService__Member’ declared inside parameter list [enabled by default]
In file included from AllInclusive.h:524:0,
from AlaCarte.h:15,
from AlaCarte.c:7:
GenericSignage.h:26:14: error: nested redefinition of ‘enum item_PR’
GenericSignage.h:26:14: error: redeclaration of ‘enum item_PR’
ExitService.h:26:14: note: originally defined here
GenericSignage.h:27:2: error: redeclaration of enumerator ‘item_PR_NOTHING’
ExitService.h:27:2: note: previous definition of ‘item_PR_NOTHING’ was here
GenericSignage.h:28:2: error: redeclaration of enumerator ‘item_PR_itis’
ExitService.h:28:2: note: previous definition of ‘item_PR_itis’ was here
GenericSignage.h:29:2: error: redeclaration of enumerator ‘item_PR_text’
ExitService.h:29:2: note: previous definition of ‘item_PR_text’ was here
GenericSignage.h:34:2: error: redefinition of ‘struct item’
ExitService.h:34:2: note: originally defined here
GenericSignage.h:34:2: error: redefinition of ‘union item_u’
ExitService.h:34:2: note: originally defined here
GenericSignage.h:34:2: warning: ‘union item_u’ declared inside parameter list [enabled by default]
GenericSignage.h:34:2: warning: ‘struct item’ declared inside parameter list [enabled by default]
GenericSignage.h:34:2: warning: ‘struct GenericSignage__Member’ declared inside parameter list [enabled by default]
In file included from AllInclusive.h:525:0,
from AlaCarte.h:15,
from AlaCarte.c:7:
SpeedLimit.h:26:14: error: nested redefinition of ‘enum item_PR’
SpeedLimit.h:26:14: error: redeclaration of ‘enum item_PR’
ExitService.h:26:14: note: originally defined here
SpeedLimit.h:27:2: error: redeclaration of enumerator ‘item_PR_NOTHING’
GenericSignage.h:27:2: note: previous definition of ‘item_PR_NOTHING’ was here
SpeedLimit.h:28:2: error: redeclaration of enumerator ‘item_PR_itis’
GenericSignage.h:28:2: note: previous definition of ‘item_PR_itis’ was here
SpeedLimit.h:29:2: error: redeclaration of enumerator ‘item_PR_text’
GenericSignage.h:29:2: note: previous definition of ‘item_PR_text’ was here
SpeedLimit.h:34:2: error: redefinition of ‘struct item’
GenericSignage.h:34:2: note: originally defined here
SpeedLimit.h:34:2: error: redefinition of ‘union item_u’
GenericSignage.h:34:2: note: originally defined here
SpeedLimit.h:34:2: warning: ‘union item_u’ declared inside parameter list [enabled by default]
SpeedLimit.h:34:2: warning: ‘struct item’ declared inside parameter list [enabled by default]
SpeedLimit.h:34:2: warning: ‘struct SpeedLimit__Member’ declared inside parameter list [enabled by default]
In file included from AllInclusive.h:526:0,
from AlaCarte.h:15,
from AlaCarte.c:7:
WorkZone.h:26:14: error: nested redefinition of ‘enum item_PR’
WorkZone.h:26:14: error: redeclaration of ‘enum item_PR’
ExitService.h:26:14: note: originally defined here
WorkZone.h:27:2: error: redeclaration of enumerator ‘item_PR_NOTHING’
SpeedLimit.h:27:2: note: previous definition of ‘item_PR_NOTHING’ was here
WorkZone.h:28:2: error: redeclaration of enumerator ‘item_PR_itis’
SpeedLimit.h:28:2: note: previous definition of ‘item_PR_itis’ was here
WorkZone.h:29:2: error: redeclaration of enumerator ‘item_PR_text’
SpeedLimit.h:29:2: note: previous definition of ‘item_PR_text’ was here
WorkZone.h:34:2: error: redefinition of ‘struct item’
SpeedLimit.h:34:2: note: originally defined here
WorkZone.h:34:2: error: redefinition of ‘union item_u’
SpeedLimit.h:34:2: note: originally defined here
WorkZone.h:34:2: warning: ‘union item_u’ declared inside parameter list [enabled by default]
WorkZone.h:34:2: warning: ‘struct item’ declared inside parameter list [enabled by default]
WorkZone.h:34:2: warning: ‘struct WorkZone__Member’ declared inside parameter list [enabled by default]
In file included from AllInclusive.h:527:0,
from AlaCarte.h:15,
from AlaCarte.c:7:
J1939data.h:42:3: warning: ‘struct J1939data__tires__Member’ declared inside parameter list [enabled by default]
J1939data.h:63:3: warning: ‘struct J1939data__axle__Member’ declared inside parameter list [enabled by default]
In file included from AllInclusive.h:557:0,
from AlaCarte.h:15,
from AlaCarte.c:7:
ITIScodesAndText.h:26:14: error: nested redefinition of ‘enum item_PR’
ITIScodesAndText.h:26:14: error: redeclaration of ‘enum item_PR’
ExitService.h:26:14: note: originally defined here
ITIScodesAndText.h:27:2: error: redeclaration of enumerator ‘item_PR_NOTHING’
WorkZone.h:27:2: note: previous definition of ‘item_PR_NOTHING’ was here
ITIScodesAndText.h:28:2: error: redeclaration of enumerator ‘item_PR_itis’
WorkZone.h:28:2: note: previous definition of ‘item_PR_itis’ was here
ITIScodesAndText.h:29:2: error: redeclaration of enumerator ‘item_PR_text’
WorkZone.h:29:2: note: previous definition of ‘item_PR_text’ was here
ITIScodesAndText.h:34:2: error: redefinition of ‘struct item’
WorkZone.h:34:2: note: originally defined here
ITIScodesAndText.h:34:2: error: redefinition of ‘union item_u’
WorkZone.h:34:2: note: originally defined here
ITIScodesAndText.h:34:2: warning: ‘union item_u’ declared inside parameter list [enabled by default]
ITIScodesAndText.h:34:2: warning: ‘struct item’ declared inside parameter list [enabled by default]
ITIScodesAndText.h:34:2: warning: ‘struct ITIScodesAndText__Member’ declared inside parameter list [enabled by default]
make: *** [AlaCarte.o] Error 1
Adding Makefile
Adding DSRC ASN file
Problem of scope.
In C/C++, you create a typedef conflict as the member name "item" is repeated in a nested type with the same generated typedef name. Technically, this is allowed in ASN.1 but seem to generate the artifact of scope clash in the current ASN1C compiler as the identifier "item" is taken verbatim by the ASN1C compiler witn the addition of a suffix (again, the same for all).
You can simply resolve the ambiguity yourself by changing a few member names (some of those that contain "item").
SpeedLimit, WorkZone and ITIScodesAndText seem to be the ones that need manual disambiguation for the C compiler;
ITIScodesAndText ::= SEQUENCE (SIZE(1..100)) OF SEQUENCE {
itis-item CHOICE {
itis ITIScodes,
text ITIStext
} -- # UNTAGGED
}
SpeedLimit ::= SEQUENCE (SIZE(1..10)) OF SEQUENCE {
sl-item CHOICE {
itis ITIS.ITIScodes,
text IA5String (SIZE(1..16))
} -- # UNTAGGED
}
WorkZone ::= SEQUENCE (SIZE(1..10)) OF
wz-item CHOICE {
itis ITIS.ITIScodes,
text IA5String (SIZE(1..16))
} -- # UNTAGGED
This generates exactly the same encoding, but will have these members printed differently if you compare to the spec letter for letter.
You can ignore the rest of the warnings or adjust your compiler warnings.
This compiles fine for me using GCC with the changes.
LEV, is this something that could be fixed? It would break the naming paradigm if a conflict with a nested type is found like this, but perhaps that is a small price?
/Stefan
Note:
This will not work for XER though as XML will use the identifiers as XML-tags. Not a problem with the binary encoding (BER/DER/PER/UPER) though where only the structure and type is relevant.
Last edit: Stefan Gudmundsson 2015-05-15
Hi, All,
I just fixed problems found during processing DSRC's ASN file in one github pull request, this repository maintained by mouse07410 which contains several useful features not merged into Lev Walkin's master yet.
Now the C code can be generated and compiled.
However, I don't have binary data of DSRC message for verifying codec's correctness. So if anyone can give me some raw data of DSRC message will be helpful.
Any feedback is welcomed.