src/pdo.c
changeset 370 6fecf36df407
parent 365 9b76e0881beb
child 379 193558036df4
equal deleted inserted replaced
369:8b67289d50b5 370:6fecf36df407
    22   USA
    22   USA
    23 */
    23 */
    24 #include "pdo.h"
    24 #include "pdo.h"
    25 #include "objacces.h"
    25 #include "objacces.h"
    26 #include "canfestival.h"
    26 #include "canfestival.h"
       
    27 #include "sysdep.h"
    27 
    28 
    28 /*!
    29 /*!
    29 ** @file   pdo.c
    30 ** @file   pdo.c
    30 ** @author Edouard TISSERANT and Francis DUPIN
    31 ** @author Edouard TISSERANT and Francis DUPIN
    31 ** @date   Tue Jun  5 09:32:32 2007
    32 ** @date   Tue Jun  5 09:32:32 2007
    52 	
    53 	
    53 	UNS8 prp_j = 0x00;
    54 	UNS8 prp_j = 0x00;
    54 	UNS8 offset = 0x00;
    55 	UNS8 offset = 0x00;
    55 	const UNS8* pMappingCount = (UNS8*) TPDO_map->pSubindex[0].pObject;
    56 	const UNS8* pMappingCount = (UNS8*) TPDO_map->pSubindex[0].pObject;
    56 
    57 
    57 	pdo->cob_id = *(UNS32*)TPDO_com->pSubindex[1].pObject & 0x7FF;
    58 	pdo->cob_id = *(UNS16*)TPDO_com->pSubindex[1].pObject & UNS16_LE(0x7FF);
    58 	pdo->rtr = NOT_A_REQUEST;
    59 	pdo->rtr = NOT_A_REQUEST;
    59 
    60 
    60 	MSG_WAR(0x3009, "  PDO CobId is : ", *(UNS32*)TPDO_com->pSubindex[1].pObject);
    61 	MSG_WAR(0x3009, "  PDO CobId is : ", *(UNS32*)TPDO_com->pSubindex[1].pObject);
    61 	MSG_WAR(0x300D, "  Number of objects mapped : ",*pMappingCount );
    62 	MSG_WAR(0x300D, "  Number of objects mapped : ",*pMappingCount );
    62 	
    63 	
   105 **
   106 **
   106 ** @return
   107 ** @return
   107 **/
   108 **/
   108 UNS8 sendPDOrequest( CO_Data* d, UNS16 RPDOIndex )
   109 UNS8 sendPDOrequest( CO_Data* d, UNS16 RPDOIndex )
   109 {
   110 {
   110   UNS32 * pwCobId;
   111   UNS16 * pwCobId;
   111   UNS16 offset = d->firstIndex->PDO_RCV;
   112   UNS16 offset = d->firstIndex->PDO_RCV;
   112   UNS16 lastIndex = d->lastIndex->PDO_RCV;
   113   UNS16 lastIndex = d->lastIndex->PDO_RCV;
   113 
   114 
   114   /* Sending the request only if the cobid have been found on the PDO
   115   /* Sending the request only if the cobid have been found on the PDO
   115      receive */
   116      receive */
   119   
   120   
   120   if (offset && RPDOIndex >= 0x1400){
   121   if (offset && RPDOIndex >= 0x1400){
   121     offset += RPDOIndex - 0x1400;  
   122     offset += RPDOIndex - 0x1400;  
   122     if (offset <= lastIndex) {
   123     if (offset <= lastIndex) {
   123       /* get the CobId*/
   124       /* get the CobId*/
   124       pwCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject;
   125       pwCobId = (UNS16*) d->objdict[offset].pSubindex[1].pObject;
   125 
   126 
   126       MSG_WAR(0x3930, "sendPDOrequest cobId is : ",*pwCobId);
   127       MSG_WAR(0x3930, "sendPDOrequest cobId is : ",*pwCobId);
   127       {
   128       {
   128           Message pdo;
   129           Message pdo;
   129           pdo.cob_id = *pwCobId;
   130           pdo.cob_id = *pwCobId;
   156   /* pointer fo the var which holds the mapping parameter of an
   157   /* pointer fo the var which holds the mapping parameter of an
   157      mapping entry */
   158      mapping entry */
   158   UNS32 *    pMappingParameter = NULL;
   159   UNS32 *    pMappingParameter = NULL;
   159   UNS8  *    pTransmissionType = NULL; /* pointer to the transmission
   160   UNS8  *    pTransmissionType = NULL; /* pointer to the transmission
   160                                          type */
   161                                          type */
   161   UNS32 *    pwCobId = NULL;
   162   UNS16 *    pwCobId = NULL;
   162   UNS8       Size;
   163   UNS8       Size;
   163   UNS8       offset;
   164   UNS8       offset;
   164   UNS8       status;
   165   UNS8       status;
   165   UNS32      objDict;
   166   UNS32      objDict;
   166   UNS16      offsetObjdict;
   167   UNS16      offsetObjdict;
   167   UNS16      lastIndex;
   168   UNS16      lastIndex;
   168   
   169   
   169   status = state2;
   170   status = state2;
   170 
   171 
   171   MSG_WAR(0x3935, "proceedPDO, cobID : ", ((*m).cob_id & 0x7ff));
   172   MSG_WAR(0x3935, "proceedPDO, cobID : ", ((*m).cob_id & UNS16_LE(0x7ff)));
   172   offset = 0x00;
   173   offset = 0x00;
   173   numPdo = 0;
   174   numPdo = 0;
   174   numMap = 0;
   175   numMap = 0;
   175   if((*m).rtr == NOT_A_REQUEST ) { /* The PDO received is not a
   176   if((*m).rtr == NOT_A_REQUEST ) { /* The PDO received is not a
   176                                      request. */
   177                                      request. */
   185         switch( status ) {
   186         switch( status ) {
   186 
   187 
   187         case state2:
   188         case state2:
   188           /* get CobId of the dictionary correspondant to the received
   189           /* get CobId of the dictionary correspondant to the received
   189              PDO */
   190              PDO */
   190           pwCobId = (UNS32*) d->objdict[offsetObjdict].pSubindex[1].pObject;
   191           pwCobId = (UNS16*) d->objdict[offsetObjdict].pSubindex[1].pObject;
   191           /* check the CobId coherance */
   192           /* check the CobId coherance */
   192           /*pwCobId is the cobId read in the dictionary at the state 3
   193           /*pwCobId is the cobId read in the dictionary at the state 3
   193             */
   194             */
   194           if ( *pwCobId == (*m).cob_id ){
   195           if ( *pwCobId == (*m).cob_id ){
   195             /* The cobId is recognized */
   196             /* The cobId is recognized */
   276       switch( status ){
   277       switch( status ){
   277 
   278 
   278       case state1:/* check the CobId */
   279       case state1:/* check the CobId */
   279         /* get CobId of the dictionary which match to the received PDO
   280         /* get CobId of the dictionary which match to the received PDO
   280          */
   281          */
   281         pwCobId = (UNS32*) (d->objdict + offsetObjdict)->pSubindex[1].pObject;
   282         pwCobId = (UNS16*) (d->objdict + offsetObjdict)->pSubindex[1].pObject;
   282         if ( *pwCobId == (*m).cob_id ) {
   283         if ( *pwCobId == (*m).cob_id ) {
   283           status = state4;
   284           status = state4;
   284           break;
   285           break;
   285         }
   286         }
   286         else {
   287         else {