0
从仿真工具中,我得到一个包含一些测量点的二进制文件。我需要做的是:解析测量值并将它们存储在一个列表中。解析二进制数据的问题
根据该工具的文件,该文件的数据结构是这样的:
First 16 bytes are always the same:
Bytes 0 - 7 char[8] Header
Byte 8 u. char Version
Byte 9 u. char Byte-order (0 for little endian)
Bytes 10 - 11 u. short Record size
Bytes 12 - 15 char[4] Reserved
The quantities are following: (for example one double and one float):
Bytes 16 - 23 double Value of quantity one
Bytes 24 - 27 float Value of quantity two
Bytes 28 - 35 double Next value of quantity one
Bytes 36 - 39 float Next value of quantity two
我也知道,该编码是小端。
在我的用例中有两个数量,但他们都是浮动。
到目前为止我的代码看起来是这样的:
QuantityList来自以前的功能,并包含了数量结构。每个数量都有一个名称,dataType,lenOfBytes称为字节,并为值称为值的准备列表。
所以在我的用例有两个量有:
dataType = "<f"
bytes = 4
values=[]
解析函数完成我绘制第一数量与matplotlib
后。正如您从附件中看到的那样,在解析过程中出现了问题。
但我无法找到我的错。
您是否创建了自己的测试数据集以确定这是数据还是程序问题? –
是的,这个参考文件是由我创建的。二进制文件是正确的。 – gismo
你认为它的数据类型?文件告诉我,浮点数是32位,双精度是64位。 – gismo