Binary2SignedDecimal Conversion

Issue #7 resolved
Venkatesan SoundiraRajan created an issue

Hi Tobias,

Thanks for your continuous support.

I can read the ASC log data & I'm trying to decode the message data with help of DBC information.

Here, I have used 10bit binary string for conversion to signed decimal and I have decoded log data to .csv with help of Canalyzer. The converted data is not matching with Canalyzer converted data.

For Example: Binary string is "1000011010" and corresponding signed decimal is "-176". Binary string is "0111010011" and corresponding signed decimal is "108".

I couldn't get the same with general conversion method. Can you give me any suggestions to resolve this issue.

Thanks in Advance!

Regards, Venkatesan S

Comments (5)

  1. Tobias Lorenz repo owner

    Hi Venkat,

    so normally this works in two steps:

    1. signal.decode() helps you to get the corresponding rawData out of the CAN message. This depends on startBit, bitSize, byteOrder and valueType.

    2. signal.rawToPhysicalValue() helps you to convert the raw value into the physical value. This depends on factor and offset.

    You gave two examples: 1. rawData="1000011010" (=0x21A=-486) becomes physicalValue="-176". 2. rawData="0111010011" (=0x1D3=467) becomes physicalValue="108".

    But, what were your decode values? startBit, bitSize, byteOrder and valueType? And what were your rawToPhysical values? factor and offset?

    Bye Tobias

  2. Venkatesan SoundiraRajan reporter

    Hi Tobias,

    Thanks for your kind reply.

    I have followed your suggestion and I got a expected output.

    Thanks for your continuous support.

    Thanks once again.

    Regards, Venkatesan S

  3. Log in to comment