Closed
Description
I'm having problems reading SDO objects that are using UNSIGNED48. It used to work before PR #395 by @ljungholm - but it turns out to be coincidental.
I believe the root cause is that canopen doesn't support the UNSIGNED48 type (which I'll contribute in another PR). The unfortunate behavior is that due to the unknown type, the data gets truncated to 1 byte. It didn't do that before #395 .
>> upload((8192, 2), {})
<-- 602 : 40 00 20 02 00 00 00 00
--> 582 : 41 00 20 02 08 00 00 00
<< read_response() = b'A\x00 \x02\x08\x00\x00\x00'
<-- 602 : 60 00 00 00 00 00 00 00
--> 582 : 00 b2 01 20 02 91 12 00
<< read_response() = b'\x00\xb2\x01 \x02\x91\x12\x00'
<-- 602 : 70 00 00 00 00 00 00 00
--> 582 : 1d 00 00 00 00 00 00 00
<< read_response() = b'\x1d\x00\x00\x00\x00\x00\x00\x00'
data=b'\xb2\x01 \x02\x91\x12\x00\x00'
response_size = 8
var.datatype = 25 # UNSIGNED48 (unsupported)
var_size = 1 # Because len(var) on unknown datatypes is 8
data = b'\xb2' # Truncated due to ^
<< upload() = b'\xb2'
Observations:
- Reading SDO objects without OD record will preserve data as-is
- Reading SDO objects with OD, but of unsupported type will return data of size 1
ODVariable.__len__()
return 8 on unknown types, while it reports number of bits in the other types. This is why it gets truncated to one byte.
Would you agree that upload()
should return the the full data for both of the first use cases? Is the fix that ODVariable.__len__()
on unknown datatypes should return 64?