valgur / velodyne_decoder

Fully-featured C++/Python Velodyne packet decoder
BSD 3-Clause "New" or "Revised" License
39 stars 12 forks source link

Unexpected Attribute Error: 'bytes' object has no attribute 'data' #7

Closed Crear12 closed 1 year ago

Crear12 commented 1 year ago

Hi Martin, Thanks for creating this decoder and Happy New Year! I'm using the velodyne_decoder to decode a 5-min-long pcap file from an Alpha Prime, which can be opened and played using Veloview from the first frame to the last frame. However, while using the velodyne_decoder to open the same file, it exits at frame 234/3000, and throws this error while trying to use the "next(The generator object read_pcap)" in the while loop:

File ~\anaconda3\envs\LiDAR\lib\site-packages\velodyne_decoder__init__.py:42 in read_pcap data = dpkt.ethernet.Ethernet(buf).data.data.data AttributeError: 'bytes' object has no attribute 'data'

I suspect that the Veloview has some exception handling procedure to locate the next correct frame, because it feels like there are some disturbance in the pcap file (maybe happened during ethernet transmission) that interrupt the decoding. Do you have any suggestion for this?

Thanks, Yi

Crear12 commented 1 year ago

I temporarily edited line 42 in init.py to the following and it worked good so far:

 try:
     data = dpkt.ethernet.Ethernet(buf).data.data.data
 except:
     continue 
valgur commented 1 year ago

That's an oversight, indeed. I fixed this in the develop branch with pretty much the same solution you shared. The fix should be published with the v3.0 release soon. Thanks!