danielhrisca / asammdf

Fast Python reader and editor for ASAM MDF / MF4 (Measurement Data Format) files
GNU Lesser General Public License v3.0
648 stars 226 forks source link

FEATURE: Support LIN Description File (LDF) as supplement to DBC #480

Open MatinF opened 3 years ago

MatinF commented 3 years ago

Hi Daniel,

Since canmatrix now supports an initial implementation of LIN Description Files, I think it would be a great feature to add for an upcoming asammdf release. The LDF could be a supported format when a user seeks to decode LIN data. It would help further cement asammdf as a tool with great LIN support.

Happy to test this and I can provide sample LIN MF4 data and LDF.

danielhrisca commented 3 years ago

First there should be a canmatrix release with LDF support

danielhrisca commented 3 years ago

@MatinF the development branch has support now but you need to install the latest canmatrix development code and also ldfparser

ghost commented 3 years ago

I didn't get this to work on the development branch, but I came up with an intermediate solution that is working nicely so far:

It is too much code to share here but thought it could give you a few ideas, if I come across limitations I will let you know, I am able to extract signals, raw and physical values, and also diagnostics like this from MDF files.

MatinF commented 1 year ago

This is a minor issue so can be closed. However, I did get to test it with the attached file/LDF in 7.2.0 and I seem to be unable to get it to work. I get below error (I have latest canmatrix installed).

LIN_LDF_EXAMPLE.zip

Error: <class 'Exception'>   
Traceback (most recent call last):
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\asammdf\gui\utils.py", line 612, in run
    self.output = self._target(*self._args, **self._kwargs)
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\asammdf\mdf.py", line 4633, in extract_bus_logging
    out = self._extract_lin_logging(
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\asammdf\mdf.py", line 5024, in _extract_lin_logging
    dbc = load_can_database(Path(dbc_name))
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\asammdf\blocks\utils.py", line 1807, in load_can_database
    dbs = func(arg, import_type=import_type, key="db", **kwargs)
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\canmatrix\formats\__init__.py", line 71, in loadp
    return load(fileObject, import_type, key, **options)
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\canmatrix\formats\__init__.py", line 86, in load
    module_instance = sys.modules["canmatrix.formats." + import_type]
KeyError: 'canmatrix.formats.ldf'

Details: 2022-12-27, 15:32:51
--------------------------------------------------------------------------------
<class 'Exception'>  
Traceback (most recent call last):
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\asammdf\gui\utils.py", line 612, in run
    self.output = self._target(*self._args, **self._kwargs)
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\asammdf\mdf.py", line 4633, in extract_bus_logging
    out = self._extract_lin_logging(
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\asammdf\mdf.py", line 5024, in _extract_lin_logging
    dbc = load_can_database(Path(dbc_name))
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\asammdf\blocks\utils.py", line 1807, in load_can_database
    dbs = func(arg, import_type=import_type, key="db", **kwargs)
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\canmatrix\formats\__init__.py", line 71, in loadp
    return load(fileObject, import_type, key, **options)
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\canmatrix\formats\__init__.py", line 86, in load
    module_instance = sys.modules["canmatrix.formats." + import_type]
KeyError: 'canmatrix.formats.ldf'

--------------------------------------------------------------------------------
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\asammdf\gui\widgets\file.py", line 1661, in extract_bus_logging
    mdf = run_thread_with_progress(
  File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\asammdf\gui\utils.py", line 562, in run_thread_with_progress
    raise Exception(thr.error)