Masilamani - 2015-06-19

Hi,

I am trying to develop an ASN.1 protocol in PER(unaligned) for encoding the Ecall MSD.

working enviroinment:- ARM 32-bit microcontroller,cubesuite (cross compiler).

Note:- Running without any OS.

=> Used the experimental version 0.9.24 online compiler for generating the .c and .h code for the ASN.1 schema (below) with all the necessary compiler options for PER(unaligned) support,fnative types.

=> used the ASN.1 online compiler generated .c and .h files and customized the code in order to make the code run on the microcontroller , because I faced lot of compatibility issue while compiling the actual generated code in the cubesuite(cross-compiler).

Eg:- Cross compiler wont support FILE operations ,printf,snprintf, alloc() etc..,

=> After the customization, I have replaced the converter-sample.c to mymain.c ( for portability)

=> Used uper_encode_to_buffer() in mymain.c (below ) for encoding the data to Global buffer.

Note:- Initialized NULL for default and optional Element

=> Code compiled and built successfully and I got the encoded data in the global buffer as

0A00338DC3C73CC21180C0881C020724741000000000000000A00000000FFFFD80C73CC220000005.

=> I didnt understand why there is lot of zeros are encoded in between. Does it mean the encoding is wrong.

=> when I tried to decode the encoded data using another ASN.1 decoder(MARBEN decoder) the decoding is successful, but some values are not decoded correctly. you can see the generated output of Marben decoder with some datas missing like( timestamp ,vehiclelocation latitude and longitude).

Only this encoded value is decoded (see above encoded datas)
0A00338D C3C73CC2 1180C088 1C020724 74100000 00000000 00A00000 000FFF

These datas are not taken for decoding => FD80C73CC220000005

=> My question is whatever am I doing is correct, will it work for microcontroller (without using OS)

=> Any one tried this in any 32-bit microcontroller project.

I could not able to find where the problem is, wheather I did any mistake in initialization part or anywhere else. What change i have to do to resolve this problem?

If any one find appropriate solution , Pleae help me in resolving this issue ASAP.

The schema, mymain.c and Marben decoder output are below.

Thanks in advance for your help.

SCHEMA:-

Telematics DEFINITIONS AUTOMATIC TAGS ::=
BEGIN

ECallMessage ::= SEQUENCE {
id INTEGER(0 .. 255),
msd MSDMessage
}

MSDMessage ::= SEQUENCE {
msdStructure MSDStructure,
optionalAdditionalData OptionalAdditionalData OPTIONAL,
...
}

MSDStructure ::= SEQUENCE {
messageIdentifier INTEGER(0 .. 255),
control ControlType,
vehicleIdentificationNumber VIN,
vehiclePropulsionStorageType VehiclePropulsionStorageType,
timestamp INTEGER(0 .. 4294967295),
vehicleLocation VehicleLocation,
vehicleDirection INTEGER(0 .. 255),
recentVehicleLocationN1 VehicleLocationDelta OPTIONAL,
recentVehicleLocationN2 VehicleLocationDelta OPTIONAL,
numberOfPassengers INTEGER(0 .. 255) OPTIONAL,
...

}

ControlType ::= SEQUENCE {
automaticActivation BOOLEAN,
testCall BOOLEAN,
positionCanBeTrusted BOOLEAN,
vehicleType VehicleType
}

VehicleType ::= ENUMERATED{
passengerVehicleClassM1 (1),
busesAndCoachesClassM2 (2),
busesAndCoachesClassM3 (3),
lightCommercialVehiclesClassN1 (4),
heavyDutyVehiclesClassN2 (5),
heavyDutyVehiclesClassN3 (6),
motorcyclesClassL1e (7),
motorcyclesClassL2e (8),
motorcyclesClassL3e (9),
motorcyclesClassL4e (10),
motorcyclesClassL5e (11),
motorcyclesClassL6e (12),
motorcyclesClassL7e (13),
...

}

VIN ::= SEQUENCE {
isowmi PrintableString (SIZE(3))
(FROM("A".."H"|"J".."N"|"P"|"R".."Z"|"0".."9")),
isovds PrintableString (SIZE(6))
(FROM("A".."H"|"J".."N"|"P"|"R".."Z"|"0".."9")),
isovisModelyear PrintableString (SIZE(1))
(FROM("A".."H"|"J".."N"|"P"|"R".."Z"|"0".."9")),
isovisSeqPlant PrintableString (SIZE(7))
(FROM("A".."H"|"J".."N"|"P"|"R".."Z"|"0".."9"))
}

VehiclePropulsionStorageType ::= SEQUENCE {
gasolineTankPresent BOOLEAN DEFAULT FALSE,
dieselTankPresent BOOLEAN DEFAULT FALSE,
compressedNaturalGas BOOLEAN DEFAULT FALSE,
liquidPropaneGas BOOLEAN DEFAULT FALSE,
electricEnergyStorage BOOLEAN DEFAULT FALSE,
hydrogenStorage BOOLEAN DEFAULT FALSE,
...

}

VehicleLocation ::= SEQUENCE {
positionLatitude INTEGER(-2147483648..2147483647),
positionLongitude INTEGER(-2147483648..2147483647)
}

