Giter Site home page Giter Site logo

can_decoder's People

Contributors

christian-steiniche avatar matinf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

can_decoder's Issues

Decoding non J1939 CAN using a DBC

It seems the function "df_decoder.decode_frame(df_raw_1)" only supports decoding J1939 CAN with a J1939 dbc. Is it possible to get this function to support decoding standard CAN with a standard DBC (regular single frame CAN messages - no Transport protocol)?

Thanks for you help,

Question: How can the can_decoder return the names of the CAN frames as well?

Hello Team,

I am working with the can_decoder recently and I have the following use case:

I have more than 1 CAN signals with the same names on the same CAN channel, however these signals are from different CAN frames, but the current decoder dataframe returns only the names of the Signals.

I need to get also the names of the CAN frames from the can_decoder( decoded from a DBC) so that I can push these CAN signals to InfluxDB, with a prefix of the CAN frame name in front of the signal and in that way to differentiate which CAN signal is part of which CAN frame.

Thanks.

Allow for in-memory binary stream for "can_decoder.load_dbc()"

Currently only decoding a .dbc from its pathname is supported and I have a use case where I'd like to decode the contents of a .dbc file as an in-memory binary stream (see: link) function below:

can_decoder.load_dbc()

As of now, the function takes in a pathname containing the .dbc file and then reads the file in as an in-memory binary stream.

with open(dbc_file, "rb") as handle:
dbc = canmatrix.formats.load_flat(handle, "dbc")

An easy fix to support using both the pathname and in-memory binary stream would be simply to remove the line below :

with open(dbc_file, "rb") as handle:

and have the user read data from a path as part of the client code like so:

with open(mdf_path, "rb") as handle:
    dbc_file = can_decoder.load_dbc(handle)
    df_decoder = can_decoder.DataFrameDecoder(dbc_file)

then users who want to pass in the in-memory binary stream can then do:

decoded_str = base64.b64decode(...)
dbc_file  = can_decoder.load_dbc(io.BytesIO(decoded_str))

CC: @dflyon

How to decode data in a specific format

Hi,
I am using the dbc file from CSS electronics to decode CAN Data.
I have CAN data as following format:
CF00400#FFFFFFC080FFFFFF

first part is CAN Id (or frame id) : CF00400
second part (CAN data) : FFFFFFC080FFFFFF

How do I decode this CAN data using the can_decoder?
df_decoder.decode_frame(df_raw, columns_to_drop=["CAN ID", "Raw Value"])
How do I construct the df_raw based on above CAN data?

Handling of data_lists for signals with different number of columns

frame_data = np.array([a for a in data_lists], dtype=np.uint8)

When decoding, this line can sometimes lead to the following error: "ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. ...โ€

After looking into it, I believe the problem is, that for some signals not all lists (a) in in the data_list have the same number of columns. Having lines with different column numbers leads to the value error. The assignment "np.array(..)" cannot handle different numbers of columns.
e.g.: For one signal, the first "a" had 63 values, while the next "a" had only 19 values.

I solved it like this:
frame_data = pd.DataFrame([a for a in data_lists]).to_numpy(dtype=np.uint8)

This way, the the "missing columns" are replace with the default value of .to_numpy(dtype=np.uint8), which is "0".

Could you please verify this correction?

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

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'

Error in setup decoding file

Hi

I am getting this below issue while running setup_decoding_rules.py file

arxml is not supported
Traceback (most recent call last):
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\site-packages\canmatrix\formats_init_.py", line 27, in
importlib.import_module("canmatrix.formats." + module)
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\importlib_init_.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in load_unlocked
File "", line 728, in exec_module
File "", line 219, in call_with_frames_removed
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\site-packages\canmatrix\formats\arxml.py", line 34, in
import lxml.etree
ModuleNotFoundError: No module named 'lxml'
kcd is not supported
Traceback (most recent call last):
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\site-packages\canmatrix\formats_init
.py", line 27, in
importlib.import_module("canmatrix.formats." + module)
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in load_unlocked
File "", line 728, in exec_module
File "", line 219, in call_with_frames_removed
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\site-packages\canmatrix\formats\kcd.py", line 35, in
import lxml.etree
ModuleNotFoundError: No module named 'lxml'
fibex is not supported
Traceback (most recent call last):
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\site-packages\canmatrix\formats_init
.py", line 27, in
importlib.import_module("canmatrix.formats." + module)
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in load_unlocked
File "", line 728, in exec_module
File "", line 219, in call_with_frames_removed
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\site-packages\canmatrix\formats\fibex.py", line 33, in
import lxml.etree
ModuleNotFoundError: No module named 'lxml'
xls is not supported
Traceback (most recent call last):
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\site-packages\canmatrix\formats_init
.py", line 27, in
importlib.import_module("canmatrix.formats." + module)
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in load_unlocked
File "", line 728, in exec_module
File "", line 219, in call_with_frames_removed
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\site-packages\canmatrix\formats\xls.py", line 34, in
import xlrd
ModuleNotFoundError: No module named 'xlrd'
xlsx is not supported
Traceback (most recent call last):
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\site-packages\canmatrix\formats_init
.py", line 27, in
importlib.import_module("canmatrix.formats." + module)
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in load_unlocked
File "", line 728, in exec_module
File "", line 219, in call_with_frames_removed
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\site-packages\canmatrix\formats\xlsx.py", line 32, in
import xlsxwriter
ModuleNotFoundError: No module named 'xlsxwriter'
yaml is not supported
Traceback (most recent call last):
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\site-packages\canmatrix\formats_init
.py", line 27, in
importlib.import_module("canmatrix.formats." + module)
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "C:\Users\kalaa\AppData\Local\Programs\Python\Python37\lib\site-packages\canmatrix\formats\yaml.py", line 32, in
import yaml
ModuleNotFoundError: No module named 'yaml'
Traceback (most recent call last):
File "C:\Users\kalaa\OneDrive\Desktop\can_decoder\examples\setup_decoding_rules.py", line 143, in
example_setup_decoding_rules_j1939()
File "C:\Users\kalaa\OneDrive\Desktop\can_decoder\examples\setup_decoding_rules.py", line 72, in example_setup_decoding_rules_j1939
decoded_result = decode_using_rules(handle, db)
File "C:\Users\kalaa\OneDrive\Desktop\can_decoder\examples\setup_decoding_rules.py", line 30, in decode_using_rules
mdf_file = mdf_iter.MdfFile(handle)
RuntimeError: Buffer error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.