Closed munzir closed 11 years ago
"The current version of esdcan gives an error on receiving this sdo message because it is always expecting a data length of 4" This actually isn't true. The assert that checks for data size checks for data size >= 1. Which makes sense because if datasize < 1 we are not going to be able to receive anything. The actual issue was coming up because of another reason: We were not receiving any data in the first place because we had not been including the canOpenIdAddSDOResponse() in the main program so the data length was coming out to be zero hence the assertion failing. It's not failing anymore.
This issue came up when we were trying to communicate to robotiq to read status registers using sdo commands. Unlike amc, which always has 4 data bytes in all communication, robotiq has a data size = 1. The current version of esdcan gives an error on receiving this sdo message because it is always expecting a data length of 4.
For now, to be able to communicate with robotiq, we have removed the assertion that causes the fail. But a proper way to handle this should be to modify the functions involved so that they have the abilioty to handle a data length = 1 when receving sdo message.
DETAILS: The assertion is caused when using the function canSDOWriteWait_ul_u8(). This function calls the function canOpenSDOWriteWait() that calls canOpenWaitSDO() that calls canOpenTranslateCAN(). This function assigns the length=4 to the sdo_msg_t structure that receives the response. This length should have been 1 since we are receiving uint8. Then in our main function canSDOWriteWait_ul_u8() we later call canOpenGet_uint8() to read the value off the message. Here there is an assertion (that we are temporarily commenting out) that fails if the legnth is not equal to one.