ebroecker / canmatrix

Converting Can (Controller Area Network) Database Formats .arxml .dbc .dbf .kcd ...
BSD 2-Clause "Simplified" License
916 stars 401 forks source link

Value type 'is_signed': converting arxml to dbc #368

Closed Mombox closed 5 years ago

Mombox commented 5 years ago

@ebroecker

'unsigned signals' in arxml become 'signed signals' after conversion to dbc, which also affects the Min and Max values of the obtained signals...

    rawRange = 2 ** (self.size - (1 if self.**is_signed** else 0))
    return (
        factory(-rawRange if self.**is_signed** else 0),
        factory(rawRange - 1),
Funth0mas commented 5 years ago

@ilazrak Could you please provide minimal example of such arxml file?

Mombox commented 5 years ago

NewCluster_max_min.zip

@Funth0mas attached one Frame similar to my arxml data

thanks

Funth0mas commented 5 years ago

Okay I accidentally reproduced the same issue with own ARXML :-) @ebroecker, there is some signed/unsigned guessing based on BASE-TYPE name. Instead, as described in https://www.autosar.org/fileadmin/user_upload/standards/adaptive/17-10/AUTOSAR_SWS_AdaptivePlatformTypes.pdf, we shall check for <BASE-TYPE-ENCODING> value:

have you already some progress, or shall I try to fix it? I might find some time to do it.

ebroecker commented 5 years ago

@Funth0mas You are probably right... Well - you are welcome - if you find time - to fix this

Funth0mas commented 5 years ago

@ilazrak please does the linear scale used in you example file make sense? There are

                      <COMPU-NUMERATOR>
                        <V>0</V>
                        <V>1</V>
                      </COMPU-NUMERATOR>
                      <COMPU-DENOMINATOR>
                        <V>0</V>
                        <V>1</V>

If I understand correctly that is a polynomial (0 + 1x)/(0 + 1x) = 1, that means constant one... unfortunately this also leads to divide-by-zero in canmatrix because it expects such function to be expressed simply as (1 + 0x)/(1 + 0x) => offset=1/1=1, scale=0/1=0.

ebroecker commented 5 years ago

@iartez could you please try branch iss385?

Thanks

ebroecker commented 5 years ago

fixed in development now. Please reopen or open new issue if still not working as expected

BasavaprabhuB commented 3 years ago

@ilazrak please does the linear scale used in you example file make sense? There are

                      <COMPU-NUMERATOR>
                        <V>0</V>
                        <V>1</V>
                      </COMPU-NUMERATOR>
                      <COMPU-DENOMINATOR>
                        <V>0</V>
                        <V>1</V>

If I understand correctly that is a polynomial (0 + 1_x)/(0 + 1_x) = 1, that means constant one... unfortunately this also leads to divide-by-zero in canmatrix because it expects such function to be expressed simply as (1 + 0_x)/(1 + 0_x) => offset=1/1=1, scale=0/1=0.

Could you please elaborate and explain the calculation of offset and scale value? It's a little confusing due to 1 and 0 values. Thanks in advance :) hope you will take some time to rectify this minuscule query of mine!

Funth0mas commented 3 years ago

@Prabhu6296 you can find more information in https://www.autosar.org/fileadmin/user_upload/standards/classic/4-2/AUTOSAR_TPS_SoftwareComponentTemplate.pdf , section "5.5.1.1 Category Values in the context of a CompuMethod". Than search for CompuNominatorDenominator. The offset and scale is expressed as a 2nd order polynomial.