src/sync.c
author lbessard
Thu, 18 Jan 2007 15:15:55 +0100
changeset 67 51642fb5a0af
parent 53 73bc47a0db55
child 71 95cd3376cc9f
permissions -rw-r--r--
TIME_OF_DAY and TIME_DIFFERENCE disabled
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack. 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     4
Copyright (C): Edouard TISSERANT and Francis DUPIN
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     5
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     6
See COPYING file for copyrights details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     7
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     8
This library is free software; you can redistribute it and/or
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    10
License as published by the Free Software Foundation; either
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    12
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    13
This library is distributed in the hope that it will be useful,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    16
Lesser General Public License for more details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    17
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    19
License along with this library; if not, write to the Free Software
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    21
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    22
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    23
#include "data.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    24
#include "sync.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
53
73bc47a0db55 Add prototypes
frdupin
parents: 31
diff changeset
    26
// Prototypes for internals functions
73bc47a0db55 Add prototypes
frdupin
parents: 31
diff changeset
    27
void SyncAlarm(CO_Data* d, UNS32 id);
73bc47a0db55 Add prototypes
frdupin
parents: 31
diff changeset
    28
UNS32 OnCOB_ID_SyncUpdate(CO_Data* d, const indextable * unsused_indextable, 
73bc47a0db55 Add prototypes
frdupin
parents: 31
diff changeset
    29
	UNS8 unsused_bSubindex);
73bc47a0db55 Add prototypes
frdupin
parents: 31
diff changeset
    30
73bc47a0db55 Add prototypes
frdupin
parents: 31
diff changeset
    31
73bc47a0db55 Add prototypes
frdupin
parents: 31
diff changeset
    32
73bc47a0db55 Add prototypes
frdupin
parents: 31
diff changeset
    33
/*****************************************************************************/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    34
void SyncAlarm(CO_Data* d, UNS32 id)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    35
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    36
	sendSYNC(d, *d->COB_ID_Sync & 0x1FFFFFFF) ;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    37
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    38
53
73bc47a0db55 Add prototypes
frdupin
parents: 31
diff changeset
    39
/*****************************************************************************/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    40
// This is called when Index 0x1005 is updated.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    41
UNS32 OnCOB_ID_SyncUpdate(CO_Data* d, const indextable * unsused_indextable, UNS8 unsused_bSubindex)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    42
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    43
	startSYNC(d);
31
a82b70738e5c Code clean-up and fixed xenomai compile problem
lbessard
parents: 0
diff changeset
    44
	return 0;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    45
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    46
53
73bc47a0db55 Add prototypes
frdupin
parents: 31
diff changeset
    47
