You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It wasn't at all obvious to me how the size of data is calculated from supplied arguments and it turns out it's IMO non-obvious/non-intuitive. In some scenarios it also appears to work but causes CANopen errors which are not easily diagnose-able.
How data argument length/size is currently calculated
Specifically, the data length is calculated based on the length of the supplied string argument:
That is, it expects the data to be expressed as two ASCII characters per byte being the hexadecimal value of the byte without any 0x prefix. e.g.: 00 or 03e8
Issues with this method of size calculation
The approach currently used leads to issues in a number of situations, including when the value is 0 or is prefixed with 0x.
This is significant because there are a number of situations where a data value of 0 is required (e.g. TPDO/RPDO remapping).
If one naively uses 0 as the argument value it results in CANopen errors such as 0x06070010 "Data type does not match". (Or, rather it should result in this error number but the value is currently incorrect, see #7.)
Alternate approaches
Ideally, a more robust size calculation would be implemented but in the interim hopefully documenting this will clarify the situation.
Current correct approach for supplying data arguments
The correct format to use is two ASCII characters per byte being the hexadecimal value of the byte without any 0x prefix.
Here is a working example (remapping a TPDO for Node ID 0x30 a.k.a 48 & modifying the event timer) to clarify how the data should be specified:
It wasn't at all obvious to me how the size of data is calculated from supplied arguments and it turns out it's IMO non-obvious/non-intuitive. In some scenarios it also appears to work but causes CANopen errors which are not easily diagnose-able.
How data argument length/size is currently calculated
Specifically, the data length is calculated based on the length of the supplied string argument:
libcanopen/bin/rs-canopen-pdo-download.c
Lines 74 to 75 in 6e4758b
libcanopen/bin/rs-canopen-sdo-download.c
Lines 74 to 78 in 6e4758b
That is, it expects the data to be expressed as two ASCII characters per byte being the hexadecimal value of the byte without any
0x
prefix. e.g.:00
or03e8
Issues with this method of size calculation
The approach currently used leads to issues in a number of situations, including when the value is
0
or is prefixed with0x
.This is significant because there are a number of situations where a data value of 0 is required (e.g. TPDO/RPDO remapping).
If one naively uses
0
as the argument value it results in CANopen errors such as0x06070010
"Data type does not match". (Or, rather it should result in this error number but the value is currently incorrect, see #7.)Alternate approaches
Ideally, a more robust size calculation would be implemented but in the interim hopefully documenting this will clarify the situation.
Current correct approach for supplying data arguments
The correct format to use is two ASCII characters per byte being the hexadecimal value of the byte without any
0x
prefix.Here is a working example (remapping a TPDO for Node ID 0x30 a.k.a 48 & modifying the event timer) to clarify how the data should be specified:
The text was updated successfully, but these errors were encountered: