Project

General

Profile

Actions

Feature #27

closed

canbus-binding: add support for per-signal endianness (was: Little endian encoded uint16 are not properly decoded by canbus-binding)

Added by Emmanuel Jubera [SAFT] over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
High
Assignee:
Target version:
Start date:
08/16/2022
Due date:
% Done:

0%

Estimated time:
Hardware platform:
Desktop SDK (openSUSE Leap 15.3)
OS Affects Version/s:
arz-1.0
OS Fix Version/s:
arz-1.0.1
Labels:

Description

Canplayer was used to send message 0x601 = 0x010203 to canbus-binding (can0 601 [3] 01 02 03).

Here's the definition of message 0x601 (3 bytes in total, 1 uint8 followed by a uint16):

    "0x601": {
        "name": "EMOJY.SysInfo.ConvertersDC",
        "bus": "hs",
        "length": 3,
        "is_fd": false,
        "is_j1939": false,
        "is_extended": false,
        "byte_frame_is_big_endian": false,
        "bit_position_reversed": false,
        "signals": {
            "idConvertersDC": {
                "name": "EMOJY.SysInfo.ConvertersDC.idConvertersDC",
                "bit_position": 0,
                "bit_size": 8,
                "factor": 1,
                "offset": 1,
                "writable": false,
                "unit": "N/A",
                "min_value": 1,
                "max_value": 2
            },
            "softwareVersion": {
                "name": "EMOJY.SysInfo.ConvertersDC.softwareVersion",
                "bit_position": 8,
                "bit_size": 16,
                "factor": 1,
                "offset": 0,
                "writable": false,
                "unit": "N/A",
                "min_value": 0,
                "max_value": 65535
            }
        }
    }

The expected values are:

  • for EMOJY.SysInfo.ConvertersDC.idConvertersDC: 2, because the value sent is 0x01, the factor is 1 and the offset is 1.
  • for EMOJY.SysInfo.ConvertersDC.softwareVersion: 770, because the value sent is 0x0203 in little endian, the factor is 1 and the offset 0.

Here're canbus-binding logs:

<sup>[[95mDEBUG<sup>[[0m:</sup></sup> <sup>[[1m[API</sup> canbus]<sup>[[0m</sup> Data available: 16 bytes read. BCM head, opcode: 12, can_id: 1537, nframes: 1
<sup>[[95mDEBUG<sup>[[0m:</sup></sup> <sup>[[1m[API</sup> canbus]<sup>[[0m</sup> Got a legacy CAN frame
<sup>[[95mDEBUG<sup>[[0m:</sup></sup> <sup>[[1m[API</sup> canbus]<sup>[[0m</sup> Found id: 601, format: 0, length: 3, data 0102030000000000
<sup>[[95mDEBUG<sup>[[0m:</sup></sup> <sup>[[1m[API</sup> canbus]<sup>[[0m</sup> Here is the next can message : id 1537 length 3, data 12300000
<sup>[[95mDEBUG<sup>[[0m:</sup></sup> <sup>[[1m[API</sup> canbus]<sup>[[0m</sup> Decoded message from parse_signal_bitfield: 515.000000
<sup>[[95mDEBUG<sup>[[0m:</sup></sup> <sup>[[1m[API</sup> canbus]<sup>[[0m</sup> Emojy_v1.5/ CAN signals processed.

EMOJY.SysInfo.ConvertersDC.softwareVersion is decoded as 515 (0x0203) instead of 770 (0x0302).

<sup>[[95mDEBUG<sup>[[0m:</sup></sup> <sup>[[1m[API</sup> canbus]<sup>[[0m</sup> Here is the next can message : id 1537 length 3, data 12300000
<sup>[[95mDEBUG<sup>[[0m:</sup></sup> <sup>[[1m[API</sup> canbus]<sup>[[0m</sup> Decoded message from parse_signal_bitfield: 2.000000
<sup>[[95mDEBUG<sup>[[0m:</sup></sup> <sup>[[1m[API</sup> canbus]<sup>[[0m</sup> Emojy_v1.5/EMOJY.SysInfo.ConvertersDC.idConvertersDC CAN signals processed.

EMOJY.SysInfo.ConvertersDC.idConvertersDC is decoded as 2 as expected.

Actions

Also available in: Atom PDF