VehicleLocationDelta ::= SEQUENCE {
latitudeDelta INTEGER (-512..511),
longitudeDelta INTEGER (-512..511)
}

OptionalAdditionalData ::= SEQUENCE {
oid OBJECT IDENTIFIER,
transparentData OCTET STRING
}
END
=========================================================================================
mymain.c:-
===============

include<stdio.h>

include<types.h>

include<ECallMessage.h>

ifdef HAVE_CONFIG_H

include <config.h>

endif

include <stdio.h>

include <types.h>

include <stdlib.h>

include <unistd.h>

include <string.h>

include <sysexits.h>

include <linux_error.h>

include <asn_application.h>

include <asn_internal.h>

include<asn_codecs.h>

char buffer[100]; // global buffer to store the encoded data.

int main()
{
ECallMessage_t autovar;
asn_enc_rval_t rval;

unsigned char str1[]="VF7";
unsigned char str2[]="FC8HZC";

unsigned char str3[]="2";
unsigned char str4[]="8708797";

BOOLEAN_t var1=1;

autovar.id=10;
autovar.msd.msdStructure.messageIdentifier=12;

autovar.msd.msdStructure.control.automaticActivation=1;

autovar.msd.msdStructure.control.testCall=1;

autovar.msd.msdStructure.control.positionCanBeTrusted=1;

autovar.msd.msdStructure.control.vehicleType=VehicleType_lightCommercialVehiclesClassN1;

autovar.msd.msdStructure.vehicleIdentificationNumber.isowmi.buf=(uint8_t*)str1;
autovar.msd.msdStructure.vehicleIdentificationNumber.isowmi.size=sizeof(str1)-1;

autovar.msd.msdStructure.vehicleIdentificationNumber.isovds.buf=(uint8_t*)str2;
autovar.msd.msdStructure.vehicleIdentificationNumber.isovds.size=sizeof(str2)-1;

autovar.msd.msdStructure.vehicleIdentificationNumber.isovisModelyear.buf=(uint8_t*)str3;
autovar.msd.msdStructure.vehicleIdentificationNumber.isovisModelyear.size=sizeof(str3)-1;

autovar.msd.msdStructure.vehicleIdentificationNumber.isovisSeqPlant.buf=(uint8_t*)str4;
autovar.msd.msdStructure.vehicleIdentificationNumber.isovisSeqPlant.size=sizeof(str4)-1;

        autovar.msd.msdStructure.vehiclePropulsionStorageType.gasolineTankPresent=&var1;
autovar.msd.msdStructure.vehiclePropulsionStorageType.dieselTankPresent=NULL;
autovar.msd.msdStructure.vehiclePropulsionStorageType.compressedNaturalGas=NULL;
autovar.msd.msdStructure.vehiclePropulsionStorageType.liquidPropaneGas=NULL;
autovar.msd.msdStructure.vehiclePropulsionStorageType.electricEnergyStorage=NULL;   
     autovar.msd.msdStructure.vehiclePropulsionStorageType.hydrogenStorage=NULL;

autovar.msd.msdStructure.timestamp=5;

autovar.msd.msdStructure.vehicleLocation.positionLatitude=12341;
autovar.msd.msdStructure.vehicleLocation.positionLongitude=15866;

autovar.msd.msdStructure.vehicleDirection=0;

autovar.msd.msdStructure.recentVehicleLocationN1=NULL;
autovar.msd.msdStructure.recentVehicleLocationN2=NULL;

     autovar.msd.msdStructure.numberOfPassengers=NULL;

autovar.msd.optionalAdditionalData=NULL;

rval=uper_encode_to_buffer(&asn_DEF_ECallMessage, &autovar, buffer, 100);

return 0;
}

Note:- Initialized NULL for default and optional Element

Marben output:-

Result of V2X decoding
V2X message: CEN ECall MSD EN 15722:2011

DECODING
<encoding>
0A00338D C3C73CC2 1180C088 1C020724 74100000 00000000 00A00000 000FFF
</encoding>

<ECallMessage>
<id>10</id>
<msd>
<msdStructure>
<messageIdentifier>12</messageIdentifier>
<control>
<automaticActivation>
<true/>
</automaticActivation>
<testCall>
<true/>
</testCall>
<positionCanBeTrusted>
<true/>
</positionCanBeTrusted>
<vehicleType>
<lightCommercialVehiclesClassN1/>
</vehicleType>
</control>
<vehicleIdentificationNumber>
<isowmi>VF7</isowmi>
<isovds>FC8HZC</isovds>
<isovisModelyear>2</isovisModelyear>
<isovisSeqPlant>8708797</isovisSeqPlant>
</vehicleIdentificationNumber>
<vehiclePropulsionStorageType>
<gasolineTankPresent>
<true/>
</gasolineTankPresent>
</vehiclePropulsionStorageType>
<timestamp>0</timestamp>
<vehicleLocation>
<positionLatitude>-2147483638</positionLatitude>
<positionLongitude>-2147483648</positionLongitude>
</vehicleLocation>
<vehicleDirection>255</vehicleDirection>
</msdStructure>
</msd>
</ECallMessage>

31 bytes decoded.
DECODING SUCCESSFUL