src/sdo.c
changeset 370 6fecf36df407
parent 365 9b76e0881beb
child 378 d2abf6c8c27b
equal deleted inserted replaced
369:8b67289d50b5 370:6fecf36df407
    33 /* #define DEBUG_ERR_CONSOLE_ON */
    33 /* #define DEBUG_ERR_CONSOLE_ON */
    34 
    34 
    35 #include "objacces.h"
    35 #include "objacces.h"
    36 #include "sdo.h"
    36 #include "sdo.h"
    37 #include "canfestival.h"
    37 #include "canfestival.h"
       
    38 #include "sysdep.h"
    38 
    39 
    39 /* Uncomment if your compiler does not support inline functions */
    40 /* Uncomment if your compiler does not support inline functions */
    40 #define NO_INLINE 
    41 #define NO_INLINE 
    41 
    42 
    42 #ifdef NO_INLINE
    43 #ifdef NO_INLINE
   500   UNS16 offset;
   501   UNS16 offset;
   501   UNS16 lastIndex;
   502   UNS16 lastIndex;
   502   UNS8 found = 0;
   503   UNS8 found = 0;
   503   Message m;
   504   Message m;
   504   UNS8 i;
   505   UNS8 i;
   505   UNS32 * pwCobId = NULL;
   506   UNS16 * pwCobId = NULL;
   506   UNS8 * pwNodeId = NULL;
   507   UNS8 * pwNodeId = NULL;
   507 
   508 
   508   MSG_WAR(0x3A38, "sendSDO",0);
   509   MSG_WAR(0x3A38, "sendSDO",0);
   509   if( !((d->nodeState == Operational) ||  (d->nodeState == Pre_operational ))) {
   510   if( !((d->nodeState == Operational) ||  (d->nodeState == Pre_operational ))) {
   510     MSG_WAR(0x2A39, "unable to send the SDO (not in op or pre-op mode", d->nodeState);
   511     MSG_WAR(0x2A39, "unable to send the SDO (not in op or pre-op mode", d->nodeState);
   549     if (! found){
   550     if (! found){
   550       MSG_WAR (0x2A45, "No SDO client corresponds to the mesage to send to node ", sdo.nodeId);
   551       MSG_WAR (0x2A45, "No SDO client corresponds to the mesage to send to node ", sdo.nodeId);
   551       return 0xFF;
   552       return 0xFF;
   552     }
   553     }
   553     /* Second, read the cobid client->server */
   554     /* Second, read the cobid client->server */
   554     pwCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject;
   555     pwCobId = (UNS16*) d->objdict[offset].pSubindex[1].pObject;
   555   }
   556   }
   556   /* message copy for sending */
   557   /* message copy for sending */
   557   m.cob_id = *pwCobId;
   558   m.cob_id = *pwCobId;
   558   m.rtr = NOT_A_REQUEST; 
   559   m.rtr = NOT_A_REQUEST; 
   559   /* the length of SDO must be 8 */
   560   /* the length of SDO must be 8 */
   617   s_SDO sdo;    /* SDO to transmit */
   618   s_SDO sdo;    /* SDO to transmit */
   618   UNS16 index;
   619   UNS16 index;
   619   UNS8 subIndex;
   620   UNS8 subIndex;
   620   UNS32 abortCode;
   621   UNS32 abortCode;
   621   UNS8 i,j;
   622   UNS8 i,j;
   622   UNS32 *     pCobId = NULL;
   623   UNS16 *pCobId = NULL;
   623   UNS16 offset;
   624   UNS16 offset;
   624   UNS16 lastIndex;
   625   UNS16 lastIndex;
   625 
   626 
   626   MSG_WAR(0x3A60, "proceedSDO ", 0);
   627   MSG_WAR(0x3A60, "proceedSDO ", 0);
   627   whoami = SDO_UNKNOWN;
   628   whoami = SDO_UNKNOWN;
   633   if(offset) while (offset <= lastIndex) {
   634   if(offset) while (offset <= lastIndex) {
   634      if (d->objdict[offset].bSubCount <= 1) {
   635      if (d->objdict[offset].bSubCount <= 1) {
   635 	  MSG_ERR(0x1A61, "Subindex 1  not found at index ", 0x1200 + j);
   636 	  MSG_ERR(0x1A61, "Subindex 1  not found at index ", 0x1200 + j);
   636 	  return 0xFF;
   637 	  return 0xFF;
   637 	}
   638 	}
   638       pCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject;
   639       pCobId = (UNS16*) d->objdict[offset].pSubindex[1].pObject;
   639       if ( *pCobId == (*m).cob_id ) {
   640       if ( *pCobId == (*m).cob_id ) {
   640 	whoami = SDO_SERVER;
   641 	whoami = SDO_SERVER;
   641 	MSG_WAR(0x3A62, "proceedSDO. I am server. index : ", 0x1200 + j);
   642 	MSG_WAR(0x3A62, "proceedSDO. I am server. index : ", 0x1200 + j);
   642 	/* In case of server, the node id of the client may be unknown. So we put the index minus offset */
   643 	/* In case of server, the node id of the client may be unknown. So we put the index minus offset */
   643 	/* 0x1200 where the cobid received is defined. */
   644 	/* 0x1200 where the cobid received is defined. */
   656        if (d->objdict[offset].bSubCount <= 3) {
   657        if (d->objdict[offset].bSubCount <= 3) {
   657 	 MSG_ERR(0x1A63, "Subindex 3  not found at index ", 0x1280 + j);
   658 	 MSG_ERR(0x1A63, "Subindex 3  not found at index ", 0x1280 + j);
   658 	 return 0xFF;
   659 	 return 0xFF;
   659        }
   660        }
   660        /* a) Looking for the cobid received. */
   661        /* a) Looking for the cobid received. */
   661        pCobId = (UNS32*) d->objdict[offset].pSubindex[2].pObject;
   662        pCobId = (UNS16*) d->objdict[offset].pSubindex[2].pObject;
   662        if (*pCobId == (*m).cob_id ) {
   663        if (*pCobId == (*m).cob_id ) {
   663 	 /* b) cobid found, so reading the node id of the server. */
   664 	 /* b) cobid found, so reading the node id of the server. */
   664 	 pNodeId = (UNS8*) d->objdict[offset].pSubindex[3].pObject;
   665 	 pNodeId = (UNS8*) d->objdict[offset].pSubindex[3].pObject;
   665 	 whoami = SDO_CLIENT;
   666 	 whoami = SDO_CLIENT;
   666 	 nodeId = *pNodeId;
   667 	 nodeId = *pNodeId;