Description
Hello, I'm trying to compile two C-ITS message formats for Europe: DENM (version 1.3.1) and IVIM (version 1.3.1). I found all the ASN files (see attachments) and I have some examples in hexadecimal format (which I converted in binary files, see attachments).
If I compile only the DENM (with requested ASNs) or IVIM I can decode the messages without problems, but if I try to compile both messages (separated or all in the same folder), I can't decode DENM messages.
I think that a possible problem is related to one specific ASN: ITS-Container, to compile IVIM I have to use 2 different versions of this ASN, I have this error but it seems working.
WARNING: ASN.1 module ITS-Container is defined more than once, with different OIDs in ../asn_files/ITS-Container_old.asn
FATAL: Name "e_ITS_Container_CenDsrcTollingZoneID" is generated by ITS-Container.CenDsrcTollingZoneID at line ../asn_files/ITS-Container.asn:505 and ITS-Container.CenDsrcTollingZoneID at line ../asn_files/ITS-Container_old.asn:501
FATAL: Name "enum ITS_Container_CenDsrcTollingZoneID" is generated by ITS-Container.CenDsrcTollingZoneID at line ../asn_files/ITS-Container.asn:505 and ITS-Container.CenDsrcTollingZoneID at line ../asn_files/ITS-Container_old.asn:501
FATAL: Name "ITS_Container_CenDsrcTollingZoneID_PR" is generated by ITS-Container.CenDsrcTollingZoneID at line ../asn_files/ITS-Container.asn:505 and ITS-Container.CenDsrcTollingZoneID at line ../asn_files/ITS-Container_old.asn:501
FATAL: Name "enum ITS_Container_CenDsrcTollingZoneID_PR" is generated by ITS-Container.CenDsrcTollingZoneID at line ../asn_files/ITS-Container.asn:505 and ITS-Container.CenDsrcTollingZoneID at line ../asn_files/ITS-Container_old.asn:501
FATAL: Name "struct ITS_Container_CenDsrcTollingZoneID" is generated by ITS-Container.CenDsrcTollingZoneID at line ../asn_files/ITS-Container.asn:505 and ITS-Container.CenDsrcTollingZoneID at line ../asn_files/ITS-Container_old.asn:501
FATAL: Name "ITS_Container_CenDsrcTollingZoneID" is generated by ITS-Container.CenDsrcTollingZoneID at line ../asn_files/ITS-Container.asn:505 and ITS-Container.CenDsrcTollingZoneID at line ../asn_files/ITS-Container_old.asn:501
FATAL: ... 793 more name clashes not shown
FATAL: Name clashes encountered even with -fcompound-names flag
To compile I use this command:
asn1c -fcompound-names -findirect-choice -fincludes-quoted -no-gen-example -pdu=DENM -pdu=all *.asn
for DENM (in the folder there are only the DENM related ASN.1)
asn1c -fcompound-names -findirect-choice -fincludes-quoted -no-gen-example -pdu=IVIM -pdu=all *.asn
for IVIM (in the folder there are only the IVIM related ASN.1)
asn1c -fcompound-names -findirect-choice -fincludes-quoted -no-gen-example -pdu=DENM -pdu=IVIM -pdu=all *.asn
for DENM+IVIM
The decoder code is the sequent:
char buf[1024];
asn_dec_rval_t rval;
DENM_t* denm = 0; //asn1c_usage.pdf pag 7
FILE* fp; /* Input file handler */
size_t size; /* Number of bytes read */
const char* filename = "Accident.dat"; /* Input file name */
/* Open input file as read-only binary */
fp = fopen(filename, "rb");
if (!fp) {
perror(filename);
exit(1);
}
/* Read up to the buffer size */
size = fread(buf, 1, sizeof(buf), fp);
fclose(fp);
if (!size) {
fprintf(stderr, "%s: Empty or broken\n", filename);
exit(1);
}
//rval = uper_decode_complete(0, &asn_DEF_DENM, (void**)&denm, buf, size);
rval = asn_decode(0, ATS_UNALIGNED_CANONICAL_PER, &asn_DEF_DENM, (void**)&denm, buf, size);
char errbuf[128];
size_t errlen = sizeof(errbuf);
asn_check_constraints(&asn_DEF_DENM, (void**)&denm, errbuf, &errlen);
if (rval.code != RC_OK)
{
printf("Broken DENM encoding at byte % ld\n", (long)rval.consumed);
//return;
}
xer_fprint(stdout, &asn_DEF_DENM, denm);
The error is that rval.code is RC_FAIL and consume is 0.
What can I try to use both DENM and IVIM message format? Did I missed something?
Thanks!