src/sdo.c
changeset 311 adf4a929cf8b
parent 306 3586cfa84705
child 365 9b76e0881beb
equal deleted inserted replaced
310:1975e546178b 311:adf4a929cf8b
   609 {
   609 {
   610   UNS8 err;
   610   UNS8 err;
   611   UNS8 line;
   611   UNS8 line;
   612   UNS8 nbBytes; /* received or to be transmited. */
   612   UNS8 nbBytes; /* received or to be transmited. */
   613   UNS8 nodeId = 0;  /* The node from which the SDO is received */
   613   UNS8 nodeId = 0;  /* The node from which the SDO is received */
   614   UNS32 nodeId_32; /* node id in 32 bits, for temporary use */
   614   UNS8 *pNodeId = NULL;
   615   UNS32 *pNodeId = NULL;
       
   616   UNS8 whoami = SDO_UNKNOWN;  /* SDO_SERVER or SDO_CLIENT.*/
   615   UNS8 whoami = SDO_UNKNOWN;  /* SDO_SERVER or SDO_CLIENT.*/
   617   UNS32 errorCode; /* while reading or writing in the local object dictionary.*/
   616   UNS32 errorCode; /* while reading or writing in the local object dictionary.*/
   618   s_SDO sdo;    /* SDO to transmit */
   617   s_SDO sdo;    /* SDO to transmit */
   619   UNS16 index;
   618   UNS16 index;
   620   UNS8 subIndex;
   619   UNS8 subIndex;
   660        }
   659        }
   661        /* a) Looking for the cobid received. */
   660        /* a) Looking for the cobid received. */
   662        pCobId = (UNS32*) d->objdict[offset].pSubindex[2].pObject;
   661        pCobId = (UNS32*) d->objdict[offset].pSubindex[2].pObject;
   663        if (*pCobId == (*m).cob_id.w ) {
   662        if (*pCobId == (*m).cob_id.w ) {
   664 	 /* b) cobid found, so reading the node id of the server. */
   663 	 /* b) cobid found, so reading the node id of the server. */
   665 	 pNodeId = (UNS32*) d->objdict[offset].pSubindex[3].pObject;
   664 	 pNodeId = (UNS8*) d->objdict[offset].pSubindex[3].pObject;
   666 	 whoami = SDO_CLIENT;
   665 	 whoami = SDO_CLIENT;
   667 	 nodeId_32 = *pNodeId;
   666 	 nodeId = *pNodeId;
   668 	 nodeId = (UNS8)nodeId_32;
       
   669 	 MSG_WAR(0x3A64, "proceedSDO. I am server. index : ", 0x1280 + j);
   667 	 MSG_WAR(0x3A64, "proceedSDO. I am server. index : ", 0x1280 + j);
   670 	 MSG_WAR(0x3A65, "                 Server nodeId : ", nodeId);
   668 	 MSG_WAR(0x3A65, "                 Server nodeId : ", nodeId);
   671 	 break;
   669 	 break;
   672 	}
   670 	}
   673        j++;
   671        j++;
  1252   UNS8 line;
  1250   UNS8 line;
  1253   s_SDO sdo;    /* SDO to transmit */
  1251   s_SDO sdo;    /* SDO to transmit */
  1254   UNS8 i, j;
  1252   UNS8 i, j;
  1255   UNS16     lastIndex;
  1253   UNS16     lastIndex;
  1256   UNS16     offset;
  1254   UNS16     offset;
  1257   UNS32      *pNodeIdServer;
  1255   UNS8      *pNodeIdServer;
  1258   UNS32      nodeIdServer;
  1256   UNS8      nodeIdServer;
  1259 
  1257 
  1260   MSG_WAR(0x3AC0, "Send SDO to write in the dictionary of node : ", nodeId);
  1258   MSG_WAR(0x3AC0, "Send SDO to write in the dictionary of node : ", nodeId);
  1261   MSG_WAR(0x3AC1, "                                   At index : ", index);
  1259   MSG_WAR(0x3AC1, "                                   At index : ", index);
  1262   MSG_WAR(0x3AC2, "                                   subIndex : ", subIndex);
  1260   MSG_WAR(0x3AC2, "                                   subIndex : ", subIndex);
  1263   MSG_WAR(0x3AC3, "                                   nb bytes : ", count);
  1261   MSG_WAR(0x3AC3, "                                   nb bytes : ", count);
  1286      if (d->objdict[offset].bSubCount <= 3) {
  1284      if (d->objdict[offset].bSubCount <= 3) {
  1287 	 MSG_ERR(0x1AC8, "Subindex 3  not found at index ", 0x1280 + i);
  1285 	 MSG_ERR(0x1AC8, "Subindex 3  not found at index ", 0x1280 + i);
  1288 	 return 0xFF;
  1286 	 return 0xFF;
  1289      }
  1287      }
  1290      /* looking for the nodeId server */
  1288      /* looking for the nodeId server */
  1291      pNodeIdServer = (UNS32*) d->objdict[offset].pSubindex[3].pObject;
  1289      pNodeIdServer = (UNS8*) d->objdict[offset].pSubindex[3].pObject;
  1292      nodeIdServer = *pNodeIdServer;
  1290      nodeIdServer = *pNodeIdServer;
  1293      MSG_WAR(0x1AD2, "index : ", 0x1280 + i);
  1291      MSG_WAR(0x1AD2, "index : ", 0x1280 + i);
  1294      MSG_WAR(0x1AD3, "nodeIdServer : ", nodeIdServer);
  1292      MSG_WAR(0x1AD3, "nodeIdServer : ", nodeIdServer);
  1295    
  1293    
  1296     if(nodeIdServer == (UNS32)nodeId) {
  1294     if(nodeIdServer == nodeId) {
  1297       SDOfound = 1;
  1295       SDOfound = 1;
  1298       break;
  1296       break;
  1299     }
  1297     }
  1300     offset++;
  1298     offset++;
  1301     i++;
  1299     i++;
  1408   UNS8 err;
  1406   UNS8 err;
  1409   UNS8 SDOfound = 0;
  1407   UNS8 SDOfound = 0;
  1410   UNS8 i;
  1408   UNS8 i;
  1411   UNS8 line;
  1409   UNS8 line;
  1412   s_SDO sdo;    /* SDO to transmit */
  1410   s_SDO sdo;    /* SDO to transmit */
  1413   UNS32      *pNodeIdServer;
  1411   UNS8      *pNodeIdServer;
  1414   UNS32      nodeIdServer;
  1412   UNS8      nodeIdServer;
  1415   UNS16     offset;
  1413   UNS16     offset;
  1416   UNS16     lastIndex;
  1414   UNS16     lastIndex;
  1417   MSG_WAR(0x3AD5, "Send SDO to read in the dictionary of node : ", nodeId);
  1415   MSG_WAR(0x3AD5, "Send SDO to read in the dictionary of node : ", nodeId);
  1418   MSG_WAR(0x3AD6, "                                  At index : ", index);
  1416   MSG_WAR(0x3AD6, "                                  At index : ", index);
  1419   MSG_WAR(0x3AD7, "                                  subIndex : ", subIndex);
  1417   MSG_WAR(0x3AD7, "                                  subIndex : ", subIndex);
  1446      if (d->objdict[offset].bSubCount <= 3) {
  1444      if (d->objdict[offset].bSubCount <= 3) {
  1447 	 MSG_ERR(0x1AE2, "Subindex 3  not found at index ", 0x1280 + i);
  1445 	 MSG_ERR(0x1AE2, "Subindex 3  not found at index ", 0x1280 + i);
  1448 	 return 0xFF;
  1446 	 return 0xFF;
  1449      }
  1447      }
  1450      /* looking for the nodeId server */
  1448      /* looking for the nodeId server */
  1451      pNodeIdServer = (UNS32*) d->objdict[offset].pSubindex[3].pObject;
  1449      pNodeIdServer = (UNS8*) d->objdict[offset].pSubindex[3].pObject;
  1452      nodeIdServer = *pNodeIdServer;
  1450      nodeIdServer = *pNodeIdServer;
  1453    
  1451    
  1454     if(nodeIdServer == (UNS32)nodeId) {
  1452     if(nodeIdServer == nodeId) {
  1455       SDOfound = 1;
  1453       SDOfound = 1;
  1456       break;
  1454       break;
  1457     }
  1455     }
  1458     offset++;
  1456     offset++;
  1459     i++;
  1457     i++;