asammdf icon indicating copy to clipboard operation
asammdf copied to clipboard

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

Open MatinF opened this issue 4 years ago • 4 comments

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.

MatinF avatar Feb 03 '21 07:02 MatinF

First there should be a canmatrix release with LDF support

danielhrisca avatar Feb 09 '21 16:02 danielhrisca

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

danielhrisca avatar Feb 10 '21 09:02 danielhrisca

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:

  • Use LDF parser, ldfparser 0.8.0, to parse the LDF file.
  • Build a DBC file from the LDF parser for the signals/frames of interest. I build it per request and on the fly previous to extract_bus_logging. Ignore the scaling and units, only obtain the raw values as the DBC does not support physical conversions as the LDF does. The DBC file does not need to be complete, just the frames and signals (BO_, SG_) and some header stuff, use a complete one as a template and validate it with CANdb++ for example.
  • Call extract_bus_logging with the DBC file.
  • Get the signals as usual, values and timestamps.
  • The LDF parser provides converters to convert the raw values to physical values.

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.

ghost avatar Jul 13 '21 11:07 ghost

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)

MatinF avatar Dec 27 '22 14:12 MatinF