Closed daestx closed 5 months ago
issue #766 looks similar
Some Idea:
canmatrix for now only uses COMPU-INTERNAL-TO-PHYS
compu-methods,
Maybe your ARXML uses COMPU-PHYS-TO-INTERNAL
.
I used dbc file as input not an ARXML
Oh sorry you are right...
Do you have a chance to check the dbc itself? A factor of 0 does not make sense at all. I just want to know if it's a problem with canmatrix or with the dbc file...
So, I checked the DBC file now and identified, that the DBC is buggy. According the documentation in https://www.influxtechnology.com/post/understanding-can-dbc
So, I presume this definition of a DBC file I received is wrong, right?
So the question to me is if such an issue shall be handled in the library. I don't know as well if the scaling factor shall not be 0. So far, I didn't find any CANdbc file spec. But what I see from Vectors CANdb++ tool, the factor for the given signal was interpreted as 1.
Hi @daestx
thanks for your analysis. Yes the dbc defines the scale (=factor) to zero which is nonsense. Seems so, that candb++ has some plausibility-check here to get around with a scale of 0. So maybe canmatrix should do the same...
Maybe I'll add some warning if scale is 0 and set it to 1
should be merged
I have an issue with doing a diff on two DBC files. I get following debug info:
File "canmatrix\formats__init__.py", line 79, in loadp_flat File "canmatrix\formats__init.py", line 71, in loadp File "canmatrix\formats\init__.py", line 90, in load File "canmatrix\formats\dbc.py", line 960, in load File "canmatrix\canmatrix.py", line 450, in phys2raw decimal.InvalidOperation: [<class 'decimal.DivisionUndefined'>]
coming from this line raw_value = (self.float_factory(value) - self.float_factory(self.offset)) / self.float_factory(self.factor)
obviously, division by 0 is not handled correctly.
I changed the code as workaround
please check if there is a better solution