Problem encoding data over 16 bits long using the function encode() #655
Unanswered
lee-matthews-decathlon
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have a problem encoding data using cantools (Version: 39.4.4).
I'm trying to send an offset encoded on 3 bytes via CAN. It works ok until I reach 65535, but once I go over 16 bits, the two most significant bytes disappear and become 0. However, for example, if I try sending the maximum value for 3 bytes (0xffffff), the value is encoded ok. I've tried using 4 bytes (code below), but I'm still having the same problem. Could anyone please shed some light on this?
Thanks in advance.
Lee
Example code
content = {'cmd': Cmd.LOAD,'offset': offset}
print(content)
foo = db.get_message_by_name('HostToNodeCmd')
data_test = foo.encode(content)
print(''.join('{:02x}'.format(x) for x in data_test))
Offset input values and output values.
Offset = 65535
Output : 02ffff0000000000
Offset = 65535+1
Output : 0200000100000000
offset = 4294967295
Output : 02ffffffff000000
Extract from .dbc file
SG_MUL_VAL_ 880 offset cmd 2-2;
Beta Was this translation helpful? Give feedback.
All reactions