我试图使用libtasn1.h中的asn1_create_element(),但它存在错误137。然而,使用相同定义和源代码的asn1_print_structure()可以工作。
asn1_print_structure(stdout, definitions, "IEC61850.GOOSEpdu", ASN1_PRINT_ALL); //Works fine
asn1_node * goose_pdu = NULL;
result = asn1_create_element(definitions, "IEC61850.GOOSEpdu", goose_pdu); //Exits code 137
好像是越来越没有记忆了,但是不知道是什么原因。
ASN.1代码
IEC61850 {}
DEFINITIONS IMPLICIT TAGS ::= BEGIN
GOOSEpdu ::= CHOICE {
goosePdu [APPLICATION 1] IMPLICIT IECGoosePdu
}
IECGoosePdu ::= SEQUENCE {
gocbRef [0] IMPLICIT VisibleString,
timeAllowedtoLive [1] IMPLICIT INTEGER,
datSet [2] IMPLICIT VisibleString,
goID [3] IMPLICIT VisibleString OPTIONAL,
t [4] IMPLICIT UtcTime,
stNum [5] IMPLICIT INTEGER,
sqNum [6] IMPLICIT INTEGER,
test [7] IMPLICIT BOOLEAN DEFAULT FALSE,
confRev [8] IMPLICIT INTEGER,
ndsCom [9] IMPLICIT BOOLEAN DEFAULT FALSE,
numDatSetEntries [10] IMPLICIT INTEGER,
allData [11] IMPLICIT SEQUENCE OF Data --,
-- security [12] ANY OPTIONAL
-- reserved for digital signature
}
UtcTime ::= OCTET STRING -- format and size defined in 8.1.3.6.
TimeOfDay ::= OCTET STRING -- (SIZE (4 | 6))
FloatingPoint ::= OCTET STRING
Data ::= CHOICE
{
-- context tag 0 is reserved for AccessResult
array [1] IMPLICIT SEQUENCE OF Data,
structure [2] IMPLICIT SEQUENCE OF Data,
boolean [3] IMPLICIT BOOLEAN,
bit-string [4] IMPLICIT BIT STRING,
integer [5] IMPLICIT INTEGER,
unsigned [6] IMPLICIT INTEGER,
floating-point [7] IMPLICIT FloatingPoint,
-- real [8] IMPLICIT REAL,
octet-string [9] IMPLICIT OCTET STRING,
visible-string [10] IMPLICIT VisibleString,
binary-time [12] IMPLICIT TimeOfDay,
bcd [13] IMPLICIT INTEGER,
booleanArray [14] IMPLICIT BIT STRING,
objId [15] IMPLICIT OBJECT IDENTIFIER,
mMSString [16] IMPLICIT MMSString,
utc-time [17] IMPLICIT UtcTime -- added by IEC61850 8.1 G3
}
MMSString ::= UTF8String
END
1条答案
按热度按时间r8uurelv1#
通过使用初始化的变量简单地解决: