1

asn1tools如何使用..从文件中解码多个 CDR 记录这是我的 python 代码:

### input file name 
fileName='D:/Python/Asn1/SIO/bHWMSC12021043012454329.dat'
## create Dict from asn file struct 
Foo = asn1tools.compile_files('asn_Huawei.asn',cache_dir='My-Cache',numeric_enums=True)
## Open binary file        
with open(fileName,"rb+") as binaryfile:
    buffer = binaryfile.read()
    ## Match and decode all record with Dict        
    decoded = Foo.decode('CallEventRecord',buffer)
    print(decoded)

print(decoded)只给出第一条记录。我的文件包含 1550 条记录....如何逐个标记我的文件asn1tools

4

2 回答 2

0

我遇到了同样的问题,试图弄清楚。您可以为此问题+1

我设法使用 pyasn1 和 asn1tools 的组合解码 multiCDR 文件,我会在完全测试后更新。

于 2021-06-24T07:47:13.730 回答
0

我会使用“decode_with_length”而不是解码。

decoded, lenDecoded = Foo.decode_with_length('CallEventRecord',buffer)
buffer = buffer[lenDecoded:]

然后循环直到缓冲区为空。

于 2021-09-08T21:14:04.080 回答