mercedes-benz / odxtools

odxtools is a collection of utilities to interact with the diagnostic functionality of automotive electronic control units using python
MIT License
171 stars 70 forks source link

Expected ComparamSpec, got ComparamSubset #301

Closed zariiii9003 closed 4 months ago

zariiii9003 commented 4 months ago

I tried to read a pdx file with version 2.0.1, but i got the following exception:

  File "scratch.py", line 3, in <module>
    db = odxtools.load_pdx_file(
  File "D:\PythonProjekte\odxtools\odxtools\load_pdx_file.py", line 8, in load_pdx_file
    return Database(pdx_zip=ZipFile(pdx_file))
  File "D:\PythonProjekte\odxtools\odxtools\database.py", line 91, in __init__
    self.refresh()
  File "D:\PythonProjekte\odxtools\odxtools\database.py", line 123, in refresh
    dlc._resolve_odxlinks(self._odxlinks)
  File "D:\PythonProjekte\odxtools\odxtools\diaglayercontainer.py", line 119, in _resolve_odxlinks
    protocol._resolve_odxlinks(odxlinks)
  File "D:\PythonProjekte\odxtools\odxtools\diaglayer.py", line 121, in _resolve_odxlinks
    self.diag_layer_raw._resolve_odxlinks(extended_odxlinks)
  File "D:\PythonProjekte\odxtools\odxtools\diaglayerraw.py", line 246, in _resolve_odxlinks
    self._comparam_spec = odxlinks.resolve(self.comparam_spec_ref, ComparamSpec)
  File "D:\PythonProjekte\odxtools\odxtools\odxlink.py", line 209, in resolve
    odxassert(isinstance(obj, expected_type))
  File "D:\PythonProjekte\odxtools\odxtools\exceptions.py", line 60, in odxassert
    odxraise(message, error_type)
  File "D:\PythonProjekte\odxtools\odxtools\exceptions.py", line 39, in odxraise
    raise error_type()
odxtools.exceptions.OdxError

In Database.__init__(), you instantiate ComparamSubset for COMPARAM-SPEC nodes, if the version is below 2.2. But later DiagLayerRaw._resolve_odxlinks() expects ComparamSpec objects.

andlaus commented 4 months ago

I see. ODX 2.0 is even more weird than 2.2 then because it seems that the "COMPARAM-SPEC-REF" subtag of "PROTOCOL" seems to point to "COMPARAM-SUBSET". (Given that 2.0 does not have COMPARAM-SPEC, I'd have expected to be COMPARAM-SPEC-REF to be not existant as well. Anyway, a patch is in the works...)