src/pdo.c
changeset 217 94c3f89bc3cc
parent 215 f49e5a6b7804
child 235 f812bf6b7237
equal deleted inserted replaced
216:8ae2ae25b096 217:94c3f89bc3cc
   192   offset = d->firstIndex->PDO_RCV;
   192   offset = d->firstIndex->PDO_RCV;
   193   lastIndex = d->lastIndex->PDO_RCV;
   193   lastIndex = d->lastIndex->PDO_RCV;
   194   if (offset)
   194   if (offset)
   195     while (offset <= lastIndex) {
   195     while (offset <= lastIndex) {
   196       /* get the CobId*/
   196       /* get the CobId*/
   197       pwCobId = d->objdict[offset].pSubindex[1].pObject;
   197       pwCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject;
   198 
   198 
   199       if ( *pwCobId  == cobId ) {
   199       if ( *pwCobId  == cobId ) {
   200         s_PDO pdo;
   200         s_PDO pdo;
   201         pdo.cobId = *pwCobId;
   201         pdo.cobId = *pwCobId;
   202         pdo.len = 0;
   202         pdo.len = 0;
   267           break;
   267           break;
   268 
   268 
   269         case state2:
   269         case state2:
   270           /* get CobId of the dictionary correspondant to the received
   270           /* get CobId of the dictionary correspondant to the received
   271              PDO */
   271              PDO */
   272           pwCobId = d->objdict[offsetObjdict].pSubindex[1].pObject;
   272           pwCobId = (UNS32*) d->objdict[offsetObjdict].pSubindex[1].pObject;
   273           /* check the CobId coherance */
   273           /* check the CobId coherance */
   274           /*pwCobId is the cobId read in the dictionary at the state 3
   274           /*pwCobId is the cobId read in the dictionary at the state 3
   275             */
   275             */
   276           if ( *pwCobId == (*m).cob_id.w ){
   276           if ( *pwCobId == (*m).cob_id.w ){
   277             /* The cobId is recognized */
   277             /* The cobId is recognized */
   291             case state4:/* Get Mapped Objects Number */
   291             case state4:/* Get Mapped Objects Number */
   292                /* The cobId of the message received has been found in the
   292                /* The cobId of the message received has been found in the
   293                  dictionnary. */
   293                  dictionnary. */
   294                offsetObjdict = d->firstIndex->PDO_RCV_MAP;
   294                offsetObjdict = d->firstIndex->PDO_RCV_MAP;
   295              lastIndex = d->lastIndex->PDO_RCV_MAP;
   295              lastIndex = d->lastIndex->PDO_RCV_MAP;
   296              pMappingCount = (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject;
   296              pMappingCount = (UNS8*) (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject;
   297              numMap = 0;
   297              numMap = 0;
   298              while (numMap < *pMappingCount) {
   298              while (numMap < *pMappingCount) {
   299                UNS8 tmp[]= {0,0,0,0,0,0,0,0};
   299                UNS8 tmp[]= {0,0,0,0,0,0,0,0};
   300                UNS8 ByteSize;
   300                UNS8 ByteSize;
   301                pMappingParameter = (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject;
   301                pMappingParameter = (UNS32*) (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject;
   302                if (pMappingParameter == NULL) {
   302                if (pMappingParameter == NULL) {
   303                  MSG_ERR(0x1937, "Couldn't get mapping parameter : ", numMap + 1);
   303                  MSG_ERR(0x1937, "Couldn't get mapping parameter : ", numMap + 1);
   304                  return 0xFF;
   304                  return 0xFF;
   305                }
   305                }
   306                /* Get the addresse of the mapped variable. */
   306                /* Get the addresse of the mapped variable. */
   355       switch( status ){
   355       switch( status ){
   356 
   356 
   357       case state1:/* check the CobId */
   357       case state1:/* check the CobId */
   358         /* get CobId of the dictionary which match to the received PDO
   358         /* get CobId of the dictionary which match to the received PDO
   359          */
   359          */
   360         pwCobId = (d->objdict + offsetObjdict)->pSubindex[1].pObject;
   360         pwCobId = (UNS32*) (d->objdict + offsetObjdict)->pSubindex[1].pObject;
   361         if ( *pwCobId == (*m).cob_id.w ) {
   361         if ( *pwCobId == (*m).cob_id.w ) {
   362           status = state4;
   362           status = state4;
   363           break;
   363           break;
   364         }
   364         }
   365         else {
   365         else {
   369         status = state1;
   369         status = state1;
   370         break;
   370         break;
   371 
   371 
   372 
   372 
   373       case state4:/* check transmission type (after request?) */
   373       case state4:/* check transmission type (after request?) */
   374         pTransmissionType = d->objdict[offsetObjdict].pSubindex[2].pObject;
   374         pTransmissionType = (UNS8*) d->objdict[offsetObjdict].pSubindex[2].pObject;
   375         if ( (*pTransmissionType == TRANS_RTR) || (*pTransmissionType == TRANS_RTR_SYNC ) || (*pTransmissionType == TRANS_EVENT) ) {
   375         if ( (*pTransmissionType == TRANS_RTR) || (*pTransmissionType == TRANS_RTR_SYNC ) || (*pTransmissionType == TRANS_EVENT) ) {
   376           status = state5;
   376           status = state5;
   377           break;
   377           break;
   378         }
   378         }
   379         else {
   379         else {
   384         }
   384         }
   385 
   385 
   386       case state5:/* get mapped objects number */
   386       case state5:/* get mapped objects number */
   387         offsetObjdict = d->firstIndex->PDO_TRS_MAP;
   387         offsetObjdict = d->firstIndex->PDO_TRS_MAP;
   388         lastIndex = d->lastIndex->PDO_TRS_MAP;
   388         lastIndex = d->lastIndex->PDO_TRS_MAP;
   389         pMappingCount = (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject;
   389         pMappingCount = (UNS8*) (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject;
   390         numMap = 0;
   390         numMap = 0;
   391         while (numMap < *pMappingCount) {
   391         while (numMap < *pMappingCount) {
   392           pMappingParameter = (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject;
   392           pMappingParameter = (UNS32*) (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject;
   393           /* Get the mapped variable */
   393           /* Get the mapped variable */
   394           Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
   394           Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
   395           objDict = getODentry( d, (UNS16)((*pMappingParameter) >> (UNS8)16),
   395           objDict = getODentry( d, (UNS16)((*pMappingParameter) >> (UNS8)16),
   396                                 (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & 0xFF),
   396                                 (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & 0xFF),
   397                                 (void *)&d->process_var.data[offset], &Size, &dataType, 0 );
   397                                 (void *)&d->process_var.data[offset], &Size, &dataType, 0 );