/*****************************************************************************/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    48
void startSYNC(CO_Data* d)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    49
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    50
	RegisterSetODentryCallBack(d, 0x1005, 0, &OnCOB_ID_SyncUpdate);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    51
	RegisterSetODentryCallBack(d, 0x1006, 0, &OnCOB_ID_SyncUpdate);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    52
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    53
	if(d->syncTimer != TIMER_NONE){
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    54
		stopSYNC(d);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    56
	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    57
	if(*d->COB_ID_Sync & 0x40000000 && *d->Sync_Cycle_Period)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    58
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    59
		d->syncTimer = SetAlarm(
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    60
				d,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    61
				0/*No id needed*/,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    62
				&SyncAlarm,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    63
				US_TO_TIMEVAL(*d->Sync_Cycle_Period), 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    64
				US_TO_TIMEVAL(*d->Sync_Cycle_Period));
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    65
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    66
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    67
53
73bc47a0db55 Add prototypes
frdupin
parents: 31
diff changeset
    68
/*****************************************************************************/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    69
void stopSYNC(CO_Data* d)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    70
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    71
	d->syncTimer = DelAlarm(d->syncTimer);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    72
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    73
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    74
/*********************************************************************/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    75
UNS8 sendSYNC(CO_Data* d, UNS32 cob_id)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    76
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    77
  Message m;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    78
  UNS8 resultat ;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    79
  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    80
  MSG_WAR(0x3001, "sendSYNC ", 0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
  m.cob_id.w = cob_id ;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
  m.rtr = NOT_A_REQUEST;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    84
  m.len = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    85
  resultat = (*d->canSend)(&m) ;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    86
  proceedSYNC(d, &m) ; 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    87
  return resultat ;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    88
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    89
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    90
/*****************************************************************************/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    91
UNS8 proceedSYNC(CO_Data* d, Message *m)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    92
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    93
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    94
  MSG_WAR(0x3002, "SYNC received. Proceed. ", 0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    95
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    96
  UNS8 	pdoNum,       // number of the actual processed pdo-nr.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    97
    prp_j;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    98
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    99
  const UNS8 *     pMappingCount = NULL;      // count of mapped objects...
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   100
  // pointer to the var which is mapped to a pdo
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   101
//  void *     pMappedAppObject = NULL; 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   102
  // pointer fo the var which holds the mapping parameter of an mapping entry  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   103
  UNS32 *    pMappingParameter = NULL;  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   104
  // pointer to the transmissiontype...
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   105
  UNS8 *     pTransmissionType = NULL;  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   106
  UNS32 *    pwCobId = NULL;	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   107
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   108
  UNS8 *    pSize;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   109
  UNS8      size;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   110
  UNS8      dataType;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   111
  UNS16 index;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   112
  UNS8 subIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   113
  UNS8 offset;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   114
  UNS8 status;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   115
  UNS8 sizeData;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   116
  pSize = &size;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   117
  UNS32   objDict;	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   118
  status = state3;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   119
  pdoNum=0x00;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   120
  prp_j=0x00;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   121
  offset = 0x00;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   122
  UNS16 offsetObjdict;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   123
  UNS16 offsetObjdictMap;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   124
  UNS16 lastIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   125
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   126
  /* only operational state allows PDO transmission */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   127
  if( d->nodeState != Operational ) 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   128
    return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   129
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   130
   (*d->post_sync)();
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   131
  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   132
  /* So, the node is in operational state */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   133
  /* study all PDO stored in the objects dictionary */	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   134
 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   135
  offsetObjdict = d->firstIndex->PDO_TRS;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   136
  lastIndex = d->lastIndex->PDO_TRS;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   137
  offsetObjdictMap = d->firstIndex->PDO_TRS_MAP;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   138
  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   139
  if(offsetObjdict) while( offsetObjdict <= lastIndex) {  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   140
    switch( status ) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   141
                    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   142
    case state3:    /* get the PDO transmission type */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   143
      if (d->objdict[offsetObjdict].bSubCount <= 2) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   144
	  MSG_ERR(0x1004, "Subindex 2  not found at index ", 0x1800 + pdoNum);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   145
	  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   146
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   147
      pTransmissionType = d->objdict[offsetObjdict].pSubindex[2].pObject;    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   148
      MSG_WAR(0x3005, "Reading PDO at index : ", 0x1800 + pdoNum);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   149
      status = state4; 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   150
      break;     
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   151
    case state4:	/* check if transmission type is after (this) SYNC */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   152
                        /* The message may not be transmited every SYNC but every n SYNC */      
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   153
      if( (*pTransmissionType >= TRANS_SYNC_MIN) && (*pTransmissionType <= TRANS_SYNC_MAX) &&
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   154
          (++d->count_sync[pdoNum] == *pTransmissionType) ) {	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
	d->count_sync[pdoNum] = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   156
	MSG_WAR(0x3007, "  PDO is on SYNCHRO. Trans type : ", *pTransmissionType);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   157
	status = state5;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   158
	break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   159
      }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   160
      else {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   161
	MSG_WAR(0x3008, "  Not on synchro or not at this SYNC. Trans type : ", 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   162
		*pTransmissionType);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   163
	pdoNum++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   164
	offsetObjdict++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   165
	offsetObjdictMap++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   166
	status = state11;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   167
	break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   168
      }      
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   169
    case state5:	/* get PDO CobId */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   170
        pwCobId = d->objdict[offsetObjdict].pSubindex[1].pObject;     
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   171
	MSG_WAR(0x3009, "  PDO CobId is : ", *pwCobId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   172
	status = state7;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   173
	break;     
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   174
    case state7:  /* get mapped objects number to transmit with this PDO */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   175
      pMappingCount = d->objdict[offsetObjdictMap].pSubindex[0].pObject;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   176
	MSG_WAR(0x300D, "  Number of objects mapped : ",*pMappingCount );
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   177
	status = state8;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   178
    case state8:	/* get mapping parameters */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   179
      pMappingParameter = d->objdict[offsetObjdictMap].pSubindex[prp_j + 1].pObject;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   180
	MSG_WAR(0x300F, "  got mapping parameter : ", *pMappingParameter);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   181
	MSG_WAR(0x3050, "    at index : ", 0x1A00 + pdoNum);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   182
	MSG_WAR(0x3051, "    sub-index : ", prp_j + 1);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   183
	status = state9;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   184
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   185
    case state9:	/* get data to transmit */ 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   186
      index = (UNS16)((*pMappingParameter) >> 16);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   187
      subIndex = (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & (UNS32)0x000000FF);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   188
      // <<3 because in *pMappingParameter the size is in bits
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   189
      sizeData = (UNS8) ((*pMappingParameter & (UNS32)0x000000FF) >> 3) ;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   190
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   191
        objDict = getODentry(d, index, subIndex, (void *)&d->process_var.data[offset], &sizeData, &dataType, 0 ); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   192
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   193
        if( objDict != OD_SUCCESSFUL ){
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   194
          MSG_ERR(0x1013, " Couldn't find mapped variable at index-subindex-size : ", (UNS16)(*pMappingParameter));
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   195
          return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   196
        }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   197
	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   198
	offset += sizeData ;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   199
	d->process_var.count = offset;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   200
	prp_j++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   201
	status = state10;	 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   202
	break;					
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   203
      
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   204
    case state10:	/* loop to get all the data to transmit */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   205
      if( prp_j < *pMappingCount ){
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   206
	MSG_WAR(0x3014, "  next variable mapped : ", prp_j);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   207
	status = state8;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   208
	break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   209
      }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   210
      else {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   211
	MSG_WAR(0x3015, "  End scan mapped variable", 0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   212
	PDOmGR( d, *pwCobId );	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   213
	MSG_WAR(0x3016, "  End of this pdo. Should have been sent", 0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   214
	pdoNum++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   215
	offsetObjdict++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   216
	offsetObjdictMap++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   217
	offset = 0x00;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   218
	prp_j = 0x00;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   219
	status = state11;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   220
	break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   221
      }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   222
      
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   223
    case state11:     
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   224
      MSG_WAR(0x3017, "next pdo index : ", pdoNum);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   225
      status = state3;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   226
      break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   227
      
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   228
    default:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   229
      MSG_ERR(0x1019,"Unknown state has been reached : %d",status);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   230
      return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   231
    }// end switch case
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   232
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   233
  }// end while( prp_i<dict_cstes.max_count_of_PDO_transmit )
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   234
   
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   235
  (*d->post_TPDO)();
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   236
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   237
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   238
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   239
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   240