ASN.1 Decode Error

﹥>﹥吖頭↗ 提交于 2020-01-07 07:42:09

问题


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?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/30601478/asn-1-decode-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!