riebl / vanetza

Open-source implementation of the ETSI C-ITS protocol stack
Other
197 stars 157 forks source link

Error validating DENM message on TimestampIts #212

Open liviolima80 opened 7 months ago

liviolima80 commented 7 months ago

Good morning, I'm using Vanetza for generating DENM messages. When I create the DENM message I set detectionTime and referenceTime in the following way:

vanetza::ManualRuntime runtime_; uint64_t detectionTime = runtime().now().time_since_epoch()).count(); uint64_t referenceTime= runtime().now().time_since_epoch()).count(); asn_uint642INTEGER(&denm.management.detectionTime, detectionTime); asn_uint642INTEGER(&denm.management.referenceTime, referenceTime);

I verified that detectionTime and referenceTime are correctly set to elapsed ms from 1/1/2004

When I try to validate the DENM message with the validate() function of vanetza::asn1::Denm I get the following error:

error TimestampIts: value too large (.......\vanetza\vanetza\asn1\its\TimestampIts.c:26)

Investingating the check function for TimestampIts fields there is a control where the decoded field is compared to LONG_MAX (see asn_INTEGER2long function). Since long are 4 bytes and TimestampIts comes from 8 bytes values this control will always fail.

Can you help me to understand where is the issue?

Regards

riebl commented 6 months ago

Hi @liviolima80,

are you using some custom ASN.1 stuff? Does Vanetza's ItsAsn1 test case run successfully on your system? This test case exercises the TimestampIts type using asn_uint642INTEGER and its siblings.