c4deszes / ldfparser

LIN Description File parser written in Python
https://c4deszes.github.io/ldfparser/
MIT License
64 stars 26 forks source link

Incorrect endianness for array type signals #125

Open nuts4coffee opened 1 year ago

nuts4coffee commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

According to the spec, The list values for array type signal is MSB order: image

However, the default transmission order for multi-byte signal values is LSB: image

The current implementation is based on MSB: https://github.com/c4deszes/ldfparser/blob/master/tests/test_frame.py#L52

Expected behavior A clear and concise description of what you expected to happen.

def test_frame_raw_encoding_array():
    signal1 = LinSignal('Signal_1', 16, [0, 0])
    frame = LinUnconditionalFrame(1, 'Frame_1', 2, {0: signal1})
    content = frame.raw({
        'Signal_1': [1, 2]
    })
    assert list(content) == [2, 1]

Stacktrace/Code If applicable, add stacktrace or code segments to help explain your problem.

Environment:

Optionally include the output of 'pipdeptree --warn silence -p ldfparser'

Additional context Add any other context about the problem here.

kayoub5 commented 1 year ago

@nuts4coffee the paragraph you are stating refer to how should a numeric number be encoded, for arrays, the concept of little endian/big endian does not really exist, endianess only applies when you try to pack a number into a multi-byte field.