Open kellerkindt opened 3 years ago
@kellerkindt Can you do me a favor and try encoding/decoding with https://github.com/mouse07410/asn1c.git (branch vlm_master
)? It should have the fix from https://github.com/riebl/asn1c.git .
Alternatively, could you provide a complete compile-able program that I can build and try on my machine?
Thanks!
I tested with my fork your UPER encoding that came from riebl/asn1c
, successfully decoded it to XER, then successfully encoded back to UPER, and cross-checked all the results with Nokalva OSS. It seems to work fine.
@mouse07410 yeah, your fork seems to produce the same valid hex value as the one from riebl:
010100000539007b0802d693a409ad27480c01001401861a9fc000420008a8
Do you know the exact reason / commit / fix?
@mouse07410 here you go https://github.com/kellerkindt/asn1c-issue-433 - an complete and compilable example project
Do you know the exact reason / commit / fix?
I think I do. It's probably https://github.com/riebl/asn1c/commit/c35ebd330b7c7e15c1bd61c9782e4259bd9bcb03, which my fork has.
Thanks very much guys, I can at least approve that after adding https://github.com/riebl/asn1c/commit/c35ebd330b7c7e15c1bd61c9782e4259bd9bcb03 my CPMs decode fine!
TLDR; I tried to encode a CPM with asn1c and decode it with asn1rs and OSS Nokalva's online decoder. Both failed while https://github.com/riebl/asn1c from @riebl and https://github.com/mouse07410/asn1c from @mouse07410 seem to work fine. Related to #383? Complete and compilable example project: https://github.com/kellerkindt/asn1c-issue-433
Simplified
Encode some Data (helper_* prefixed functions are local helpers that work as their name suggest, BAIL exits on error):
With asn1c version 0.9.28 from the ubuntu repo and the current master, the above code produces the following text and binary (hex) output:
freeSpaceConfidence
, which should be 4 but decodes to 8):C0043I: 0 error messages, 0 warning messages and 0 informatory messages issued.
ASN1STEP: Decoding PDU #1 :
rec1value CPM ::= { --TYPE INFORMATION: SEQUENCE --OFFSET: 0,0 header { --TYPE INFORMATION: SEQUENCE --OFFSET: 0,0 protocolVersion 1, --TYPE INFORMATION: INTEGER (0..255) --OFFSET: 0,0; LENGTH: 1,0 --contents: .01 messageID 1, --TYPE INFORMATION: INTEGER (0..255) --OFFSET: 1,0; LENGTH: 1,0 --contents: .01 stationID 1337 --TYPE INFORMATION: INTEGER (0..4294967295) --OFFSET: 2,0; LENGTH: 4,0 --contents: .00.00.05.39 }, cpm { --TYPE INFORMATION: SEQUENCE --OFFSET: 6,0 generationDeltaTime 123, --TYPE INFORMATION: INTEGER (0..65535) --OFFSET: 6,0; LENGTH: 2,0 --contents: .00.7B cpmParameters { --TYPE INFORMATION: SEQUENCE --OFFSET: 8,0 --extension flag: <.0> --preamble: <0001> --bit #0 = 0: 'stationDataContainer' is absent --bit #1 = 0: 'sensorInformationContainer' is absent --bit #2 = 0: 'perceivedObjectContainer' is absent --bit #3 = 1: 'freeSpaceAddendumContainer' is present managementContainer { --TYPE INFORMATION: SEQUENCE --OFFSET: 8,5 --extension flag: <0> --preamble: <0> --bit #0 = 0: 'perceivedObjectContainerSegmentInfo' is absent stationType 1, --TYPE INFORMATION: INTEGER (0..255) --OFFSET: 8,7; LENGTH: 1,0 --contents: <0.0000001> referencePosition { --TYPE INFORMATION: SEQUENCE --OFFSET: 9,7 latitude 2, --TYPE INFORMATION: INTEGER (-900000000..900000001) --OFFSET: 9,7; LENGTH: 3,7 --contents: <0>.D6.93.A4.<000010> longitude 3, --TYPE INFORMATION: INTEGER (-1800000000..1800000001) --OFFSET: 13,6; LENGTH: 4,0 --contents: <01>.AD.27.48.<000011> positionConfidenceEllipse { --TYPE INFORMATION: SEQUENCE --OFFSET: 17,6 semiMajorConfidence 4, --TYPE INFORMATION: INTEGER (0..4095) --OFFSET: 17,6; LENGTH: 1,4 --contents: <00>.01.<00> semiMinorConfidence 5, --TYPE INFORMATION: INTEGER (0..4095) --OFFSET: 19,2; LENGTH: 1,4 --contents: <000000.000101> semiMajorOrientation 6 --TYPE INFORMATION: INTEGER (0..3601) --OFFSET: 20,6; LENGTH: 1,4 --contents: <00>.01.<10> }, altitude { --TYPE INFORMATION: SEQUENCE --OFFSET: 22,2 altitudeValue 7, --TYPE INFORMATION: INTEGER (-100000..800001) --OFFSET: 22,2; LENGTH: 2,4 --contents: <000110>.1A.<100111> altitudeConfidence unavailable --TYPE INFORMATION: ENUMERATED {alt-000-01,alt-000-02,alt-000-05,alt-000-10,alt-000-20,alt-000-50,alt-001-00,alt-002-00,alt-005-00,alt-010-00,alt-020-00,alt-050-00,alt-100-00,alt-200-00,outOfRange,unavailable} --OFFSET: 24,6; LENGTH: 0,4 --contents: <11.11> } } }, freeSpaceAddendumContainer { --TYPE INFORMATION: SEQUENCE (SIZE(1..128,...)) OF OPTIONAL --OFFSET: 25,2 --extension range: <0> --length: <00000.00> (decoded as 1) { --TYPE INFORMATION: SEQUENCE --OFFSET: 26,2 --extension flag: <0> --preamble: <00> --bit #0 = 0: 'sensorIDList' is absent --bit #1 = 0: 'shadowingApplies' is absent freeSpaceConfidence 8, --TYPE INFORMATION: INTEGER (0..101) --OFFSET: 26,5; LENGTH: 0,7 --contents: <000.1000> freeSpaceArea --choice value: --TYPE INFORMATION: CHOICE --OFFSET: 27,4 --extension flag: <0> --choice index: <10> (index = 2) freeSpaceEllipse : 0 --TYPE INFORMATION: INTEGER --OFFSET: 27,7; LENGTH: 1,0 --length: <0.0000000> (decoded as 0) } }, numberOfPerceivedObjects 8 --TYPE INFORMATION: INTEGER (0..255) --OFFSET: 28,7; LENGTH: 1,0 --contents: <0.0001000> } } } --PDU padding: <0> --TOTAL LENGTH: 30,0 Successfully decoded 30 bytes. rec1value CPM ::= { header { protocolVersion 1, messageID 1, stationID 1337 }, cpm { generationDeltaTime 123, cpmParameters { managementContainer { stationType 1, referencePosition { latitude 2, longitude 3, positionConfidenceEllipse { semiMajorConfidence 4, semiMinorConfidence 5, semiMajorOrientation 6 }, altitude { altitudeValue 7, altitudeConfidence unavailable } } }, freeSpaceAddendumContainer { { freeSpaceConfidence 8, freeSpaceArea freeSpaceEllipse : 0 } }, numberOfPerceivedObjects 8 } } } Value notation is written to the file 'data.txt'.
ASN1STEP: Decoded '1' record, the remaining '1' bytes are skipped.
The output may be truncated. Please sign in to get unlimited access.
by a non-extensible SEQUENCE OF
the binary data from 2. can be decoded by asn1rs and OSS Nokalva's online decoder.