src/pdo.c
changeset 71 95cd3376cc9f
parent 0 4472ee7c6c3e
child 90 7df322d86ae1
equal deleted inserted replaced
70:f36f09f08b62 71:95cd3376cc9f
    28   UNS8 i;
    28   UNS8 i;
    29   if( d->nodeState == Operational ) {
    29   if( d->nodeState == Operational ) {
    30     Message m;
    30     Message m;
    31 
    31 
    32     /* Message copy for sending */
    32     /* Message copy for sending */
    33     m.cob_id.w = pdo.cobId & 0x7FF; // Because the cobId is 11 bytes length
    33     m.cob_id.w = pdo.cobId & 0x7FF; /* Because the cobId is 11 bytes length */
    34     if ( req == NOT_A_REQUEST ) {
    34     if ( req == NOT_A_REQUEST ) {
    35       UNS8 i;
    35       UNS8 i;
    36       m.rtr = NOT_A_REQUEST;
    36       m.rtr = NOT_A_REQUEST;
    37       m.len = pdo.len;
    37       m.len = pdo.len;
    38       //memcpy(&m.data, &pdo.data, m.len);
    38       /* memcpy(&m.data, &pdo.data, m.len); */
    39       // This Memcpy depends on packing structure. Avoid
    39       /* This Memcpy depends on packing structure. Avoid */
    40       for (i = 0 ; i < pdo.len ; i++)
    40       for (i = 0 ; i < pdo.len ; i++)
    41 	m.data[i] = pdo.data[i];
    41 	m.data[i] = pdo.data[i];
    42     }
    42     }
    43     else {
    43     else {
    44       m.rtr = REQUEST;
    44       m.rtr = REQUEST;
    50     for (i = 0 ; i < m.len ; i++) {
    50     for (i = 0 ; i < m.len ; i++) {
    51       MSG_WAR(0x3903,"           data : ", m.data[i]);
    51       MSG_WAR(0x3903,"           data : ", m.data[i]);
    52     }
    52     }
    53 		  
    53 		  
    54     return (*d->canSend)(&m);
    54     return (*d->canSend)(&m);
    55   } // end if 
    55   } /* end if */
    56   return 0xFF;
    56   return 0xFF;
    57 }
    57 }
    58 
    58 
    59 /***************************************************************************/
    59 /***************************************************************************/
    60 UNS8 PDOmGR(CO_Data* d, UNS32 cobId) //PDO Manager
    60 UNS8 PDOmGR(CO_Data* d, UNS32 cobId) /* PDO Manager */
    61 {
    61 {
    62   UNS8 res;
    62   UNS8 res;
    63   UNS8 i;
    63   UNS8 i;
    64   s_PDO pdo;
    64   s_PDO pdo;
    65 
    65 
    67 	
    67 	
    68   /* if PDO is waiting for transmission,
    68   /* if PDO is waiting for transmission,
    69      preparation of the message to send */
    69      preparation of the message to send */
    70     pdo.cobId = cobId;
    70     pdo.cobId = cobId;
    71     pdo.len =  d->process_var.count;
    71     pdo.len =  d->process_var.count;
    72     //memcpy(&(pdo.data), &(process_var.data), pdo.len);
    72     /* memcpy(&(pdo.data), &(process_var.data), pdo.len); */
    73     // Ce memcpy devrait être portable
    73     /* Ce memcpy devrait être portable */
    74     for ( i = 0 ; i < pdo.len ; i++) 
    74     for ( i = 0 ; i < pdo.len ; i++) 
    75       pdo.data[i] = d->process_var.data[i];
    75       pdo.data[i] = d->process_var.data[i];
    76 
    76 
    77     res = sendPDO(d, pdo, NOT_A_REQUEST);
    77     res = sendPDO(d, pdo, NOT_A_REQUEST);
    78 
    78 
    79     return res;
    79     return res;
    80 }
    80 }
    81 
    81 
    82 /**************************************************************************/
    82 /**************************************************************************/
    83 UNS8 buildPDO(CO_Data* d, UNS16 index)
    83 UNS8 buildPDO(CO_Data* d, UNS16 index)
    84 { // DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails.	
    84 { /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails. */	
    85   UNS16 ind;
    85   UNS16 ind;
    86   UNS8      subInd;
    86   UNS8      subInd;
    87 
    87 
    88   UNS8 *     pMappingCount = NULL;      // count of mapped objects...
    88   UNS8 *     pMappingCount = NULL;      /* count of mapped objects... */
    89   // pointer to the var which is mapped to a pdo
    89   /* pointer to the var which is mapped to a pdo */
    90 //  void *     pMappedAppObject = NULL; 
    90 /*  void *     pMappedAppObject = NULL;  */
    91   // pointer fo the var which holds the mapping parameter of an mapping entry  
    91   /* pointer fo the var which holds the mapping parameter of an mapping entry  */ 
    92   UNS32 *    pMappingParameter = NULL;  
    92   UNS32 *    pMappingParameter = NULL;  
    93 
    93 
    94   UNS8      Size;
    94   UNS8      Size;
    95   UNS8      dataType;
    95   UNS8      dataType;
    96   UNS8      offset;
    96   UNS8      offset;
   116   {
   116   {
   117 	  /* get mapped objects number to transmit with this PDO */
   117 	  /* get mapped objects number to transmit with this PDO */
   118 	  pMappingCount = (d->objdict + offsetObjdict + ind)->pSubindex[0].pObject;
   118 	  pMappingCount = (d->objdict + offsetObjdict + ind)->pSubindex[0].pObject;
   119 	  MSG_WAR(0x3912, "Nb maped objects : ",* pMappingCount);
   119 	  MSG_WAR(0x3912, "Nb maped objects : ",* pMappingCount);
   120 	  MSG_WAR(0x3913, "        at index : ", 0x1A00 + ind);
   120 	  MSG_WAR(0x3913, "        at index : ", 0x1A00 + ind);
   121 	  while (subInd < *pMappingCount) { // Loop on mapped variables
   121 	  while (subInd < *pMappingCount) { /* Loop on mapped variables */
   122 	    /* get mapping parameters */
   122 	    /* get mapping parameters */
   123 	    pMappingParameter = (d->objdict + offsetObjdict + ind)->pSubindex[subInd + 1].pObject;
   123 	    pMappingParameter = (d->objdict + offsetObjdict + ind)->pSubindex[subInd + 1].pObject;
   124 	    MSG_WAR(0x3914, "Get the mapping      at index : ", (UNS16)0x1A00 + ind);
   124 	    MSG_WAR(0x3914, "Get the mapping      at index : ", (UNS16)0x1A00 + ind);
   125 	    MSG_WAR(0x3915, "                     subIndex : ", subInd + 1);
   125 	    MSG_WAR(0x3915, "                     subIndex : ", subInd + 1);
   126 	    MSG_WAR(0x3916, "                     value    : ", *(UNS32 *)pMappingParameter);
   126 	    MSG_WAR(0x3916, "                     value    : ", *(UNS32 *)pMappingParameter);
   127 	    // Get the mapped variable
   127 	    /* Get the mapped variable */
   128 	     Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
   128 	     Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
   129 	     objDict = getODentry(d, (UNS16)((*pMappingParameter) >> 16),
   129 	     objDict = getODentry(d, (UNS16)((*pMappingParameter) >> 16),
   130 				    (UNS8)(((*pMappingParameter) >> 8 ) & 0x000000FF),
   130 				    (UNS8)(((*pMappingParameter) >> 8 ) & 0x000000FF),
   131 				    (void *)&d->process_var.data[offset], &Size, &dataType, 0 ); 
   131 				    (void *)&d->process_var.data[offset], &Size, &dataType, 0 ); 
   132 
   132 
   138 	     } 
   138 	     } 
   139 
   139 
   140 	      offset += Size;
   140 	      offset += Size;
   141 	      d->process_var.count = offset;
   141 	      d->process_var.count = offset;
   142 	      subInd++;					
   142 	      subInd++;					
   143 	}// end Loop on mapped variables 
   143 	}/* end Loop on mapped variables  */
   144   }
   144   }
   145   return 0;
   145   return 0;
   146 }
   146 }
   147 
   147 
   148 /**************************************************************************/
   148 /**************************************************************************/
   152   UNS16          offset;
   152   UNS16          offset;
   153   UNS16          lastIndex;
   153   UNS16          lastIndex;
   154   UNS8           err;
   154   UNS8           err;
   155 
   155 
   156   MSG_WAR(0x3930, "sendPDOrequest ",0);  
   156   MSG_WAR(0x3930, "sendPDOrequest ",0);  
   157   // Sending the request only if the cobid have been found on the PDO receive
   157   /* Sending the request only if the cobid have been found on the PDO receive */
   158   // part dictionary
   158   /* part dictionary */
   159   offset = d->firstIndex->PDO_RCV;
   159   offset = d->firstIndex->PDO_RCV;
   160   lastIndex = d->lastIndex->PDO_RCV;
   160   lastIndex = d->lastIndex->PDO_RCV;
   161   if (offset)
   161   if (offset)
   162 	  while (offset <= lastIndex) {
   162 	  while (offset <= lastIndex) {
   163 	    /*get the CobId*/
   163 	    /*get the CobId*/
   180 
   180 
   181 /***********************************************************************/
   181 /***********************************************************************/
   182 UNS8 proceedPDO(CO_Data* d, Message *m)
   182 UNS8 proceedPDO(CO_Data* d, Message *m)
   183 {		
   183 {		
   184   UNS8   numPdo;
   184   UNS8   numPdo;
   185   UNS8   numMap;  // Number of the mapped varable                           
   185   UNS8   numMap;  /* Number of the mapped varable */                      
   186   UNS8 i;
   186   UNS8 i;
   187   UNS8 *     pMappingCount = NULL;    // count of mapped objects...
   187   UNS8 *     pMappingCount = NULL;    /* count of mapped objects... */
   188   // pointer to the var which is mapped to a pdo...
   188   /* pointer to the var which is mapped to a pdo... */
   189 //  void *     pMappedAppObject = NULL;  
   189 /*  void *     pMappedAppObject = NULL;   */
   190   // pointer fo the var which holds the mapping parameter of an mapping entry
   190   /* pointer fo the var which holds the mapping parameter of an mapping entry */
   191   UNS32 *    pMappingParameter = NULL;  
   191   UNS32 *    pMappingParameter = NULL;  
   192   UNS8  *    pTransmissionType = NULL; // pointer to the transmission type
   192   UNS8  *    pTransmissionType = NULL; /* pointer to the transmission type */
   193   UNS32 *    pwCobId = NULL;
   193   UNS32 *    pwCobId = NULL;
   194   UNS8       Size;
   194   UNS8       Size;
   195   UNS8       dataType;
   195   UNS8       dataType;
   196   UNS8       offset;
   196   UNS8       offset;
   197   UNS8       status;
   197   UNS8       status;
   202 
   202 
   203   MSG_WAR(0x3935, "proceedPDO, cobID : ", ((*m).cob_id.w & 0x7ff)); 
   203   MSG_WAR(0x3935, "proceedPDO, cobID : ", ((*m).cob_id.w & 0x7ff)); 
   204   offset = 0x00;
   204   offset = 0x00;
   205   numPdo = 0;
   205   numPdo = 0;
   206   numMap = 0;
   206   numMap = 0;
   207   if((*m).rtr == NOT_A_REQUEST ) { // The PDO received is not a request.
   207   if((*m).rtr == NOT_A_REQUEST ) { /* The PDO received is not a request. */
   208     offsetObjdict = d->firstIndex->PDO_RCV;
   208     offsetObjdict = d->firstIndex->PDO_RCV;
   209     lastIndex = d->lastIndex->PDO_RCV;
   209     lastIndex = d->lastIndex->PDO_RCV;
   210 
   210 
   211     /* study of all the PDO stored in the dictionary */   
   211     /* study of all the PDO stored in the dictionary */   
   212     if(offsetObjdict)
   212     if(offsetObjdict)
   213 	    while (offsetObjdict <= lastIndex) {
   213 	    while (offsetObjdict <= lastIndex) {
   214 					
   214 					
   215 	      switch( status ) {
   215 	      switch( status ) {
   216 						
   216 						
   217 	        case state1:	/* data are stored in process_var array */
   217 	        case state1:	/* data are stored in process_var array */
   218 		  //memcpy(&(process_var.data), &m->data, (*m).len);
   218 		  /* memcpy(&(process_var.data), &m->data, (*m).len); */
   219 		  // Ce memcpy devrait être portable.
   219 		  /* Ce memcpy devrait être portable. */
   220 		  for ( i = 0 ; i < m->len ; i++) 
   220 		  for ( i = 0 ; i < m->len ; i++) 
   221 		    d->process_var.data[i] = m->data[i];
   221 		    d->process_var.data[i] = m->data[i];
   222 		  d->process_var.count = (*m).len;
   222 		  d->process_var.count = (*m).len;
   223 	
   223 	
   224 		  status = state2; 
   224 		  status = state2; 
   226 	
   226 	
   227 		case state2:
   227 		case state2:
   228 		  /* get CobId of the dictionary correspondant to the received PDO */
   228 		  /* get CobId of the dictionary correspondant to the received PDO */
   229 	          pwCobId = d->objdict[offsetObjdict].pSubindex[1].pObject;
   229 	          pwCobId = d->objdict[offsetObjdict].pSubindex[1].pObject;
   230 		  /* check the CobId coherance */
   230 		  /* check the CobId coherance */
   231 		  //*pwCobId is the cobId read in the dictionary at the state 3
   231 		  /*pwCobId is the cobId read in the dictionary at the state 3 */
   232 		  if ( *pwCobId == (*m).cob_id.w ){
   232 		  if ( *pwCobId == (*m).cob_id.w ){
   233 		    // The cobId is recognized
   233 		    /* The cobId is recognized */
   234 		    status = state4;
   234 		    status = state4;
   235 		    MSG_WAR(0x3936, "cobId found at index ", 0x1400 + numPdo);
   235 		    MSG_WAR(0x3936, "cobId found at index ", 0x1400 + numPdo);
   236 		    break;
   236 		    break;
   237 		  }
   237 		  }
   238 		  else {
   238 		  else {
   239 		    // cobId received does not match with those write in the dictionnary
   239 		    /* cobId received does not match with those write in the dictionnary */
   240 		    numPdo++;
   240 		    numPdo++;
   241 		    offsetObjdict++;
   241 		    offsetObjdict++;
   242 		    status = state2;
   242 		    status = state2;
   243 		    break;
   243 		    break;
   244 		  }
   244 		  }
   245 	
   245 	
   246 		case state4:	/* get mapped objects number */
   246 		case state4:	/* get mapped objects number */
   247 		  // The cobId of the message received has been found in the dictionnary.
   247 		  /* The cobId of the message received has been found in the dictionnary. */
   248 		  offsetObjdict = d->firstIndex->PDO_RCV_MAP;
   248 		  offsetObjdict = d->firstIndex->PDO_RCV_MAP;
   249 		  lastIndex = d->lastIndex->PDO_RCV_MAP;
   249 		  lastIndex = d->lastIndex->PDO_RCV_MAP;
   250 		  pMappingCount = (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject;	  
   250 		  pMappingCount = (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject;	  
   251 		  numMap = 0;
   251 		  numMap = 0;
   252 		  while (numMap < *pMappingCount) {
   252 		  while (numMap < *pMappingCount) {
   253 		    pMappingParameter = (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject;
   253 		    pMappingParameter = (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject;
   254 		    if (pMappingParameter == NULL) {
   254 		    if (pMappingParameter == NULL) {
   255 		      MSG_ERR(0x1937, "Couldn't get mapping parameter : ", numMap + 1); 
   255 		      MSG_ERR(0x1937, "Couldn't get mapping parameter : ", numMap + 1); 
   256 		      return 0xFF;
   256 		      return 0xFF;
   257 		    }
   257 		    }
   258 		    // Get the addresse of the mapped variable.
   258 		    /* Get the addresse of the mapped variable. */
   259 		    // detail of *pMappingParameter :
   259 		    /* detail of *pMappingParameter : */
   260 	            // The 16 hight bits contains the index, the medium 8 bits contains the subindex, 
   260 	            /* The 16 hight bits contains the index, the medium 8 bits contains the subindex, */
   261 		    // and the lower 8 bits contains the size of the mapped variable.
   261 		    /* and the lower 8 bits contains the size of the mapped variable. */
   262 
   262 
   263 		    Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
   263 		    Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
   264 
   264 
   265 		    objDict = setODentry(d, (UNS16)((*pMappingParameter) >> 16),
   265 		    objDict = setODentry(d, (UNS16)((*pMappingParameter) >> 16),
   266 				            (UNS8)(((*pMappingParameter) >> 8 ) & 0xFF),
   266 				            (UNS8)(((*pMappingParameter) >> 8 ) & 0xFF),
   274 		    }
   274 		    }
   275 
   275 
   276 		    MSG_WAR(0x3942, "Variable updated with value received by PDO cobid : ", m->cob_id.w);  
   276 		    MSG_WAR(0x3942, "Variable updated with value received by PDO cobid : ", m->cob_id.w);  
   277 		    MSG_WAR(0x3943, "         Mapped at index : ", (*pMappingParameter) >> 16);
   277 		    MSG_WAR(0x3943, "         Mapped at index : ", (*pMappingParameter) >> 16);
   278 		    MSG_WAR(0x3944, "                subindex : ", ((*pMappingParameter) >> 8 ) & 0xFF);
   278 		    MSG_WAR(0x3944, "                subindex : ", ((*pMappingParameter) >> 8 ) & 0xFF);
   279 //		    MSG_WAR(0x3945, "                data : ",*((UNS32 *)pMappedAppObject));
   279 		    /* MSG_WAR(0x3945, "                data : ",*((UNS32 *)pMappedAppObject)); */
   280 		    offset += Size;
   280 		    offset += Size;
   281 		    numMap++;
   281 		    numMap++;
   282 		  } // end loop while on mapped variables
   282 		  } /* end loop while on mapped variables */
   283 		  
   283 		  
   284 		  offset=0x00;		
   284 		  offset=0x00;		
   285 		  numMap = 0;
   285 		  numMap = 0;
   286 		  return 0;
   286 		  return 0;
   287 		  
   287 		  
   288 	      }// end switch status		 
   288 	      }/* end switch status	*/	 
   289 	    }// end while	
   289 	    }/* end while	*/
   290   }// end if Donnees 
   290   }/* end if Donnees */
   291 
   291 
   292 
   292 
   293   else if ((*m).rtr == REQUEST ){  
   293   else if ((*m).rtr == REQUEST ){  
   294       MSG_WAR(0x3946, "Receive a PDO request cobId : ", m->cob_id.w);
   294       MSG_WAR(0x3946, "Receive a PDO request cobId : ", m->cob_id.w);
   295       status = state1;
   295       status = state1;
   320 	  if ( (*pTransmissionType == TRANS_RTR) || (*pTransmissionType == TRANS_RTR_SYNC ) || (*pTransmissionType == TRANS_EVENT) ) {
   320 	  if ( (*pTransmissionType == TRANS_RTR) || (*pTransmissionType == TRANS_RTR_SYNC ) || (*pTransmissionType == TRANS_EVENT) ) {
   321 	    status = state5;
   321 	    status = state5;
   322 	    break;
   322 	    break;
   323 	  }
   323 	  }
   324 	  else {
   324 	  else {
   325 	    // The requested PDO is not to send on request. So, does nothing.
   325 	    /* The requested PDO is not to send on request. So, does nothing. */
   326 	    MSG_WAR(0x2947, "PDO is not to send on request : ", m->cob_id.w);
   326 	    MSG_WAR(0x2947, "PDO is not to send on request : ", m->cob_id.w);
   327 	    return 0xFF;
   327 	    return 0xFF;
   328 	  }
   328 	  }
   329 
   329 
   330 	case state5:	/* get mapped objects number */
   330 	case state5:	/* get mapped objects number */
   332 	  lastIndex = d->lastIndex->PDO_TRS_MAP;
   332 	  lastIndex = d->lastIndex->PDO_TRS_MAP;
   333 	  pMappingCount = (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject;
   333 	  pMappingCount = (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject;
   334 	  numMap = 0;
   334 	  numMap = 0;
   335 	  while (numMap < *pMappingCount) {
   335 	  while (numMap < *pMappingCount) {
   336 	    pMappingParameter = (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject;
   336 	    pMappingParameter = (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject;
   337 	    // Get the mapped variable
   337 	    /* Get the mapped variable */
   338 	    Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
   338 	    Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
   339 	    objDict = getODentry( d, (UNS16)((*pMappingParameter) >> (UNS8)16), 
   339 	    objDict = getODentry( d, (UNS16)((*pMappingParameter) >> (UNS8)16), 
   340 				     (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & 0xFF),
   340 				     (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & 0xFF),
   341 				     (void *)&d->process_var.data[offset], &Size, &dataType, 0 );
   341 				     (void *)&d->process_var.data[offset], &Size, &dataType, 0 );
   342 	    if (objDict != OD_SUCCESSFUL) {
   342 	    if (objDict != OD_SUCCESSFUL) {
   347 	    }
   347 	    }
   348 	    offset += (UNS8) (((*pMappingParameter) & 0xFF) >> 3);
   348 	    offset += (UNS8) (((*pMappingParameter) & 0xFF) >> 3);
   349 	    d->process_var.count = offset;
   349 	    d->process_var.count = offset;
   350 	    numMap++;
   350 	    numMap++;
   351 
   351 
   352 	  } // end while
   352 	  } /* end while */
   353 	  PDOmGR( d, *pwCobId ); // Transmit the PDO
   353 	  PDOmGR( d, *pwCobId ); /* Transmit the PDO */
   354 	  return 0;
   354 	  return 0;
   355 
   355 
   356 	}// end switch status
   356 	}/* end switch status */
   357       }// end while				
   357       }/* end while	 */			
   358     }// end if Requete
   358     }/* end if Requete */
   359 		
   359 		
   360   return 0;
   360   return 0;
   361 }
   361 }
   362 
   362 
   363 
   363 
   364 
   364 
       
   365 
       
   366 #if 0
   365 
   367 
   366 /*********************************************************************/
   368 /*********************************************************************/
   367 /* TODO : reimplement this using CallBacks                           */
   369 /* TODO : reimplement this using CallBacks                           */
   368 /*********************************************************************/
   370 /*********************************************************************/
   369 /*
   371 
   370 UNS8 sendPDOevent( CO_Data* d, void * variable )
   372 UNS8 sendPDOevent( CO_Data* d, void * variable )
   371 { // DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails.	
   373 { /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails.	*/
   372   UNS32           objDict = 0;
   374   UNS32           objDict = 0;
   373   UNS8            ind, sub_ind;
   375   UNS8            ind, sub_ind;
   374   UNS8            status; 
   376   UNS8            status; 
   375   UNS8            offset;
   377   UNS8            offset;
   376   UNS8 *     pMappingCount = NULL;
   378   UNS8 *     pMappingCount = NULL;
   377   UNS32 *    pMappingParameter = NULL;
   379   UNS32 *    pMappingParameter = NULL;
   378   void *     pMappedAppObject = NULL;
   380   void *     pMappedAppObject = NULL;
   379   UNS8 *     pTransmissionType = NULL; // pointer to the transmission type
   381   UNS8 *     pTransmissionType = NULL; /* pointer to the transmission type */
   380   UNS32 *    pwCobId = NULL;
   382   UNS32 *    pwCobId = NULL;
   381   UNS8 *     pSize;
   383   UNS8 *     pSize;
   382   UNS8       size;
   384   UNS8       size;
   383   UNS8       dataType;
   385   UNS8       dataType;
   384   UNS16      offsetObjdict;
   386   UNS16      offsetObjdict;
   389   sub_ind = 1; 
   391   sub_ind = 1; 
   390   offset  = 0x00;
   392   offset  = 0x00;
   391   pSize   = &size;
   393   pSize   = &size;
   392   status  = state1;
   394   status  = state1;
   393 
   395 
   394   // look for the index and subindex where the variable is mapped
   396   /* look for the index and subindex where the variable is mapped */
   395   // Then, send the pdo which contains the variable.
   397   /* Then, send the pdo which contains the variable. */
   396 
   398 
   397   MSG_WAR (0x3960, "sendPDOevent", 0);
   399   MSG_WAR (0x3960, "sendPDOevent", 0);
   398   offsetObjdictPrm = d->firstIndex->PDO_TRS;
   400   offsetObjdictPrm = d->firstIndex->PDO_TRS;
   399   
   401   
   400   offsetObjdict = d->firstIndex->PDO_TRS_MAP;
   402   offsetObjdict = d->firstIndex->PDO_TRS_MAP;
   401   lastIndex = d->lastIndex->PDO_TRS_MAP;
   403   lastIndex = d->lastIndex->PDO_TRS_MAP;
   402 
   404 
   403   if (offsetObjdictPrm && offsetObjdict) 
   405   if (offsetObjdictPrm && offsetObjdict) 
   404 	  // Loop on PDO Transmit
   406 	  /* Loop on PDO Transmit */
   405 	  while(offsetObjdict <= lastIndex){
   407 	  while(offsetObjdict <= lastIndex){
   406 	    // Check the transmission mode
   408 	    /* Check the transmission mode */
   407 	    pTransmissionType = d->objdict[offsetObjdictPrm].pSubindex[2].pObject;
   409 	    pTransmissionType = d->objdict[offsetObjdictPrm].pSubindex[2].pObject;
   408 	    if (*pTransmissionType != TRANS_EVENT) {
   410 	    if (*pTransmissionType != TRANS_EVENT) {
   409 	      ind++;
   411 	      ind++;
   410 	      offsetObjdict++;  
   412 	      offsetObjdict++;  
   411 	      offsetObjdictPrm++;
   413 	      offsetObjdictPrm++;
   412 	      continue;
   414 	      continue;
   413 	    }
   415 	    }
   414 	    pMappingCount = d->objdict[offsetObjdict].pSubindex[0].pObject;
   416 	    pMappingCount = d->objdict[offsetObjdict].pSubindex[0].pObject;
   415 	    numMap = 1; // mapped variable
   417 	    numMap = 1; /* mapped variable */
   416 	    while (numMap <= *pMappingCount) {
   418 	    while (numMap <= *pMappingCount) {
   417 	      pMappingParameter = d->objdict[offsetObjdict].pSubindex[numMap].pObject;
   419 	      pMappingParameter = d->objdict[offsetObjdict].pSubindex[numMap].pObject;
   418 	      // Get the variable
   420 	      /* Get the variable */
   419 	      objDict = getODentry( d,
   421 	      objDict = getODentry( d,
   420 	                            (UNS16)((*pMappingParameter) >> 16), 
   422 	                            (UNS16)((*pMappingParameter) >> 16), 
   421 				    (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & (UNS32)0x000000FF),
   423 				    (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & (UNS32)0x000000FF),
   422 				    (void * *)&pMappedAppObject, pSize, &dataType, 0 );
   424 				    (void * *)&pMappedAppObject, pSize, &dataType, 0 );
   423 	      if( objDict != OD_SUCCESSFUL ) {  
   425 	      if( objDict != OD_SUCCESSFUL ) {  
   432 		MSG_WAR(0x3963, "Variable to send found at index : ", 
   434 		MSG_WAR(0x3963, "Variable to send found at index : ", 
   433 			(*pMappingParameter) >> 16);
   435 			(*pMappingParameter) >> 16);
   434 		MSG_WAR(0x3964, "                       subIndex : ", 
   436 		MSG_WAR(0x3964, "                       subIndex : ", 
   435 			((*pMappingParameter) >> 8 ) & 0x000000FF);
   437 			((*pMappingParameter) >> 8 ) & 0x000000FF);
   436 		buildPDO(d, 0x1800 + ind);
   438 		buildPDO(d, 0x1800 + ind);
   437 		// Get the cobId
   439 		/* Get the cobId */
   438 		pwCobId = d->objdict[offsetObjdictPrm].pSubindex[1].pObject;
   440 		pwCobId = d->objdict[offsetObjdictPrm].pSubindex[1].pObject;
   439 		PDOmGR( d, *pwCobId ); // Send the PDO
   441 		PDOmGR( d, *pwCobId ); /* Send the PDO */
   440 		return 0;	    
   442 		return 0;	    
   441 	      }
   443 	      }
   442 	      numMap++;
   444 	      numMap++;
   443 	    } // End loop on mapped variable
   445 	    } /* End loop on mapped variable */
   444 	    ind++;	
   446 	    ind++;	
   445 	    offsetObjdict++;  
   447 	    offsetObjdict++;  
   446 	    offsetObjdictPrm++;
   448 	    offsetObjdictPrm++;
   447 	  } // End loop while on PDO
   449 	  } /* End loop while on PDO */
   448 
   450 
   449   MSG_WAR(0x2965, "Variable not found in a PDO to send on event", 0);
   451   MSG_WAR(0x2965, "Variable not found in a PDO to send on event", 0);
   450   return 0xFF;
   452   return 0xFF;
   451 
   453 
   452 }
   454 }
   453 */
   455 #endif