src/pdo.c
author lbessard
Fri, 22 Jun 2007 17:46:18 +0200
changeset 226 abf63d732a84
parent 217 94c3f89bc3cc
child 235 f812bf6b7237
permissions -rw-r--r--
Bug on EDS file parsing fixed
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
/*
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     2
  This file is part of CanFestival, a library implementing CanOpen
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     3
  Stack.
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     4
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     5
  Copyright (C): Edouard TISSERANT and Francis DUPIN
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     6
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     7
  See COPYING file for copyrights details.
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     8
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     9
  This library is free software; you can redistribute it and/or
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    10
  modify it under the terms of the GNU Lesser General Public
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    11
  License as published by the Free Software Foundation; either
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    12
  version 2.1 of the License, or (at your option) any later version.
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    13
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    14
  This library is distributed in the hope that it will be useful,
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    15
  but WITHOUT ANY WARRANTY; without even the implied warranty of
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    16
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    17
  Lesser General Public License for more details.
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    18
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    19
  You should have received a copy of the GNU Lesser General Public
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    20
  License along with this library; if not, write to the Free Software
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    21
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    22
  USA
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    23
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    24
#include "pdo.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
#include "objacces.h"
149
fe50ada8020b Changes in the API:
etisserant
parents: 90
diff changeset
    26
#include "canfestival.h"
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    27
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    28
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    29
** @file   pdo.c
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    30
** @author Edouard TISSERANT and Francis DUPIN
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    31
** @date   Tue Jun  5 09:32:32 2007
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    32
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    33
** @brief
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    34
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    35
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    36
*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    37
UNS8 sendPDO(CO_Data* d, s_PDO pdo, UNS8 req)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    38
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    39
  UNS8 i;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    40
  if( d->nodeState == Operational ) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    41
    Message m;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    42
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
    43
    /* Message copy for sending */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
    44
    m.cob_id.w = pdo.cobId & 0x7FF; /* Because the cobId is 11 bytes
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    45
                                      length */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    46
    if ( req == NOT_A_REQUEST ) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    47
      UNS8 i;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    48
      m.rtr = NOT_A_REQUEST;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    49
      m.len = pdo.len;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
    50
      /* memcpy(&m.data, &pdo.data, m.len); */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
    51
      /* This Memcpy depends on packing structure. Avoid */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    52
      for (i = 0 ; i < pdo.len ; i++)
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    53
        m.data[i] = pdo.data[i];
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    54
    }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
    else {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    56
      m.rtr = REQUEST;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    57
      m.len = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    58
    }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    59
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    60
    MSG_WAR(0x3901, "sendPDO cobId :", m.cob_id.w);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    61
    MSG_WAR(0x3902,  "     Nb octets  : ",  m.len);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    62
    for (i = 0 ; i < m.len ; i++) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    63
      MSG_WAR(0x3903,"           data : ", m.data[i]);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    64
    }
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    65
149
fe50ada8020b Changes in the API:
etisserant
parents: 90
diff changeset
    66
    return canSend(d->canHandle,&m);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
    67
  } /* end if */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    68
  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    69
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    70
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    71
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    72
** PDO Manager
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    73
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    74
** @param d
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    75
** @param cobId
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    76
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    77
** @return
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    78
**/
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    79
UNS8 PDOmGR(CO_Data* d, UNS32 cobId)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    80
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
  UNS8 res;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
  UNS8 i;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
  s_PDO pdo;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    84
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    85
  MSG_WAR(0x3905, "PDOmGR",0);
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    86
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
    87
  /* if PDO is waiting for transmission,
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    88
    preparation of the message to send */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    89
  pdo.cobId = cobId;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    90
  pdo.len =  d->process_var.count;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
    91
  /* memcpy(&(pdo.data), &(process_var.data), pdo.len); */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    92
     /* Ce memcpy devrait tre portable */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    93
    for ( i = 0 ; i < pdo.len ; i++) 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    94
      pdo.data[i] = d->process_var.data[i];
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    95
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    96
    res = sendPDO(d, pdo, NOT_A_REQUEST);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    97
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    98
    return res;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    99
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   100
201
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   101
#if 0
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   102
/*********************************************************************/
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   103
/* TODO : implement bit mapping                          			 */
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   104
/*********************************************************************/
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   105
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   106
UNS8 buildPDO(CO_Data* d, UNS16 index)
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   107
{ /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails. */	
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   108
  UNS16 ind;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   109
  UNS8      subInd;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   110
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   111
  UNS8 *     pMappingCount = NULL;      /* count of mapped objects... */
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   112
  /* pointer to the var which is mapped to a pdo */
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   113
/*  void *     pMappedAppObject = NULL;  */
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   114
  /* pointer fo the var which holds the mapping parameter of an mapping entry  */ 
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   115
 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   116
  UNS32 *    pMappingParameter = NULL;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   117
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   118
  UNS8      Size;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   119
  UNS8      dataType;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   120
  UNS8      offset;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   121
  UNS16     offsetObjdict;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   122
  UNS16     offsetObjdictPrm;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   123
  UNS32     objDict;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   124
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   125
  subInd=(UNS8)0x00;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   126
  offset = 0x00;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   127
  ind = index - 0x1800;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   128
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   129
  MSG_WAR(0x3910,"Prepare PDO to send index :", index);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   130
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   131
  /* only operational state allows PDO transmission */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   132
  if( d->nodeState != Operational ) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   133
    MSG_WAR(0x2911, "Unable to send the PDO (node not in OPERATIONAL mode). Node : ", index);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   134
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   135
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   136
  offsetObjdictPrm = d->firstIndex->PDO_TRS;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   137
  offsetObjdict = d->firstIndex->PDO_TRS_MAP;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   138
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   139
  if (offsetObjdictPrm && offsetObjdict)
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   140
    {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   141
      /* get mapped objects number to transmit with this PDO */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   142
      pMappingCount = (d->objdict + offsetObjdict + ind)->pSubindex[0].pObject;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   143
      MSG_WAR(0x3912, "Nb maped objects : ",* pMappingCount);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   144
      MSG_WAR(0x3913, "        at index : ", 0x1A00 + ind);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   145
      while (subInd < *pMappingCount) { /* Loop on mapped variables */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   146
        /* get mapping parameters */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   147
        pMappingParameter = (d->objdict + offsetObjdict + ind)->pSubindex[subInd + 1].pObject;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   148
        MSG_WAR(0x3914, "Get the mapping      at index : ", (UNS16)0x1A00 + ind);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   149
        MSG_WAR(0x3915, "                     subIndex : ", subInd + 1);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   150
        MSG_WAR(0x3916, "                     value    : ", *(UNS32 *)pMappingParameter);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   151
        /* Get the mapped variable */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   152
        Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   153
        objDict = getODentry(d, (UNS16)((*pMappingParameter) >> 16),
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   154
                             (UNS8)(((*pMappingParameter) >> 8 ) & 0x000000FF),
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   155
                             (void *)&d->process_var.data[offset], &Size, &dataType, 0 );
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   156
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   157
        if (objDict != OD_SUCCESSFUL) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   158
          MSG_WAR(0x2919, "error accessing to the mapped var : ", subInd + 1);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   159
          MSG_WAR(0x2920, "         Mapped at index : ", (*pMappingParameter) >> 16);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   160
          MSG_WAR(0x2921, "                subindex : ", ((*pMappingParameter) >> 8 ) & 0xFF);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   161
          return 0xFF;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   162
        }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   163
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   164
        offset += Size;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   165
        d->process_var.count = offset;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   166
        subInd++;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   167
      }/* end Loop on mapped variables  */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   168
    }
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   169
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   170
}
201
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   171
#endif
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   172
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   173
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   174
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   175
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   176
** @param d
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   177
** @param cobId
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   178
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   179
** @return
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   180
**/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   181
UNS8 sendPDOrequest( CO_Data* d, UNS32 cobId )
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   182
{
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   183
  UNS32 * pwCobId;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   184
  UNS16          offset;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   185
  UNS16          lastIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   186
  UNS8           err;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   187
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   188
  MSG_WAR(0x3930, "sendPDOrequest ",0);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   189
  /* Sending the request only if the cobid have been found on the PDO
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   190
     receive */
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   191
  /* part dictionary */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   192
  offset = d->firstIndex->PDO_RCV;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   193
  lastIndex = d->lastIndex->PDO_RCV;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   194
  if (offset)
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   195
    while (offset <= lastIndex) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   196
      /* get the CobId*/
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   197
      pwCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   198
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   199
      if ( *pwCobId  == cobId ) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   200
        s_PDO pdo;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   201
        pdo.cobId = *pwCobId;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   202
        pdo.len = 0;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   203
        err  = sendPDO(d, pdo, REQUEST);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   204
        return err;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   205
      }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   206
      offset++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   207
    }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   208
  MSG_WAR(0x1931, "sendPDOrequest : COBID not found : ", cobId);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   209
  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   210
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   211
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   212
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   213
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   214
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   215
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   216
** @param d
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   217
** @param m
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   218
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   219
** @return
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   220
**/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   221
UNS8 proceedPDO(CO_Data* d, Message *m)
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   222
{
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   223
  UNS8   numPdo;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   224
  UNS8   numMap;  /* Number of the mapped varable */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   225
  UNS8 i;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   226
  UNS8 *     pMappingCount = NULL;    /* count of mapped objects... */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   227
  /* pointer to the var which is mapped to a pdo... */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   228
  /*  void *     pMappedAppObject = NULL;   */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   229
  /* pointer fo the var which holds the mapping parameter of an
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   230
     mapping entry */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   231
  UNS32 *    pMappingParameter = NULL;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   232
  UNS8  *    pTransmissionType = NULL; /* pointer to the transmission
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   233
                                         type */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   234
  UNS32 *    pwCobId = NULL;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   235
  UNS8       Size;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   236
  UNS8       dataType;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   237
  UNS8       offset;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   238
  UNS8       status;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   239
  UNS32      objDict;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   240
  UNS16      offsetObjdict;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   241
  UNS16      lastIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   242
  status = state1;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   243
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   244
  MSG_WAR(0x3935, "proceedPDO, cobID : ", ((*m).cob_id.w & 0x7ff));
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   245
  offset = 0x00;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   246
  numPdo = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   247
  numMap = 0;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   248
  if((*m).rtr == NOT_A_REQUEST ) { /* The PDO received is not a
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   249
                                     request. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   250
    offsetObjdict = d->firstIndex->PDO_RCV;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   251
    lastIndex = d->lastIndex->PDO_RCV;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   252
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   253
    /* study of all the PDO stored in the dictionary */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   254
    if(offsetObjdict)
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   255
      while (offsetObjdict <= lastIndex) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   256
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   257
        switch( status ) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   258
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   259
        case state1:/* data are stored in process_var array */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   260
          /* memcpy(&(process_var.data), &m->data, (*m).len); */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   261
          /* Ce memcpy devrait etre portable */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   262
          for ( i = 0 ; i < m->len ; i++)
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   263
            d->process_var.data[i] = m->data[i];
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   264
          d->process_var.count = (*m).len;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   265
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   266
          status = state2;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   267
          break;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   268
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   269
        case state2:
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   270
          /* get CobId of the dictionary correspondant to the received
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   271
             PDO */
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   272
          pwCobId = (UNS32*) d->objdict[offsetObjdict].pSubindex[1].pObject;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   273
          /* check the CobId coherance */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   274
          /*pwCobId is the cobId read in the dictionary at the state 3
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   275
            */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   276
          if ( *pwCobId == (*m).cob_id.w ){
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   277
            /* The cobId is recognized */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   278
            status = state4;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   279
            MSG_WAR(0x3936, "cobId found at index ", 0x1400 + numPdo);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   280
            break;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   281
          }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   282
          else {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   283
            /* cobId received does not match with those write in the
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   284
              dictionnary */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   285
            numPdo++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   286
            offsetObjdict++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   287
            status = state2;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   288
            break;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   289
          }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   290
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   291
            case state4:/* Get Mapped Objects Number */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   292
               /* The cobId of the message received has been found in the
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   293
                 dictionnary. */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   294
               offsetObjdict = d->firstIndex->PDO_RCV_MAP;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   295
             lastIndex = d->lastIndex->PDO_RCV_MAP;
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   296
             pMappingCount = (UNS8*) (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   297
             numMap = 0;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   298
             while (numMap < *pMappingCount) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   299
               UNS8 tmp[]= {0,0,0,0,0,0,0,0};
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   300
               UNS8 ByteSize;
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   301
               pMappingParameter = (UNS32*) (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   302
               if (pMappingParameter == NULL) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   303
                 MSG_ERR(0x1937, "Couldn't get mapping parameter : ", numMap + 1);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   304
                 return 0xFF;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   305
               }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   306
               /* Get the addresse of the mapped variable. */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   307
               /* detail of *pMappingParameter : */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   308
               /* The 16 hight bits contains the index, the medium 8 bits
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   309
                 contains the subindex, */
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   310
               /* and the lower 8 bits contains the size of the mapped
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   311
                 variable. */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   312
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   313
               Size = (UNS8)(*pMappingParameter);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   314
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   315
               /* copy bit per bit in little endian */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   316
               CopyBits(Size, (UNS8*)&d->process_var.data[offset>>3], offset%8, 0, ((UNS8*)tmp), 0, 0);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   317
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   318
               ByteSize = 1 + ((Size - 1) >> 3); /*1->8 => 1 ; 9->16 =>
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   319
                                                   2, ... */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   320
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   321
               objDict = setODentry(d, (UNS16)((*pMappingParameter) >> 16),
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   322
                                    (UNS8)(((*pMappingParameter) >> 8 ) & 0xFF),
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   323
                                 tmp, &ByteSize, 0 );
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   324
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   325
               if(objDict != OD_SUCCESSFUL) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   326
                 MSG_ERR(0x1938, "error accessing to the mapped var : ", numMap + 1);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   327
                 MSG_WAR(0x2939, "         Mapped at index : ", (*pMappingParameter) >> 16);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   328
                 MSG_WAR(0x2940, "                subindex : ", ((*pMappingParameter) >> 8 ) & 0xFF);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   329
                 return 0xFF;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   330
               }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   331
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   332
               MSG_WAR(0x3942, "Variable updated with value received by PDO cobid : ", m->cob_id.w);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   333
               MSG_WAR(0x3943, "         Mapped at index : ", (*pMappingParameter) >> 16);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   334
               MSG_WAR(0x3944, "                subindex : ", ((*pMappingParameter) >> 8 ) & 0xFF);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   335
               /* MSG_WAR(0x3945, "                data : ",*((UNS32*)pMappedAppObject)); */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   336
               offset += Size;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   337
               numMap++;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   338
             } /* end loop while on mapped variables */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   339
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   340
             offset=0x00;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   341
             numMap = 0;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   342
             return 0;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   343
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   344
        }/* end switch status*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   345
      }/* end while*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   346
  }/* end if Donnees */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   347
  else if ((*m).rtr == REQUEST ){
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   348
    MSG_WAR(0x3946, "Receive a PDO request cobId : ", m->cob_id.w);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   349
    status = state1;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   350
    offsetObjdict = d->firstIndex->PDO_TRS;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   351
    lastIndex = d->lastIndex->PDO_TRS;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   352
    if(offsetObjdict) while( offsetObjdict  <= lastIndex ){
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   353
      /* study of all PDO stored in the objects dictionary */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   354
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   355
      switch( status ){
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   356
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   357
      case state1:/* check the CobId */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   358
        /* get CobId of the dictionary which match to the received PDO
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   359
         */
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   360
        pwCobId = (UNS32*) (d->objdict + offsetObjdict)->pSubindex[1].pObject;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   361
        if ( *pwCobId == (*m).cob_id.w ) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   362
          status = state4;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   363
          break;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   364
        }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   365
        else {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   366
          numPdo++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   367
          offsetObjdict++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   368
        }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   369
        status = state1;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   370
        break;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   371
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   372
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   373
      case state4:/* check transmission type (after request?) */
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   374
        pTransmissionType = (UNS8*) d->objdict[offsetObjdict].pSubindex[2].pObject;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   375
        if ( (*pTransmissionType == TRANS_RTR) || (*pTransmissionType == TRANS_RTR_SYNC ) || (*pTransmissionType == TRANS_EVENT) ) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   376
          status = state5;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   377
          break;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   378
        }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   379
        else {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   380
          /* The requested PDO is not to send on request. So, does
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   381
            nothing. */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   382
          MSG_WAR(0x2947, "PDO is not to send on request : ", m->cob_id.w);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   383
          return 0xFF;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   384
        }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   385
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   386
      case state5:/* get mapped objects number */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   387
        offsetObjdict = d->firstIndex->PDO_TRS_MAP;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   388
        lastIndex = d->lastIndex->PDO_TRS_MAP;
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   389
        pMappingCount = (UNS8*) (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   390
        numMap = 0;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   391
        while (numMap < *pMappingCount) {
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   392
          pMappingParameter = (UNS32*) (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   393
          /* Get the mapped variable */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   394
          Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   395
          objDict = getODentry( d, (UNS16)((*pMappingParameter) >> (UNS8)16),
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   396
                                (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & 0xFF),
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   397
                                (void *)&d->process_var.data[offset], &Size, &dataType, 0 );
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   398
          if (objDict != OD_SUCCESSFUL) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   399
            MSG_ERR(0x1948, "error accessing to the mapped var : ", numMap + 1);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   400
            MSG_WAR(0x2949, "         Mapped at index : ", (*pMappingParameter) >> 16);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   401
            MSG_WAR(0x2950, "                subindex : ", ((*pMappingParameter) >> 8 ) & 0xFF);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   402
            return 0xFF;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   403
          }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   404
          offset += (UNS8) (((*pMappingParameter) & 0xFF) >> 3);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   405
          d->process_var.count = offset;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   406
          numMap++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   407
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   408
        } /* end while */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   409
        PDOmGR( d, *pwCobId ); /* Transmit the PDO */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   410
        return 0;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   411
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   412
      }/* end switch status */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   413
    }/* end while */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   414
  }/* end if Requete */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   415
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   416
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   417
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   418
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   419
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   420
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   421
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   422
** @param NbBits
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   423
** @param SrcByteIndex
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   424
** @param SrcBitIndex
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   425
** @param SrcBigEndian
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   426
** @param DestByteIndex
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   427
** @param DestBitIndex
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   428
** @param DestBigEndian
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   429
**/
201
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   430
void CopyBits(UNS8 NbBits, UNS8* SrcByteIndex, UNS8 SrcBitIndex, UNS8 SrcBigEndian, UNS8* DestByteIndex, UNS8 DestBitIndex, UNS8 DestBigEndian)
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   431
{
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   432
  /* This loop copy as many bits that it can each time, crossing*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   433
  /* successively bytes*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   434
  // boundaries from LSB to MSB.
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   435
  while(NbBits > 0)
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   436
    {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   437
      /* Bit missalignement between src and dest*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   438
      INTEGER8 Vect = DestBitIndex - SrcBitIndex;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   439
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   440
      /* We can now get src and align it to dest*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   441
      UNS8 Aligned = Vect>0 ? *SrcByteIndex << Vect : *SrcByteIndex >> -Vect;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   442
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   443
      /* Compute the nb of bit we will be able to copy*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   444
      UNS8 BoudaryLimit = (Vect>0 ? 8 - DestBitIndex :  8 - SrcBitIndex );
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   445
      UNS8 BitsToCopy = BoudaryLimit > NbBits ? NbBits : BoudaryLimit;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   446
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   447
      /* Create a mask that will serve in:*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   448
      UNS8 Mask = ((0xff << (DestBitIndex + BitsToCopy)) | (0xff >> (8 - DestBitIndex)));
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   449
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   450
      /* - Filtering src*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   451
      UNS8 Filtered = Aligned & ~Mask;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   452
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   453
      /* - and erase bits where we write, preserve where we don't*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   454
      *DestByteIndex &= Mask;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   455
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   456
      /* Then write.*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   457
      *DestByteIndex |= Filtered ;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   458
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   459
      /*Compute next time cursors for src*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   460
      if((SrcBitIndex += BitsToCopy)>7)/* cross boundary ?*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   461
        {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   462
          SrcBitIndex = 0;/* First bit*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   463
          SrcByteIndex += (SrcBigEndian ? -1 : 1);/* Next byte*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   464
        }
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   465
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   466
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   467
      /*Compute next time cursors for dest*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   468
      if((DestBitIndex += BitsToCopy)>7)
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   469
        {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   470
          DestBitIndex = 0;/* First bit*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   471
          DestByteIndex += (DestBigEndian ? -1 : 1);/* Next byte*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   472
        }
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   473
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   474
      /*And decrement counter.*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   475
      NbBits -= BitsToCopy;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   476
    }
201
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   477
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   478
}
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   479
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   480
#if 0
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   481
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   482
/*********************************************************************/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   483
/* TODO : reimplement this using CallBacks
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   484
 */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   485
/*********************************************************************/
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   486
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   487
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   488
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   489
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   490
** @param d
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   491
** @param variable
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   492
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   493
** @return
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   494
**/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   495
UNS8 sendPDOevent( CO_Data* d, void * variable )
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   496
{ /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   497
    loop if it fails.*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   498
  UNS32           objDict = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   499
  UNS8            ind, sub_ind;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   500
  UNS8            status;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   501
  UNS8            offset;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   502
  UNS8 *     pMappingCount = NULL;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   503
  UNS32 *    pMappingParameter = NULL;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   504
  void *     pMappedAppObject = NULL;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   505
  UNS8 *     pTransmissionType = NULL; /* pointer to the transmission
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   506
                                         type */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   507
  UNS32 *    pwCobId = NULL;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   508
  UNS8 *     pSize;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   509
  UNS8       size;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   510
  UNS8       dataType;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   511
  UNS16      offsetObjdict;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   512
  UNS16      offsetObjdictPrm;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   513
  UNS16      lastIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   514
  UNS8       numMap;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   515
  ind     = 0x00;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   516
  sub_ind = 1;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   517
  offset  = 0x00;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   518
  pSize   = &size;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   519
  status  = state1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   520
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   521
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   522
  /* look for the index and subindex where the variable is mapped */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   523
  /* Then, send the pdo which contains the variable. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   524
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   525
  MSG_WAR (0x3960, "sendPDOevent", 0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   526
  offsetObjdictPrm = d->firstIndex->PDO_TRS;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   527
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   528
  offsetObjdict = d->firstIndex->PDO_TRS_MAP;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   529
  lastIndex = d->lastIndex->PDO_TRS_MAP;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   530
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   531
  if (offsetObjdictPrm && offsetObjdict)
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   532
    /* Loop on PDO Transmit */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   533
    while(offsetObjdict <= lastIndex){
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   534
      /* Check the transmission mode */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   535
      pTransmissionType = d->objdict[offsetObjdictPrm].pSubindex[2].pObject;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   536
      if (*pTransmissionType != TRANS_EVENT) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   537
        ind++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   538
        offsetObjdict++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   539
        offsetObjdictPrm++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   540
        continue;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   541
      }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   542
      pMappingCount = d->objdict[offsetObjdict].pSubindex[0].pObject;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   543
      numMap = 1; /* mapped variable */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   544
      while (numMap <= *pMappingCount) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   545
        pMappingParameter = d->objdict[offsetObjdict].pSubindex[numMap].pObject;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   546
        /* Get the variable */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   547
        objDict = getODentry( d,
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   548
                              (UNS16)((*pMappingParameter) >> 16),
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   549
                              (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & (UNS32)0x000000FF),
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   550
                              (void * *)&pMappedAppObject, pSize, &dataType, 0 );
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   551
        if( objDict != OD_SUCCESSFUL ) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   552
          MSG_WAR(0x2961, "Error in dict. at index : ",
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   553
                  (*pMappingParameter) >> (UNS8)16);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   554
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   555
          MSG_WAR(0x2962, "               subindex : ",
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   556
                  ((*pMappingParameter) >> (UNS8)8 ) & (UNS32)0x000000FF);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   557
          return 0xFF;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   558
        }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   559
        if (pMappedAppObject == variable) { // Variable found !
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   560
          MSG_WAR(0x3963, "Variable to send found at index : ",
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   561
                  (*pMappingParameter) >> 16);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   562
          MSG_WAR(0x3964, "                       subIndex : ",
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   563
                  ((*pMappingParameter) >> 8 ) & 0x000000FF);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   564
          buildPDO(d, 0x1800 + ind);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   565
          /* Get the cobId */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   566
          pwCobId = d->objdict[offsetObjdictPrm].pSubindex[1].pObject;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   567
          PDOmGR( d, *pwCobId ); /* Send the PDO */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   568
          return 0;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   569
        }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   570
        numMap++;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   571
      } /* End loop on mapped variable */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   572
      ind++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   573
      offsetObjdict++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   574
      offsetObjdictPrm++;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   575
    } /* End loop while on PDO */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   576
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   577
  MSG_WAR(0x2965, "Variable not found in a PDO to send on event", 0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   578
  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   579
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   580
}
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   581
#endif
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   582
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   583
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   584