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

TableStructParameter: allow the table key to be specified via SNREF #288

Closed andlaus closed 5 months ago

andlaus commented 5 months ago

This requires to use a custom _resolve_snrefs() function because the parameter object itself cannot know the context from where it is called...

Andreas Lauser <andreas.lauser@mercedes-benz.com>, on behalf of MBition GmbH. Provider Information

andlaus commented 5 months ago

@QWander: can you check if this fixes your issue (#283)? If it doesn't it would be great if you provided a backtrace of the failure...

QWander commented 5 months ago

issue not solved, specific information: File "odxtools\load_pdx_file.py", line 8, in load_pdx_file return Database(pdx_zip=ZipFile(pdx_file)) File "odxtools\database.py", line 91, in init self.refresh() File "odxtools\database.py", line 128, in refresh dlc._finalize_init(self._odxlinks) File "odxtools\diaglayercontainer.py", line 129, in _finalize_init ecu_shared_data._finalize_init(odxlinks) File "odxtools\diaglayer.py", line 228, in _finalize_init self.diag_layer_raw._resolve_snrefs(self) File "odxtools\diaglayerraw.py", line 291, in _resolve_snrefs
self.diag_data_dictionary_spec._resolve_snrefs(diag_layer) File "odxtools\diagdatadictionaryspec.py", line 232, in _resolve_snrefs structure._resolve_snrefs(diag_layer) File "odxtools\basicstructure.py", line 323, in _resolve_snrefs
param._resolve_snrefs(diag_layer) File "odxtools\parameters\valueparameter.py", line 54, in _resolve_snrefs super()._resolve_snrefs(diag_layer) File "odxtools\parameters\parameterwithdop.py", line 69, in _resolv File "odxtools\parameters\parameterwithdop.py", line 69, in _resolve_snrefs self._dop = odxrequire(ddds.all_data_object_properties.get(self.dop_snref)) File "odxtools\exceptions.py", line 76, in odxrequire odxraise(message) File "odxtools\exceptions.py", line 39, in odxraise raise error_type() odxtools.exceptions.OdxError

andlaus commented 5 months ago

okay, it seems like at least you now get a different exception: instead of complaining that table-keys cannot be referenced via SNREF in table-struct parameters, it cannot resolve the DOP associated with the parameter in parameterwithdop.py.

can you find out what the type of the referenced DOP is? (change line 69 of ´parameterwithdop.py` to

if ddds.all_data_object_properties.get(self.dop_snref) is None:
  print(f"Cannot resolve SNREF to DOP '{self.dop_snref}'")
self._dop = odxrequire(ddds.all_data_object_properties.get(self.dop_snref))

after you know the short name of the DOP that cannot be resolved, you can hunt it down in your PDX file:

unzip -o $YOUR_PDX_FILE.pdx
grep -B5 "<SHORT-NAME>$NAME_OF_DOP</SHORT-NAME>" *.odx-*

I suspect that it is a DYNAMIC-ENMARKER-FIELD, which -- as far as I know -- is currently the only type of DOP which is not yet implemented...

andlaus commented 5 months ago

@kayoub5: do you see any issues with this PR? If no, I'd like to push the Green Button... @QWander: will you determine the type of the DOP which cannot be resolved?