1.关于SDO发送,SDO需要提前在0x1280中定义SDO服务,如果没有定义则无法发出SDO.
这时候可以使用
/**
* @ingroup sdo
* @brief Used to send a SDO request frame to write in a distant node dictionnary.
* @details The function Callback which must be defined in the user code is called at the
* end of the exchange. (on succes or abort). First free SDO client parameter is
* automatically initialized for specific node if not already defined.
* @param *d Pointer to a CAN object data structure
* @param nodeId Node Id of the slave
* @param index At index indicated
* @param subIndex At subIndex indicated
* @param count number of bytes to write in the dictionnary.
* @param dataType (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value.
* @param *data Pointer to data
* @param Callback Callback function
* @param endianize When not 0, data is endianized into network byte order
* when 0, data is not endianized and copied in machine native
* endianness
* @param useBlockMode true if block mode transfer is used
* @return
* - 0 is returned upon success.
* - 0xFF is returned when error occurs.
*/
UNS8 writeNetworkDictCallBackAI (CO_Data* d, UNS8 nodeId, UNS16 index,
UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize, UNS8 useBlockMode);
会自动从未使用的SDO服务中分配一个。
OD服务如下:
/* index 0x1200 : Server SDO Parameter. */
UNS8 CIA402_highestSubIndex_obj1200 = 2; /* number of subindex - 1*/
UNS32 CIA402_obj1200_COB_ID_Client_to_Server_Receive_SDO = 0x600; /* 1536 */
UNS32 CIA402_obj1200_COB_ID_Server_to_Client_Transmit_SDO = 0x580; /* 1408 */
subindex CIA402_Index1200[] =
{
{ RO, uint8, sizeof (UNS8), (void*)&CIA402_highestSubIndex_obj1200, NULL },
{ RO, uint32, sizeof (UNS32), (void*)&CIA402_obj1200_COB_ID_Client_to_Server_Receive_SDO, NULL },
{ RO, uint32, sizeof (UNS32), (void*)&CIA402_obj1200_COB_ID_Server_to_Client_Transmit_SDO, NULL }
};
/* index 0x1280 : Client SDO 1 Parameter. */
UNS8 CIA402_highestSubIndex_obj1280 = 3; /* number of subindex - 1*/
UNS32 CIA402_obj1280_COB_ID_Client_to_Server_Transmit_SDO = 0x600; /* 1537 */
UNS32 CIA402_obj1280_COB_ID_Server_to_Client_Receive_SDO = 0x580; /* 1409 */
UNS8 CIA402_obj1280_Node_ID_of_the_SDO_Server = 0x1; /* 1 */
subindex CIA402_Index1280[] =
{
{ RO, uint8, sizeof (UNS8), (void*)&CIA402_highestSubIndex_obj1280, NULL },
{ RW, uint32, sizeof (UNS32), (void*)&CIA402_obj1280_COB_ID_Client_to_Server_Transmit_SDO, NULL },
{ RW, uint32, sizeof (UNS32), (void*)&CIA402_obj1280_COB_ID_Server_to_Client_Receive_SDO, NULL },
{ RW, uint8, sizeof (UNS8), (void*)&CIA402_obj1280_Node_ID_of_the_SDO_Server, NULL }
};