CSS-Electronics / can_decoder

API module for decoding raw CAN bus data to physical values
MIT License
67 stars 14 forks source link

Attribution Error: 'can_decoder' has no attribute 'load_dbc' #11

Open Sohaibbbb opened 5 months ago

Sohaibbbb commented 5 months ago

I have been using this code from the documentation to decode my MF4 files but for the past few days, the code has stopped working. Following is the code:

import can_decoder import mdf_iter

mdf_path = "00000001.MF4" dbc_path = "j1939.dbc"

db = can_decoder.load_dbc(dbc_path) df_decoder = can_decoder.DataFrameDecoder(db)

with open(mdf_path, "rb") as handle: mdf_file = mdf_iter.MdfFile(handle) df_raw = mdf_file.get_data_frame()

df_phys = df_decoder.decode_frame(df_raw) print(df_phys)

Now its showing error as follows: Attribution Error: 'can_decoder' has no attribute 'load_dbc'

MatinF commented 5 months ago

Hi, can you please share a replicable example zip file and a pip freeze of your requirements in the virtual environment you're using?

Sohaibbbb commented 4 months ago

Hi Martin,

I hope this email finds you well. The issue I was facing was resolved that load_dbc was the attribute of DBCLoader instead of can_decoder. It would be better if you update the documentation to change the code as follows:

-----------Rest of the Code------------ from can_decoder import DBCLoader from can_decoder import DataFrameDecoder

Load the DBC file

db = DBCLoader.load_dbc(dbc_path) df_decoder = DataFrameDecoder(db) -----------Rest of the Code------------

Sorry for the late reply. If you have any questions please let me know.

Best regards Sohaib Raza

On Mon, Feb 5, 2024 at 12:43 PM Martin Falch @.***> wrote:

Hi, can you please share a replicable example zip file and a pip freeze of your requirements in the virtual environment you're using?

— Reply to this email directly, view it on GitHub https://github.com/CSS-Electronics/can_decoder/issues/11#issuecomment-1926390856, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATW7SKHM5CVAKTOYVTQ5EKTYSCEQZAVCNFSM6AAAAABCYW2IPWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRWGM4TAOBVGY . You are receiving this because you authored the thread.Message ID: @.***>