我正在使用asammdf包加载MDF文件。以下代码仅适用于我的某些MDF文件。许多文件给我下面的错误。我可以在CANape中打开文件,没有问题。
在桌面应用中加载文件(有效)
from asammdf import MDF
mdf = MDF(r'\\Stnafddco123.us123.corpintra.net\veh_test\Vehicles_Data_and_Truck_Info\APTIV_logger_data\1FUJHLDR8KLXXXXXX_Trip-Detail_2019-07-16 15-18-25.mf4')
mdf
error Traceback (most recent call last)
<ipython-input-16-c9001bcab2a9> in <module>()
1 from asammdf import MDF
----> 2 mdf = MDF(r'\\Stnafddco123.us123.corpintra.net\veh_test\Vehicles_Data_and_Truck_Info\APTIV_logger_data\1FUJHLDR8KLXXXXXX_Trip-Detail_2019-07-16 15-18-25.mf4')
3 mdf
~\AppData\Local\Continuum\anaconda3\lib\site-packages\asammdf\mdf.py in __init__(self, name, version, **kwargs)
124 self._mdf = MDF3(name, **kwargs)
125 elif version in MDF4_VERSIONS:
--> 126 self._mdf = MDF4(name, **kwargs)
127 elif version in MDF2_VERSIONS:
128 self._mdf = MDF2(name, **kwargs)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\asammdf\blocks\mdf_v4.py in __init__(self, name, version, **kwargs)
247 self._file = mmap.mmap(x.fileno(), 0, access=mmap.ACCESS_READ)
248 self._from_filelike = False
--> 249 self._read(mapped=True)
250
251 self._file.close()
~\AppData\Local\Continuum\anaconda3\lib\site-packages\asammdf\blocks\mdf_v4.py in _read(self, mapped)
415 # Read channels by walking recursively in the channel group
416 # starting from the first channel
--> 417 self._read_channels(ch_addr, grp, stream, dg_cntr, ch_cntr, mapped=mapped)
418
419 cg_addr = channel_group.next_cg_addr
~\AppData\Local\Continuum\anaconda3\lib\site-packages\asammdf\blocks\mdf_v4.py in _read_channels(self, ch_addr, grp, stream, dg_cntr, ch_cntr, channel_composition, mapped)
760 at_map=self._attachments_map,
761 use_display_names=self._use_display_names,
--> 762 mapped=mapped,
763 )
764
~\AppData\Local\Continuum\anaconda3\lib\site-packages\asammdf\blocks\v4_blocks.py in __init__(self, **kwargs)
606 conv = ChannelConversion(
607 raw_bytes=raw_bytes, stream=stream, address=address,
--> 608 mapped=mapped,
609 )
610 cc_map[raw_bytes] = conv
~\AppData\Local\Continuum\anaconda3\lib\site-packages\asammdf\blocks\v4_blocks.py in __init__(self, **kwargs)
2010 self.min_phy_value,
2011 self.max_phy_value,
-> 2012 ) = v4c.CONVERSION_NONE_INIT_u(block)
2013
2014 elif conv == v4c.CONVERSION_TYPE_LIN:
error: unpack requires a buffer of 56 bytes
答案 0 :(得分:0)
使用MDFValidator打开文件时是否看到任何错误?