I am using Objective System Inc(http://www.obj-sys.com/products/asn1c/index.php) ASN.1 Compiler
and the specification file(cdr_spec.asn) generated Java source code. The CDRS are enecoded based on format BER(Basic Encoding Rule)
Command to generate Java source:
./asn1c cdr_spec.asn -java -ber -reader -print -getset -pkgname com.testpkg
The source is generated:
ASN1C Compiler, Version 6.4.5
Copyright (c) 1997-2011 Objective Systems, Inc. All Rights Reserved.
Registered to: XXXXXX
Parsing ASN.1 definitions..
Generating Java source files for module XXX-XXX..
When I decode the first CDR file, it parses 3 lines only, the CDR file is supposed to contain more than 100 lines, so it is partially decoded.
When I try decoding another CDR file, it is failed when decoding CDR file and gave me such error:
com.objsys.asn1j.runtime.Asn1MissingRequiredException: ASN.1 decode error @ offset 832:
SEQUENCE or SET is missing a required element.
10:11:30.394 [main] ERROR com.testpkg.Test - ASN.1 decode error @ offset 832:
SEQUENCE or SET is missing a required element.
My ASN.1 specification file does not have any syntax error when I use tool checking its syntax.
Can anyone who knows ASN.1 well help me about this?
From your description, the problem appears to be with the input data, not with the actual specification itself. It's not unusual for vendors to provide specifications that don't quite line up with the data produced by their hardware.
If you can identify which element is missing, you can always try to mark the field
OPTIONAL
in the specification, regenerate the code, and try again.Alternatively, you can always contact the software and/or hardware vendors for assistance.