/* #define DEBUG_WAR_CONSOLE_ON */
/* #define DEBUG_ERR_CONSOLE_ON */
-#include "objacces.h"
-#include "sdo.h"
#include "canfestival.h"
+#include "sysdep.h"
/* Uncomment if your compiler does not support inline functions */
#define NO_INLINE
errorCode = getODentry(d, d->transfers[line].index,
d->transfers[line].subIndex,
(void *)d->transfers[line].data,
- &size, &dataType, 0);
+ &size, &dataType, 1);
if (errorCode != OD_SUCCESSFUL)
return errorCode;
d->transfers[line].count = size;
d->transfers[line].offset = 0;
-#if 0
- /*Me laisser a, please ! (FD)*/
- {
- UNS8 i;
- for (i = 0 ; i < 10 ; i++) {
- MSG_WAR(i, "data= ", d->transfers[line].data[i]);
- }
- }
-#endif
+
return 0;
}
}
/*get the server->client cobid*/
- if ( whoami == SDO_SERVER ) {/*case server. Easy because today only one server SDO is authorized in CanFestival*/
+ if ( whoami == SDO_SERVER ) {/*case server. only one SDO server*/
offset = d->firstIndex->SDO_SVR;
if (offset == 0) {
MSG_ERR(0x1A42, "SendSDO : No SDO server found", 0);
MSG_ERR(0x1A42, "SendSDO : No SDO client index found", 0);
return 0xFF;
}
- /* First, have to find at the index where is defined the communication with the server node */
+ /* find index for communication server node */
while (offset <= lastIndex){
MSG_WAR(0x3A43,"Reading index : ", 0x1280 + sdoNum);
if (d->objdict[offset].bSubCount <= 3) {
MSG_WAR (0x2A45, "No SDO client corresponds to the mesage to send to node ", sdo.nodeId);
return 0xFF;
}
- /* Second, read the cobid client->server */
+ /* read the client->server cobid */
pwCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject;
}
/* message copy for sending */
- m.cob_id.w = *pwCobId;
+ m.cob_id = UNS16_LE(*pwCobId);
m.rtr = NOT_A_REQUEST;
/* the length of SDO must be 8 */
m.len = 8;
UNS8 line;
UNS8 nbBytes; /* received or to be transmited. */
UNS8 nodeId = 0; /* The node from which the SDO is received */
- UNS32 nodeId_32; /* node id in 32 bits, for temporary use */
- UNS32 *pNodeId = NULL;
+ UNS8 *pNodeId = NULL;
UNS8 whoami = SDO_UNKNOWN; /* SDO_SERVER or SDO_CLIENT.*/
UNS32 errorCode; /* while reading or writing in the local object dictionary.*/
s_SDO sdo; /* SDO to transmit */
UNS8 subIndex;
UNS32 abortCode;
UNS8 i,j;
- UNS32 * pCobId = NULL;
+ UNS32 *pCobId = NULL;
UNS16 offset;
UNS16 lastIndex;
return 0xFF;
}
pCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject;
- if ( *pCobId == (*m).cob_id.w ) {
+ if ( *pCobId == UNS16_LE(m->cob_id) ) {
whoami = SDO_SERVER;
MSG_WAR(0x3A62, "proceedSDO. I am server. index : ", 0x1200 + j);
/* In case of server, the node id of the client may be unknown. So we put the index minus offset */
}
/* a) Looking for the cobid received. */
pCobId = (UNS32*) d->objdict[offset].pSubindex[2].pObject;
- if (*pCobId == (*m).cob_id.w ) {
+ if (*pCobId == UNS16_LE(m->cob_id) ) {
/* b) cobid found, so reading the node id of the server. */
- pNodeId = (UNS32*) d->objdict[offset].pSubindex[3].pObject;
+ pNodeId = (UNS8*) d->objdict[offset].pSubindex[3].pObject;
whoami = SDO_CLIENT;
- nodeId_32 = *pNodeId;
- nodeId = (UNS8)nodeId_32;
+ nodeId = *pNodeId;
MSG_WAR(0x3A64, "proceedSDO. I am server. index : ", 0x1280 + j);
MSG_WAR(0x3A65, " Server nodeId : ", nodeId);
break;
/* Test if the size of the SDO is ok */
if ( (*m).len != 8) {
- MSG_ERR(0x1A67, "Error size SDO. CobId : ", (*m).cob_id.w);
+ MSG_ERR(0x1A67, "Error size SDO. CobId : ", UNS16_LE(m->cob_id));
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_GENERAL_ERROR);
return 0xFF;
}
MSG_WAR(0x3A68, "I am CLIENT. Received SDO from nodeId : ", nodeId);
}
else {
- MSG_WAR(0x3A69, "I am SERVER. Received SDO cobId : ", (*m).cob_id.w);
+ MSG_WAR(0x3A69, "I am SERVER. Received SDO cobId : ", UNS16_LE(m->cob_id));
}
/* Testing the command specifier */
break;
case 4:
- abortCode = (*m).data[3] |
+ abortCode =
+ (UNS32)m->data[4] |
((UNS32)m->data[5] << 8) |
((UNS32)m->data[6] << 16) |
((UNS32)m->data[7] << 24);
UNS8 i, j;
UNS16 lastIndex;
UNS16 offset;
- UNS32 *pNodeIdServer;
- UNS32 nodeIdServer;
+ UNS8 *pNodeIdServer;
+ UNS8 nodeIdServer;
MSG_WAR(0x3AC0, "Send SDO to write in the dictionary of node : ", nodeId);
MSG_WAR(0x3AC1, " At index : ", index);
return 0xFF;
}
/* looking for the nodeId server */
- pNodeIdServer = (UNS32*) d->objdict[offset].pSubindex[3].pObject;
+ pNodeIdServer = (UNS8*) d->objdict[offset].pSubindex[3].pObject;
nodeIdServer = *pNodeIdServer;
MSG_WAR(0x1AD2, "index : ", 0x1280 + i);
MSG_WAR(0x1AD3, "nodeIdServer : ", nodeIdServer);
- if(nodeIdServer == (UNS32)nodeId) {
+ if(nodeIdServer == nodeId) {
SDOfound = 1;
break;
}
UNS8 i;
UNS8 line;
s_SDO sdo; /* SDO to transmit */
- UNS32 *pNodeIdServer;
- UNS32 nodeIdServer;
+ UNS8 *pNodeIdServer;
+ UNS8 nodeIdServer;
UNS16 offset;
UNS16 lastIndex;
MSG_WAR(0x3AD5, "Send SDO to read in the dictionary of node : ", nodeId);
return 0xFF;
}
/* looking for the nodeId server */
- pNodeIdServer = (UNS32*) d->objdict[offset].pSubindex[3].pObject;
+ pNodeIdServer = (UNS8*) d->objdict[offset].pSubindex[3].pObject;
nodeIdServer = *pNodeIdServer;
- if(nodeIdServer == (UNS32)nodeId) {
+ if(nodeIdServer == nodeId) {
SDOfound = 1;
break;
}
}
/*!
-**
-**
-** @param d
-** @param nodeId
-** @param data
-** @param size
-** @param abortCode
-**
-** @return
+**
+**
+** @param d
+** @param nodeId
+** @param data
+** @param size pointer to expected size, changed into returned size. Expected size will be truncated to transfered data size
+** @param abortCode
+**
+** @return
**/
UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, UNS8 *size,
UNS32 * abortCode)
return d->transfers[line].state;
/* Transfert is finished. Put the value in the data. */
- * size = (UNS8)d->transfers[line].count;
+ /* use transfers[line].count as max size */
+ if( (UNS8)d->transfers[line].count < *size )
+ *size = (UNS8)d->transfers[line].count;
for ( i = 0 ; i < *size ; i++) {
# ifdef CANOPEN_BIG_ENDIAN
if (d->transfers[line].dataType != visible_string)