src/sdo.c
author etisserant
Fri, 01 Feb 2008 18:01:36 +0100
changeset 377 bea5a1576cbd
parent 370 6fecf36df407
child 378 d2abf6c8c27b
permissions -rw-r--r--
Enhanced cleanup of TCP CAN client/server
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
*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    22
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    23
** @file   sdo.c
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    24
** @author Edouard TISSERANT and Francis DUPIN
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    25
** @date   Tue Jun  5 09:32:32 2007
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    26
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    27
** @brief
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    28
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    29
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    30
*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    31
84
19def60bd29c forgot some comments ...
frdupin
parents: 82
diff changeset
    32
/* #define DEBUG_WAR_CONSOLE_ON */
19def60bd29c forgot some comments ...
frdupin
parents: 82
diff changeset
    33
/* #define DEBUG_ERR_CONSOLE_ON */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    34
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    35
#include "objacces.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    36
#include "sdo.h"
149
fe50ada8020b Changes in the API:
etisserant
parents: 145
diff changeset
    37
#include "canfestival.h"
370
6fecf36df407 Fixed some endianization problems caused by switch to UNS16 for cob_id member in CAN messages. To be continued.
etisserant
parents: 365
diff changeset
    38
#include "sysdep.h"
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    39
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    40
/* Uncomment if your compiler does not support inline functions */
86
683702a46416 big endian bogue : nodeIdServer in now in 32 bits
frdupin
parents: 84
diff changeset
    41
#define NO_INLINE 
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    42
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    43
#ifdef NO_INLINE
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    44
  #define INLINE 
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    45
#else
86
683702a46416 big endian bogue : nodeIdServer in now in 32 bits
frdupin
parents: 84
diff changeset
    46
  #define INLINE inline
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    47
#endif
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    48
53
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
    49
/*Internals prototypes*/
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
    50
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    51
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    52
** Called by writeNetworkDict
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    53
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    54
** @param d
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    55
** @param nodeId
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    56
** @param index
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    57
** @param subIndex
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    58
** @param count
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    59
** @param dataType
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    60
** @param data
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    61
** @param Callback
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    62
** @param endianize
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    63
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    64
** @return
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    65
**/
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    66
INLINE UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, 
174
cd1638bc0cb0 Added _writenetworkdictionary option to avoir endianiation
etisserant
parents: 172
diff changeset
    67
		       UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize);
53
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
    68
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    69
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    70
** Called by readNetworkDict
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    71
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    72
** @param d
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    73
** @param nodeId
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    74
** @param index
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    75
** @param subIndex
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    76
** @param dataType
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    77
** @param Callback
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    78
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    79
** @return
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
    80
**/
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    81
INLINE UNS8 _readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, 
53
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
    82
	UNS8 dataType, SDOCallback_t Callback);
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
    83
	
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
    84
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    85
/***************************************************************************/
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    86
/* SDO (un)packing macros */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    87
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    88
/** Returns the command specifier (cs, ccs, scs) from the first byte of the SDO   
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    89
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    90
#define getSDOcs(byte) (byte >> 5)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    91
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    92
/** Returns the number of bytes without data from the first byte of the SDO. Coded in 2 bits   
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    93
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    94
#define getSDOn2(byte) ((byte >> 2) & 3)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    95
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    96
/** Returns the number of bytes without data from the first byte of the SDO. Coded in 3 bits   
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    97
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    98
#define getSDOn3(byte) ((byte >> 1) & 7)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    99
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   100
/** Returns the transfer type from the first byte of the SDO   
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   101
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   102
#define getSDOe(byte) ((byte >> 1) & 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   103
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   104
/** Returns the size indicator from the first byte of the SDO   
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   105
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   106
#define getSDOs(byte) (byte & 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   107
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   108
/** Returns the indicator of end transmission from the first byte of the SDO   
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   109
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   110
#define getSDOc(byte) (byte & 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   111
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   112
/** Returns the toggle from the first byte of the SDO   
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   113
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   114
#define getSDOt(byte) ((byte >> 4) & 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   115
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   116
/** Returns the index from the bytes 1 and 2 of the SDO   
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   117
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   118
#define getSDOindex(byte1, byte2) ((byte2 << 8) | (byte1))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   119
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   120
/** Returns the subIndex from the byte 3 of the SDO   
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   121
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   122
#define getSDOsubIndex(byte3) (byte3)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   123
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   124
/*!                                                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   125
**                                                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   126
**                                                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   127
** @param d                                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   128
** @param id                                                                                                               
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   129
**/  
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   130
void SDOTimeoutAlarm(CO_Data* d, UNS32 id)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   131
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   132
    MSG_ERR(0x1A01, "SDO timeout. SDO response not received.", 0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   133
    MSG_WAR(0x2A02, "server node : ", d->transfers[id].nodeId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   134
    MSG_WAR(0x2A02, "      index : ", d->transfers[id].index);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   135
    MSG_WAR(0x2A02, "   subIndex : ", d->transfers[id].subIndex); 
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   136
    /* Reset timer handler */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   137
    d->transfers[id].timer = TIMER_NONE;
172
0248c2b148bb Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents: 166
diff changeset
   138
    /*Set aborted state*/
0248c2b148bb Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents: 166
diff changeset
   139
    d->transfers[id].state = SDO_ABORTED_INTERNAL;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   140
    /* Sending a SDO abort */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   141
    sendSDOabort(d, d->transfers[id].whoami, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   142
		 d->transfers[id].index, d->transfers[id].subIndex, SDOABT_TIMED_OUT);
172
0248c2b148bb Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents: 166
diff changeset
   143
    d->transfers[id].abortCode = SDOABT_TIMED_OUT;
0248c2b148bb Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents: 166
diff changeset
   144
    /* Call the user function to inform of the problem.*/
0248c2b148bb Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents: 166
diff changeset
   145
    if(d->transfers[id].Callback)
0248c2b148bb Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents: 166
diff changeset
   146
    	/*If ther is a callback, it is responsible to close SDO transfer (client)*/
0248c2b148bb Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents: 166
diff changeset
   147
    	(*d->transfers[id].Callback)(d,d->transfers[id].nodeId);
0248c2b148bb Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents: 166
diff changeset
   148
    else if(d->transfers[id].whoami == SDO_SERVER)
0248c2b148bb Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents: 166
diff changeset
   149
    	/*Else, if server, reset the line*/
0248c2b148bb Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents: 166
diff changeset
   150
    	resetSDOline(d, (UNS8)id);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   151
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   152
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   153
#define StopSDO_TIMER(id) \
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   154
MSG_WAR(0x3A05, "StopSDO_TIMER for line : ", line);\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
d->transfers[id].timer = DelAlarm(d->transfers[id].timer);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   156
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   157
#define StartSDO_TIMER(id) \
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   158
MSG_WAR(0x3A06, "StartSDO_TIMER for line : ", line);\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   159
d->transfers[id].timer = SetAlarm(d,id,&SDOTimeoutAlarm,MS_TO_TIMEVAL(SDO_TIMEOUT_MS),0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   160
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   161
#define RestartSDO_TIMER(id) \
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   162
MSG_WAR(0x3A07, "restartSDO_TIMER for line : ", line);\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   163
if(d->transfers[id].timer != TIMER_NONE) { StopSDO_TIMER(id) StartSDO_TIMER(id) }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   164
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   165
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   166
** Reset all sdo buffers                                                                                             
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   167
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   168
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   169
**/  
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   170
void resetSDO (CO_Data* d)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   171
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   172
  UNS8 j;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   173
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   174
  /* transfer structure initialization */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   175
    for (j = 0 ; j < SDO_MAX_SIMULTANEOUS_TRANSFERTS ; j++) 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   176
      resetSDOline(d, j);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   177
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   178
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   179
/*!                                                                                           
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   180
**                                                                                            
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   181
**                                                                                            
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   182
** @param d                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   183
** @param line                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   184
**                                                                                            
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   185
** @return                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   186
**/ 
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   187
UNS32 SDOlineToObjdict (CO_Data* d, UNS8 line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   188
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   189
  UNS8      size;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   190
  UNS32 errorCode;
1
b3dc740b4b04 Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents: 0
diff changeset
   191
  MSG_WAR(0x3A08, "Enter in SDOlineToObjdict ", line);
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents: 87
diff changeset
   192
  size = (UNS8)d->transfers[line].count;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   193
  errorCode = setODentry(d, d->transfers[line].index, d->transfers[line].subIndex, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   194
			 (void *) d->transfers[line].data, &size, 1);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   195
  if (errorCode != OD_SUCCESSFUL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   196
    return errorCode;
1
b3dc740b4b04 Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents: 0
diff changeset
   197
  MSG_WAR(0x3A08, "exit of SDOlineToObjdict ", line);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   198
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   199
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   200
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   201
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   202
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   203
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   204
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   205
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   206
** @param line                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   207
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   208
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   209
**/  
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   210
UNS32 objdictToSDOline (CO_Data* d, UNS8 line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   211
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   212
  UNS8  size = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   213
  UNS8  dataType;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   214
  UNS32 errorCode;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   215
12
1d3b9ad366c8 CANOPEN_BIG_ENDIAN :
dejoigny
parents: 6
diff changeset
   216
  MSG_WAR(0x3A05, "objdict->line index : ", d->transfers[line].index);
1d3b9ad366c8 CANOPEN_BIG_ENDIAN :
dejoigny
parents: 6
diff changeset
   217
  MSG_WAR(0x3A06, "  subIndex : ", d->transfers[line].subIndex);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   218
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   219
  errorCode = getODentry(d, 	d->transfers[line].index,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   220
  				d->transfers[line].subIndex,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   221
  				(void *)d->transfers[line].data,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   222
  				&size, &dataType, 0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   223
  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   224
  if (errorCode != OD_SUCCESSFUL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   225
    return errorCode;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   226
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   227
  d->transfers[line].count = size;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   228
  d->transfers[line].offset = 0;
12
1d3b9ad366c8 CANOPEN_BIG_ENDIAN :
dejoigny
parents: 6
diff changeset
   229
#if 0
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   230
   /*Me laisser a, please ! (FD)*/
12
1d3b9ad366c8 CANOPEN_BIG_ENDIAN :
dejoigny
parents: 6
diff changeset
   231
  {
1d3b9ad366c8 CANOPEN_BIG_ENDIAN :
dejoigny
parents: 6
diff changeset
   232
    UNS8 i;
1d3b9ad366c8 CANOPEN_BIG_ENDIAN :
dejoigny
parents: 6
diff changeset
   233
    for (i = 0 ; i < 10 ; i++) {
1d3b9ad366c8 CANOPEN_BIG_ENDIAN :
dejoigny
parents: 6
diff changeset
   234
      MSG_WAR(i, "data= ", d->transfers[line].data[i]);
1d3b9ad366c8 CANOPEN_BIG_ENDIAN :
dejoigny
parents: 6
diff changeset
   235
    }     
1d3b9ad366c8 CANOPEN_BIG_ENDIAN :
dejoigny
parents: 6
diff changeset
   236
  }
1d3b9ad366c8 CANOPEN_BIG_ENDIAN :
dejoigny
parents: 6
diff changeset
   237
#endif
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   238
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   239
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   240
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   241
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   242
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   243
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   244
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   245
** @param line                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   246
** @param nbBytes                                                                                  
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   247
** @param data                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   248
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   249
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   250
**/  
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   251
UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8* data) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   252
  UNS8 i;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   253
  UNS8 offset;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   254
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   255
  if ((d->transfers[line].offset + nbBytes) > SDO_MAX_LENGTH_TRANSFERT) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   256
    MSG_ERR(0x1A10,"SDO Size of data too large. Exceed SDO_MAX_LENGTH_TRANSFERT", nbBytes);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   257
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   258
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   259
    if ((d->transfers[line].offset + nbBytes) > d->transfers[line].count) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   260
    MSG_ERR(0x1A11,"SDO Size of data too large. Exceed count", nbBytes);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   261
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   262
  }
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents: 87
diff changeset
   263
  offset = (UNS8)d->transfers[line].offset;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   264
  for (i = 0 ; i < nbBytes ; i++) 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   265
    * (data + i) = d->transfers[line].data[offset + i];
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   266
  d->transfers[line].offset = d->transfers[line].offset + nbBytes;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   267
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   268
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   269
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   270
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   271
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   272
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   273
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   274
** @param line                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   275
** @param nbBytes                                                                                  
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   276
** @param data                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   277
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   278
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   279
**/   
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   280
UNS8 SDOtoLine (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8* data)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   281
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   282
  UNS8 i;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   283
  UNS8 offset;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   284
  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   285
  if ((d->transfers[line].offset + nbBytes) > SDO_MAX_LENGTH_TRANSFERT) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   286
    MSG_ERR(0x1A15,"SDO Size of data too large. Exceed SDO_MAX_LENGTH_TRANSFERT", nbBytes);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   287
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   288
  }
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents: 87
diff changeset
   289
  offset = (UNS8)d->transfers[line].offset;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   290
  for (i = 0 ; i < nbBytes ; i++) 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   291
    d->transfers[line].data[offset + i] = * (data + i);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   292
  d->transfers[line].offset = d->transfers[line].offset + nbBytes;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   293
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   294
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   295
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   296
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   297
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   298
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   299
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   300
** @param nodeId                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   301
** @param whoami                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   302
** @param index                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   303
** @param subIndex                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   304
** @param abortCode                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   305
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   306
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   307
**/ 
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   308
UNS8 failedSDO (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS16 index, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   309
		UNS8 subIndex, UNS32 abortCode)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   310
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   311
  UNS8 err;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   312
  UNS8 line;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   313
  err = getSDOlineOnUse( d, nodeId, whoami, &line );
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   314
  if (!err) /* If a line on use have been found.*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   315
    MSG_WAR(0x3A20, "FailedSDO : line found : ", line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   316
  if ((! err) && (whoami == SDO_SERVER)) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   317
    resetSDOline( d, line );
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   318
    MSG_WAR(0x3A21, "FailedSDO : line released : ", line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   319
  }
1
b3dc740b4b04 Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents: 0
diff changeset
   320
  if ((! err) && (whoami == SDO_CLIENT)) {
b3dc740b4b04 Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents: 0
diff changeset
   321
    StopSDO_TIMER(line);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   322
    d->transfers[line].state = SDO_ABORTED_INTERNAL;
1
b3dc740b4b04 Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents: 0
diff changeset
   323
  }
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   324
  MSG_WAR(0x3A22, "Sending SDO abort ", 0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   325
  err = sendSDOabort(d, whoami, index, subIndex, abortCode);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   326
  if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   327
    MSG_WAR(0x3A23, "Unable to send the SDO abort", 0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   328
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   329
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   330
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   331
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   332
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   333
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   334
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   335
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   336
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   337
** @param line                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   338
**/  
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   339
void resetSDOline ( CO_Data* d, UNS8 line )
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   340
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   341
  UNS8 i; 
1
b3dc740b4b04 Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents: 0
diff changeset
   342
  MSG_WAR(0x3A25, "reset SDO line nb : ", line); 
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   343
  initSDOline(d, line, 0, 0, 0, SDO_RESET);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   344
  for (i = 0 ; i < SDO_MAX_LENGTH_TRANSFERT ; i++)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   345
    d->transfers[line].data[i] = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   346
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   347
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   348
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   349
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   350
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   351
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   352
** @param line                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   353
** @param nodeId                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   354
** @param index                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   355
** @param subIndex                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   356
** @param state                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   357
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   358
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   359
**/   
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   360
UNS8 initSDOline (CO_Data* d, UNS8 line, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 state)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   361
{
1
b3dc740b4b04 Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents: 0
diff changeset
   362
  MSG_WAR(0x3A25, "init SDO line nb : ", line); 
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   363
  if (state == SDO_DOWNLOAD_IN_PROGRESS || state == SDO_UPLOAD_IN_PROGRESS){
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   364
  	StartSDO_TIMER(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   365
  }else{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   366
  	StopSDO_TIMER(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   367
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   368
  d->transfers[line].nodeId = nodeId; 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   369
  d->transfers[line].index = index;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   370
  d->transfers[line].subIndex = subIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   371
  d->transfers[line].state = state;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   372
  d->transfers[line].toggle = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   373
  d->transfers[line].count = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   374
  d->transfers[line].offset = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   375
  d->transfers[line].dataType = 0;
32
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
   376
  d->transfers[line].Callback = NULL;  
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   377
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   378
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   379
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   380
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   381
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   382
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   383
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   384
** @param whoami                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   385
** @param line                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   386
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   387
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   388
**/    
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   389
UNS8 getSDOfreeLine ( CO_Data* d, UNS8 whoami, UNS8 *line )
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   390
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   391
	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   392
  UNS8 i;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   393
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   394
  for (i = 0 ; i < SDO_MAX_SIMULTANEOUS_TRANSFERTS ; i++){
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   395
    if ( d->transfers[i].state == SDO_RESET ) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   396
      *line = i;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   397
      d->transfers[i].whoami = whoami;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   398
      return 0;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   399
    } /* end if */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   400
  } /* end for */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   401
  MSG_ERR(0x1A25, "Too many SDO in progress. Aborted.", i);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   402
  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   403
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   404
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   405
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   406
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   407
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   408
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   409
** @param nodeId                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   410
** @param whoami                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   411
** @param line                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   412
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   413
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   414
**/      
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   415
UNS8 getSDOlineOnUse (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS8 *line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   416
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   417
	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   418
  UNS8 i;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   419
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   420
  for (i = 0 ; i < SDO_MAX_SIMULTANEOUS_TRANSFERTS ; i++){
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   421
    if ( (d->transfers[i].state != SDO_RESET) &&
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   422
	 (d->transfers[i].nodeId == nodeId) && 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   423
	 (d->transfers[i].whoami == whoami) ) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   424
      *line = i;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   425
      return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   426
    }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   427
  } 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   428
  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   429
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   430
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   431
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   432
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   433
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   434
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   435
** @param nodeId                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   436
** @param whoami                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   437
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   438
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   439
**/  
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   440
UNS8 closeSDOtransfer (CO_Data* d, UNS8 nodeId, UNS8 whoami)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   441
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   442
  UNS8 err;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   443
  UNS8 line;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   444
  err = getSDOlineOnUse(d, nodeId, whoami, &line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   445
  if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   446
    MSG_WAR(0x2A30, "No SDO communication to close for node : ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   447
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   448
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   449
  resetSDOline(d, line);  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   450
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   451
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   452
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   453
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   454
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   455
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   456
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   457
** @param line                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   458
** @param nbBytes                                                                                  
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   459
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   460
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   461
**/   
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   462
UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 * nbBytes)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   463
{
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   464
  if (d->transfers[line].count == 0) /* if received initiate SDO protocol with e=0 and s=0 */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   465
    * nbBytes = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   466
  else
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents: 87
diff changeset
   467
    * nbBytes = (UNS8)d->transfers[line].count - (UNS8)d->transfers[line].offset;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   468
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   469
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   470
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   471
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   472
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   473
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   474
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   475
** @param line                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   476
** @param nbBytes                                                                                  
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   477
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   478
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   479
**/   
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   480
UNS8 setSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 nbBytes)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   481
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   482
  if (nbBytes > SDO_MAX_LENGTH_TRANSFERT) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   483
    MSG_ERR(0x1A35,"SDO Size of data too large. Exceed SDO_MAX_LENGTH_TRANSFERT", nbBytes);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   484
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   485
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   486
  d->transfers[line].count = nbBytes;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   487
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   488
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   489
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   490
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   491
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   492
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   493
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   494
** @param whoami                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   495
** @param sdo                                                                                  
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   496
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   497
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   498
**/   
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   499
UNS8 sendSDO (CO_Data* d, UNS8 whoami, s_SDO sdo)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   500
{	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   501
  UNS16 offset;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   502
  UNS16 lastIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   503
  UNS8 found = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   504
  Message m;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   505
  UNS8 i;
370
6fecf36df407 Fixed some endianization problems caused by switch to UNS16 for cob_id member in CAN messages. To be continued.
etisserant
parents: 365
diff changeset
   506
  UNS16 * pwCobId = NULL;
306
3586cfa84705 Fixed incoherency with idx 0x1280+n sidx 3 in sdo.c against newly generated objectditcs (UNS32*->UNS8*).
etisserant
parents: 217
diff changeset
   507
  UNS8 * pwNodeId = NULL;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   508
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   509
  MSG_WAR(0x3A38, "sendSDO",0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   510
  if( !((d->nodeState == Operational) ||  (d->nodeState == Pre_operational ))) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   511
    MSG_WAR(0x2A39, "unable to send the SDO (not in op or pre-op mode", d->nodeState);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   512
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   513
  }  				
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   514
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   515
  /*get the server->client cobid*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   516
  if ( whoami == SDO_SERVER )	{/*case server. Easy because today only one server SDO is authorized in CanFestival*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   517
    offset = d->firstIndex->SDO_SVR;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   518
    if (offset == 0) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   519
      MSG_ERR(0x1A42, "SendSDO : No SDO server found", 0); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   520
      return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   521
    }
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
   522
    pwCobId = (UNS32*) d->objdict[offset].pSubindex[2].pObject;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   523
    MSG_WAR(0x3A41, "I am server. cobId : ", *pwCobId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   524
  }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   525
  else {			/*case client*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   526
    /* Get the client->server cobid.*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   527
    UNS16 sdoNum = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   528
    offset = d->firstIndex->SDO_CLT;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   529
    lastIndex = d->lastIndex->SDO_CLT;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   530
    if (offset == 0) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   531
      MSG_ERR(0x1A42, "SendSDO : No SDO client index found", 0); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   532
      return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   533
    }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   534
    /* First, have to find at the index where is defined the communication with the server node */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   535
    while (offset <= lastIndex){
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   536
      MSG_WAR(0x3A43,"Reading index : ", 0x1280 + sdoNum);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   537
      if (d->objdict[offset].bSubCount <= 3) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   538
	MSG_ERR(0x1A28, "Subindex 3  not found at index ", 0x1280 + sdoNum);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   539
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   540
      }
306
3586cfa84705 Fixed incoherency with idx 0x1280+n sidx 3 in sdo.c against newly generated objectditcs (UNS32*->UNS8*).
etisserant
parents: 217
diff changeset
   541
      pwNodeId = (UNS8*) d->objdict[offset].pSubindex[3].pObject;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   542
      MSG_WAR(0x3A44, "Found nodeId server = ", *pwNodeId);	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   543
      if(*pwNodeId == sdo.nodeId) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   544
	found = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   545
	break;          
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   546
      }      
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   547
      offset ++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   548
      sdoNum ++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   549
    }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   550
    if (! found){
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   551
      MSG_WAR (0x2A45, "No SDO client corresponds to the mesage to send to node ", sdo.nodeId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   552
      return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   553
    }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   554
    /* Second, read the cobid client->server */
370
6fecf36df407 Fixed some endianization problems caused by switch to UNS16 for cob_id member in CAN messages. To be continued.
etisserant
parents: 365
diff changeset
   555
    pwCobId = (UNS16*) d->objdict[offset].pSubindex[1].pObject;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   556
  }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   557
  /* message copy for sending */
365
9b76e0881beb Changed cob_id from struct{UNS32} to UNS16
etisserant
parents: 311
diff changeset
   558
  m.cob_id = *pwCobId;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   559
  m.rtr = NOT_A_REQUEST; 
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   560
  /* the length of SDO must be 8 */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   561
  m.len = 8;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   562
  for (i = 0 ; i < 8 ; i++) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   563
    m.data[i] =  sdo.body.data[i];
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   564
  }
149
fe50ada8020b Changes in the API:
etisserant
parents: 145
diff changeset
   565
  return canSend(d->canHandle,&m);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   566
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   567
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   568
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   569
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   570
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   571
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   572
** @param whoami                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   573
** @param index                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   574
** @param subIndex                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   575
** @param abortCode                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   576
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   577
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   578
**/   
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   579
UNS8 sendSDOabort (CO_Data* d, UNS8 whoami, UNS16 index, UNS8 subIndex, UNS32 abortCode)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   580
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   581
  s_SDO sdo;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   582
  UNS8 ret;
1
b3dc740b4b04 Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents: 0
diff changeset
   583
  MSG_WAR(0x2A50,"Sending SDO abort ", abortCode);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   584
  sdo.nodeId = *d->bDeviceNodeId;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   585
  sdo.body.data[0] = 0x80;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   586
  /* Index */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   587
  sdo.body.data[1] = index & 0xFF; /* LSB */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   588
  sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   589
  /* Subindex */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   590
  sdo.body.data[3] = subIndex;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   591
  /* Data */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   592
  sdo.body.data[4] = (UNS8)(abortCode & 0xFF);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   593
  sdo.body.data[5] = (UNS8)((abortCode >> 8) & 0xFF);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   594
  sdo.body.data[6] = (UNS8)((abortCode >> 16) & 0xFF);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   595
  sdo.body.data[7] = (UNS8)((abortCode >> 24) & 0xFF);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   596
  ret = sendSDO(d, whoami, sdo);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   597
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   598
  return ret;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   599
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   600
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   601
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   602
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   603
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   604
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   605
** @param m                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   606
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   607
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
   608
**/   
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   609
UNS8 proceedSDO (CO_Data* d, Message *m)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   610
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   611
  UNS8 err;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   612
  UNS8 line;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   613
  UNS8 nbBytes; /* received or to be transmited. */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   614
  UNS8 nodeId = 0;  /* The node from which the SDO is received */
311
adf4a929cf8b Bug on type inconsistency in SDO Client fixed
lbessard
parents: 306
diff changeset
   615
  UNS8 *pNodeId = NULL;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   616
  UNS8 whoami = SDO_UNKNOWN;  /* SDO_SERVER or SDO_CLIENT.*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   617
  UNS32 errorCode; /* while reading or writing in the local object dictionary.*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   618
  s_SDO sdo;    /* SDO to transmit */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   619
  UNS16 index;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   620
  UNS8 subIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   621
  UNS32 abortCode;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   622
  UNS8 i,j;
370
6fecf36df407 Fixed some endianization problems caused by switch to UNS16 for cob_id member in CAN messages. To be continued.
etisserant
parents: 365
diff changeset
   623
  UNS16 *pCobId = NULL;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   624
  UNS16 offset;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   625
  UNS16 lastIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   626
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   627
  MSG_WAR(0x3A60, "proceedSDO ", 0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   628
  whoami = SDO_UNKNOWN;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   629
  /* Looking for the cobId in the object dictionary. */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   630
  /* Am-I a server ? */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   631
  offset = d->firstIndex->SDO_SVR;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   632
  lastIndex = d->lastIndex->SDO_SVR;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   633
  j = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   634
  if(offset) while (offset <= lastIndex) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   635
     if (d->objdict[offset].bSubCount <= 1) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   636
	  MSG_ERR(0x1A61, "Subindex 1  not found at index ", 0x1200 + j);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   637
	  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   638
	}
370
6fecf36df407 Fixed some endianization problems caused by switch to UNS16 for cob_id member in CAN messages. To be continued.
etisserant
parents: 365
diff changeset
   639
      pCobId = (UNS16*) d->objdict[offset].pSubindex[1].pObject;
365
9b76e0881beb Changed cob_id from struct{UNS32} to UNS16
etisserant
parents: 311
diff changeset
   640
      if ( *pCobId == (*m).cob_id ) {
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   641
	whoami = SDO_SERVER;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   642
	MSG_WAR(0x3A62, "proceedSDO. I am server. index : ", 0x1200 + j);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   643
	/* In case of server, the node id of the client may be unknown. So we put the index minus offset */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   644
	/* 0x1200 where the cobid received is defined. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   645
	nodeId = j;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   646
	break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   647
      }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   648
      j++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   649
      offset++;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   650
  } /* end while */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   651
  if (whoami == SDO_UNKNOWN) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   652
    /* Am-I client ? */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   653
    offset = d->firstIndex->SDO_CLT;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   654
    lastIndex = d->lastIndex->SDO_CLT;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   655
    j = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   656
    if(offset) while (offset <= lastIndex) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   657
       if (d->objdict[offset].bSubCount <= 3) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   658
	 MSG_ERR(0x1A63, "Subindex 3  not found at index ", 0x1280 + j);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   659
	 return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   660
       }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   661
       /* a) Looking for the cobid received. */
370
6fecf36df407 Fixed some endianization problems caused by switch to UNS16 for cob_id member in CAN messages. To be continued.
etisserant
parents: 365
diff changeset
   662
       pCobId = (UNS16*) d->objdict[offset].pSubindex[2].pObject;
365
9b76e0881beb Changed cob_id from struct{UNS32} to UNS16
etisserant
parents: 311
diff changeset
   663
       if (*pCobId == (*m).cob_id ) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   664
	 /* b) cobid found, so reading the node id of the server. */
311
adf4a929cf8b Bug on type inconsistency in SDO Client fixed
lbessard
parents: 306
diff changeset
   665
	 pNodeId = (UNS8*) d->objdict[offset].pSubindex[3].pObject;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   666
	 whoami = SDO_CLIENT;
311
adf4a929cf8b Bug on type inconsistency in SDO Client fixed
lbessard
parents: 306
diff changeset
   667
	 nodeId = *pNodeId;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   668
	 MSG_WAR(0x3A64, "proceedSDO. I am server. index : ", 0x1280 + j);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   669
	 MSG_WAR(0x3A65, "                 Server nodeId : ", nodeId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   670
	 break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   671
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   672
       j++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   673
       offset++;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   674
    } /* end while */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   675
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   676
  if (whoami == SDO_UNKNOWN) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   677
    return 0xFF;/* This SDO was not for us ! */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   678
  }
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   679
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   680
  /* Test if the size of the SDO is ok */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   681
  if ( (*m).len != 8) {
365
9b76e0881beb Changed cob_id from struct{UNS32} to UNS16
etisserant
parents: 311
diff changeset
   682
    MSG_ERR(0x1A67, "Error size SDO. CobId  : ", (*m).cob_id);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   683
    failedSDO(d, nodeId, whoami, 0, 0, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   684
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   685
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   686
  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   687
  if (whoami == SDO_CLIENT) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   688
    MSG_WAR(0x3A68, "I am CLIENT. Received SDO from nodeId : ", nodeId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   689
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   690
  else {
365
9b76e0881beb Changed cob_id from struct{UNS32} to UNS16
etisserant
parents: 311
diff changeset
   691
    MSG_WAR(0x3A69, "I am SERVER. Received SDO cobId : ", (*m).cob_id);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   692
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   693
    
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   694
  /* Testing the command specifier */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   695
  /* Allowed : cs = 0, 1, 2, 3, 4. (=  all except those for block tranfert). */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   696
  /* cs = other : Not allowed -> abort. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   697
  switch (getSDOcs(m->data[0])) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   698
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   699
  case 0:
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   700
    /* I am SERVER */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   701
    if (whoami == SDO_SERVER) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   702
      /* Receiving a download segment data. */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   703
      /* A SDO transfert should have been yet initiated. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   704
      err = getSDOlineOnUse( d, nodeId, whoami, &line ); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   705
      if (!err)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   706
	err = d->transfers[line].state != SDO_DOWNLOAD_IN_PROGRESS;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   707
      if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   708
	MSG_ERR(0x1A70, "SDO error : Received download segment for unstarted trans. index 0x1200 + ", 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   709
		nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   710
	failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   711
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   712
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   713
      /* Reset the wathdog */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   714
      RestartSDO_TIMER(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   715
      MSG_WAR(0x3A71, "Received SDO download segment defined at index 0x1200 + ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   716
      index = d->transfers[line].index;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   717
      subIndex = d->transfers[line].subIndex;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   718
      /* Toggle test. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   719
      if (d->transfers[line].toggle != getSDOt(m->data[0])) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   720
	MSG_ERR(0x1A72, "SDO error : Toggle error : ", getSDOt(m->data[0])); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   721
	failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_TOGGLE_NOT_ALTERNED);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   722
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   723
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   724
      /* Nb of data to be downloaded */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   725
      nbBytes = 7 - getSDOn3(m->data[0]);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   726
      /* Store the data in the transfert structure. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   727
      err = SDOtoLine(d, line, nbBytes, (*m).data + 1);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   728
      if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   729
	failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   730
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   731
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   732
      /* Sending the SDO response, CS = 1 */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   733
      sdo.nodeId = *d->bDeviceNodeId; /* The node id of the server, (here it is the sender). */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   734
      sdo.body.data[0] = (1 << 5) | (d->transfers[line].toggle << 4);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   735
      for (i = 1 ; i < 8 ; i++)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   736
	sdo.body.data[i] = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   737
      MSG_WAR(0x3A73, "SDO. Send response to download request defined at index 0x1200 + ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   738
      sendSDO(d, whoami, sdo);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   739
      /* Inverting the toggle for the next segment. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   740
      d->transfers[line].toggle = ! d->transfers[line].toggle & 1;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   741
      /* If it was the last segment, */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   742
      if (getSDOc(m->data[0])) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   743
	/* Transfering line data to object dictionary. */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   744
	/* The code does not use the "d" of initiate frame. So it is safe if e=s=0 */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   745
	errorCode = SDOlineToObjdict(d, line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   746
	if (errorCode) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   747
	  MSG_ERR(0x1A54, "SDO error : Unable to copy the data in the object dictionary", 0); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   748
	  failedSDO(d, nodeId, whoami, index, subIndex, errorCode);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   749
	  return 0xFF;	  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   750
	}
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   751
	/* Release of the line */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   752
	resetSDOline(d, line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   753
	MSG_WAR(0x3A74, "SDO. End of download defined at index 0x1200 + ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   754
      }
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   755
    } /* end if SERVER */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   756
    else { /* if CLIENT */
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   757
      /* I am CLIENT */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   758
      /* It is a request for a previous upload segment. We should find a line opened for this.*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   759
      err = getSDOlineOnUse( d, nodeId, whoami, &line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   760
      if (!err)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   761
	err = d->transfers[line].state != SDO_UPLOAD_IN_PROGRESS;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   762
      if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   763
	MSG_ERR(0x1A75, "SDO error : Received segment response for unknown trans. from nodeId", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   764
	failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   765
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   766
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   767
      /* Reset the wathdog */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   768
      RestartSDO_TIMER(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   769
      index = d->transfers[line].index;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   770
      subIndex = d->transfers[line].subIndex;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   771
      /* test of the toggle; */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   772
      if (d->transfers[line].toggle != getSDOt(m->data[0])) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   773
	MSG_ERR(0x1A76, "SDO error : Received segment response Toggle error. from nodeId", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   774
	failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_TOGGLE_NOT_ALTERNED);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   775
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   776
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   777
      /* nb of data to be uploaded */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   778
      nbBytes = 7 - getSDOn3(m->data[0]);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   779
      /* Storing the data in the line structure. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   780
      err = SDOtoLine(d, line, nbBytes, (*m).data + 1);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   781
      if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   782
	failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   783
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   784
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   785
      /* Inverting the toggle for the next segment. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   786
      d->transfers[line].toggle = ! d->transfers[line].toggle & 1;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   787
      /* If it was the last segment,*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   788
      if ( getSDOc(m->data[0])) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   789
	/* Put in state finished */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   790
	/* The code is safe for the case e=s=0 in initiate frame. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   791
	StopSDO_TIMER(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   792
	d->transfers[line].state = SDO_FINISHED;
32
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
   793
	if(d->transfers[line].Callback) (*d->transfers[line].Callback)(d,nodeId);
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
   794
	
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   795
	MSG_WAR(0x3A77, "SDO. End of upload from node : ", nodeId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   796
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   797
      else { /* more segments to receive */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   798
	     /* Sending the request for the next segment. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   799
	sdo.nodeId = nodeId;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   800
	sdo.body.data[0] = (3 << 5) | (d->transfers[line].toggle << 4);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   801
	for (i = 1 ; i < 8 ; i++)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   802
	  sdo.body.data[i] = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   803
	sendSDO(d, whoami, sdo);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   804
	MSG_WAR(0x3A78, "SDO send upload segment request to nodeId", nodeId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   805
      }            
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   806
    } /* End if CLIENT */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   807
    break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   808
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   809
  case 1:
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   810
    /* I am SERVER */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   811
    /* Receive of an initiate download */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   812
    if (whoami == SDO_SERVER) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   813
      index = getSDOindex(m->data[1],m->data[2]);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   814
      subIndex = getSDOsubIndex(m->data[3]);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   815
      MSG_WAR(0x3A79, "Received SDO Initiate Download (to store data) defined at index 0x1200 + ", 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   816
	      nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   817
      MSG_WAR(0x3A80, "Writing at index : ", index);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   818
      MSG_WAR(0x3A80, "Writing at subIndex : ", subIndex);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   819
      
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   820
      /* Search if a SDO transfert have been yet initiated */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   821
      err = getSDOlineOnUse( d, nodeId, whoami, &line );
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   822
      if (! err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   823
	MSG_ERR(0x1A81, "SDO error : Transmission yet started.", 0); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   824
	failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_LOCAL_CTRL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   825
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   826
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   827
      /* No line on use. Great ! */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   828
      /* Try to open a new line. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   829
      err = getSDOfreeLine( d, whoami, &line );
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   830
      if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   831
	MSG_ERR(0x1A82, "SDO error : No line free, too many SDO in progress. Aborted.", 0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   832
	failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_LOCAL_CTRL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   833
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   834
      }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   835
      initSDOline(d, line, nodeId, index, subIndex, SDO_DOWNLOAD_IN_PROGRESS);      
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   836
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   837
      if (getSDOe(m->data[0])) { /* If SDO expedited */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   838
	/* nb of data to be downloaded */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   839
	nbBytes = 4 - getSDOn2(m->data[0]);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   840
	/* Storing the data in the line structure. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   841
	d->transfers[line].count = nbBytes;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   842
	err = SDOtoLine(d, line, nbBytes, (*m).data + 4);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   843
	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   844
	if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   845
	  failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   846
	  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   847
	}	  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   848
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   849
	/* SDO expedited -> transfert finished. Data can be stored in the dictionary. */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   850
	/*The line will be reseted when it is downloading in the dictionary. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   851
	MSG_WAR(0x3A83, "SDO Initiate Download is an expedited transfert. Finished.: ", nodeId);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   852
	/* Transfering line data to object dictionary. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   853
	errorCode = SDOlineToObjdict(d, line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   854
	if (errorCode) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   855
	  MSG_ERR(0x1A84, "SDO error : Unable to copy the data in the object dictionary", 0); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   856
	  failedSDO(d, nodeId, whoami, index, subIndex, errorCode);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   857
	  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   858
	}
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   859
	/* Release of the line. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   860
	resetSDOline(d, line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   861
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   862
      else {/* So, if it is not an expedited transfert */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   863
	if (getSDOs(m->data[0])) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   864
	  /* TODO : if e and s = 0, not reading m->data[4] but put nbBytes = 0 */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   865
	  nbBytes = m->data[4]; /* Transfert limited to 255 bytes. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   866
	  err = setSDOlineRestBytes(d, nodeId, nbBytes);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   867
	  if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   868
	    failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   869
	    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   870
	  }	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   871
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   872
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   873
      /*Sending a SDO, cs=3*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   874
      sdo.nodeId = *d->bDeviceNodeId; /* The node id of the server, (here it is the sender).*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   875
      sdo.body.data[0] = 3 << 5;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   876
      sdo.body.data[1] = index & 0xFF;        /* LSB */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   877
      sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   878
      sdo.body.data[3] = subIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   879
      for (i = 4 ; i < 8 ; i++)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   880
		sdo.body.data[i] = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   881
      sendSDO(d, whoami, sdo);
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   882
    } /* end if I am SERVER */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   883
    else {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   884
      /* I am CLIENT */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   885
      /* It is a response for a previous download segment. We should find a line opened for this. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   886
      err = getSDOlineOnUse( d, nodeId, whoami, &line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   887
      if (!err)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   888
	err = d->transfers[line].state != SDO_DOWNLOAD_IN_PROGRESS;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   889
      if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   890
	MSG_ERR(0x1A85, "SDO error : Received segment response for unknown trans. from nodeId", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   891
	failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   892
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   893
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   894
      /* Reset the wathdog */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   895
      RestartSDO_TIMER(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   896
      index = d->transfers[line].index;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   897
      subIndex = d->transfers[line].subIndex;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   898
      /* test of the toggle; */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   899
      if (d->transfers[line].toggle != getSDOt(m->data[0])) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   900
	MSG_ERR(0x1A86, "SDO error : Received segment response Toggle error. from nodeId", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   901
	failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_TOGGLE_NOT_ALTERNED);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   902
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   903
      }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   904
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   905
      /* End transmission or downloading next segment. We need to know if it will be the last one. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   906
      getSDOlineRestBytes(d, line, &nbBytes);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   907
      if (nbBytes == 0) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   908
	MSG_WAR(0x3A87, "SDO End download. segment response received. OK. from nodeId", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   909
	StopSDO_TIMER(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   910
	d->transfers[line].state = SDO_FINISHED;
32
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
   911
	if(d->transfers[line].Callback) (*d->transfers[line].Callback)(d,nodeId);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   912
	return 0x00;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   913
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   914
      /* At least one transfer to send.	*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   915
      if (nbBytes > 7) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   916
	/* several segments to download.*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   917
	/* code to send the next segment. (cs = 0; c = 0) */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   918
	d->transfers[line].toggle = ! d->transfers[line].toggle & 1;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   919
	sdo.nodeId = nodeId; /* The server node Id; */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   920
	sdo.body.data[0] = (d->transfers[line].toggle << 4);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   921
	err = lineToSDO(d, line, 7, sdo.body.data + 1);	 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   922
	if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   923
	  failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   924
	  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   925
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   926
      } 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   927
      else {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   928
	/* Last segment. */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   929
	/* code to send the last segment. (cs = 0; c = 1)*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   930
	d->transfers[line].toggle = ! d->transfers[line].toggle & 1;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   931
	sdo.nodeId = nodeId; /* The server node Id; */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   932
	sdo.body.data[0] = (d->transfers[line].toggle << 4) | ((7 - nbBytes) << 1) | 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   933
	err = lineToSDO(d, line, nbBytes, sdo.body.data + 1);	 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   934
	if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   935
	  failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   936
	  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   937
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   938
	for (i = nbBytes + 1 ; i < 8 ; i++)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   939
	  sdo.body.data[i] = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   940
      }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   941
      MSG_WAR(0x3A88, "SDO sending download segment to nodeId", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   942
      sendSDO(d, whoami, sdo); 
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   943
    } /* end if I am a CLIENT */			  
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   944
    break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   945
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   946
  case 2:
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   947
    /* I am SERVER */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   948
    /* Receive of an initiate upload.*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   949
    if (whoami == SDO_SERVER) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   950
      index = getSDOindex(m->data[1],m->data[2]);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   951
      subIndex = getSDOsubIndex(m->data[3]);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   952
      MSG_WAR(0x3A89, "Received SDO Initiate upload (to send data) defined at index 0x1200 + ", 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   953
	      nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   954
      MSG_WAR(0x3A90, "Reading at index : ", index);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   955
      MSG_WAR(0x3A91, "Reading at subIndex : ", subIndex);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   956
      /* Search if a SDO transfert have been yet initiated*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   957
      err = getSDOlineOnUse( d, nodeId, whoami, &line );
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   958
      if (! err) {
12
1d3b9ad366c8 CANOPEN_BIG_ENDIAN :
dejoigny
parents: 6
diff changeset
   959
	    MSG_ERR(0x1A92, "SDO error : Transmission yet started at line : ", line); 
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   960
        MSG_WAR(0x3A93, "nodeId = ", nodeId); 
12
1d3b9ad366c8 CANOPEN_BIG_ENDIAN :
dejoigny
parents: 6
diff changeset
   961
	    failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_LOCAL_CTRL_ERROR);
1d3b9ad366c8 CANOPEN_BIG_ENDIAN :
dejoigny
parents: 6
diff changeset
   962
	    return 0xFF;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   963
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   964
      /* No line on use. Great !*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   965
      /* Try to open a new line.*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   966
      err = getSDOfreeLine( d, whoami, &line );
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   967
      if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   968
	MSG_ERR(0x1A71, "SDO error : No line free, too many SDO in progress. Aborted.", 0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   969
	failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_LOCAL_CTRL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   970
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   971
      }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   972
      initSDOline(d, line, nodeId, index, subIndex, SDO_UPLOAD_IN_PROGRESS);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   973
      /* Transfer data from dictionary to the line structure. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   974
      errorCode = objdictToSDOline(d, line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   975
     
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   976
      if (errorCode) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   977
	MSG_ERR(0x1A94, "SDO error : Unable to copy the data from object dictionary. Err code : ", 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   978
		errorCode); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   979
	failedSDO(d, nodeId, whoami, index, subIndex, errorCode);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   980
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   981
	}
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   982
      /* Preparing the response.*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   983
      getSDOlineRestBytes(d, line, &nbBytes);	/* Nb bytes to transfer ? */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   984
      sdo.nodeId = nodeId; /* The server node Id; */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   985
      if (nbBytes > 4) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   986
	/* normal transfert. (segmented). */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   987
	/* code to send the initiate upload response. (cs = 2) */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   988
	sdo.body.data[0] = (2 << 5) | 1;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   989
	sdo.body.data[1] = index & 0xFF;        /* LSB */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   990
	sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   991
	sdo.body.data[3] = subIndex;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   992
        sdo.body.data[4] = nbBytes; /* Limitation of canfestival2 : Max tranfert is 256 bytes.*/
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   993
	/* It takes too much memory to upgrate to 2^32 because the size of data is also coded */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   994
	/* in the object dictionary, at every index and subindex. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   995
	for (i = 5 ; i < 8 ; i++)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   996
	  sdo.body.data[i] = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   997
	MSG_WAR(0x3A95, "SDO. Sending normal upload initiate response defined at index 0x1200 + ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   998
	sendSDO(d, whoami, sdo); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   999
      }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1000
      else {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1001
	/* Expedited upload. (cs = 2 ; e = 1) */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1002
	sdo.body.data[0] = (2 << 5) | ((4 - nbBytes) << 2) | 3;  
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1003
	sdo.body.data[1] = index & 0xFF;        /* LSB */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1004
	sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1005
	sdo.body.data[3] = subIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1006
	err = lineToSDO(d, line, nbBytes, sdo.body.data + 4);	 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1007
	if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1008
	  failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1009
	  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1010
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1011
	for (i = 4 + nbBytes ; i < 8 ; i++)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1012
	  sdo.body.data[i] = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1013
	MSG_WAR(0x3A96, "SDO. Sending expedited upload initiate response defined at index 0x1200 + ", 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1014
		nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1015
	sendSDO(d, whoami, sdo); 
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1016
	/* Release the line.*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1017
	resetSDOline(d, line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1018
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1019
    } /* end if I am SERVER*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1020
    else {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1021
      /* I am CLIENT */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1022
      /* It is the response for the previous initiate upload request.*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1023
      /* We should find a line opened for this. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1024
      err = getSDOlineOnUse( d, nodeId, whoami, &line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1025
      if (!err)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1026
	err = d->transfers[line].state != SDO_UPLOAD_IN_PROGRESS;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1027
      if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1028
	MSG_ERR(0x1A97, "SDO error : Received response for unknown upload request from nodeId", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1029
	failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1030
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1031
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1032
      /* Reset the wathdog */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1033
      RestartSDO_TIMER(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1034
      index = d->transfers[line].index;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1035
      subIndex = d->transfers[line].subIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1036
      
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1037
      if (getSDOe(m->data[0])) { /* If SDO expedited */
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1038
	/* nb of data to be uploaded */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1039
	  nbBytes = 4 - getSDOn2(m->data[0]);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1040
	/* Storing the data in the line structure. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1041
	err = SDOtoLine(d, line, nbBytes, (*m).data + 4);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1042
	if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1043
	  failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1044
	  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1045
	}
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1046
	/* SDO expedited -> transfert finished. data are available via  getReadResultNetworkDict(). */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1047
	MSG_WAR(0x3A98, "SDO expedited upload finished. Response received from node : ", nodeId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1048
	StopSDO_TIMER(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1049
	d->transfers[line].count = nbBytes;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1050
	d->transfers[line].state = SDO_FINISHED;
32
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1051
	if(d->transfers[line].Callback) (*d->transfers[line].Callback)(d,nodeId);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1052
	return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1053
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1054
      else { /* So, if it is not an expedited transfert */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1055
	/* Storing the nb of data to receive. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1056
	if (getSDOs(m->data[0])) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1057
	  nbBytes = m->data[4]; /* Remember the limitation to 255 bytes to transfert */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1058
	  err = setSDOlineRestBytes(d, line, nbBytes);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1059
	  if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1060
	    failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1061
	    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1062
	  }	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1063
	}
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1064
	/* Requesting next segment. (cs = 3) */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1065
	sdo.nodeId = nodeId;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1066
	sdo.body.data[0] = 3 << 5;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1067
	for (i = 1 ; i < 8 ; i++)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1068
	  sdo.body.data[i] = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1069
	MSG_WAR(0x3A99, "SDO. Sending upload segment request to node : ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1070
	sendSDO(d, whoami, sdo);  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1071
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1072
    } /* End if CLIENT */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1073
    break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1074
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1075
  case 3:
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1076
    /* I am SERVER */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1077
    if (whoami == SDO_SERVER) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1078
      /* Receiving a upload segment. */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1079
      /* A SDO transfert should have been yet initiated. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1080
      err = getSDOlineOnUse( d, nodeId, whoami, &line ); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1081
      if (!err)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1082
	err = d->transfers[line].state != SDO_UPLOAD_IN_PROGRESS;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1083
      if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1084
	MSG_ERR(0x1AA0, "SDO error : Received upload segment for unstarted trans. index 0x1200 + ", 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1085
		nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1086
	failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1087
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1088
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1089
      /* Reset the wathdog */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1090
      RestartSDO_TIMER(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1091
      MSG_WAR(0x3AA1, "Received SDO upload segment defined at index 0x1200 + ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1092
      index = d->transfers[line].index;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1093
      subIndex = d->transfers[line].subIndex;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1094
      /* Toggle test.*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1095
      if (d->transfers[line].toggle != getSDOt(m->data[0])) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1096
	MSG_ERR(0x1AA2, "SDO error : Toggle error : ", getSDOt(m->data[0])); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1097
	failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_TOGGLE_NOT_ALTERNED);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1098
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1099
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1100
      /* Uploading next segment. We need to know if it will be the last one. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1101
      getSDOlineRestBytes(d, line, &nbBytes);	  	  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1102
      if (nbBytes > 7) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1103
	/* The segment to transfer is not the last one.*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1104
	/* code to send the next segment. (cs = 0; c = 0) */
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1105
	sdo.nodeId = nodeId; /* The server node Id; */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1106
	sdo.body.data[0] = (d->transfers[line].toggle << 4);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1107
	err = lineToSDO(d, line, 7, sdo.body.data + 1);	 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1108
	if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1109
	  failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1110
	  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1111
	}
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1112
	/* Inverting the toggle for the next tranfert. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1113
	d->transfers[line].toggle = ! d->transfers[line].toggle & 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1114
	MSG_WAR(0x3AA3, "SDO. Sending upload segment defined at index 0x1200 + ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1115
	sendSDO(d, whoami, sdo); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1116
      } 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1117
      else {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1118
	/* Last segment. */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1119
	/* code to send the last segment. (cs = 0; c = 1) */	    
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1120
	sdo.nodeId = nodeId; /** The server node Id; */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1121
	sdo.body.data[0] = (d->transfers[line].toggle << 4) | ((7 - nbBytes) << 1) | 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1122
	err = lineToSDO(d, line, nbBytes, sdo.body.data + 1);	 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1123
	if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1124
	  failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1125
	  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1126
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1127
	for (i = nbBytes + 1 ; i < 8 ; i++)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1128
	  sdo.body.data[i] = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1129
	MSG_WAR(0x3AA4, "SDO. Sending last upload segment defined at index 0x1200 + ", nodeId);      
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1130
	sendSDO(d, whoami, sdo);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1131
	/* Release the line */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1132
	resetSDOline(d, line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1133
      }
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1134
    } /* end if SERVER*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1135
    else {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1136
      /* I am CLIENT */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1137
      /* It is the response for the previous initiate download request. */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1138
      /* We should find a line opened for this. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1139
      err = getSDOlineOnUse( d, nodeId, whoami, &line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1140
      if (!err)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1141
	err = d->transfers[line].state != SDO_DOWNLOAD_IN_PROGRESS;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1142
      if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1143
	MSG_ERR(0x1AA5, "SDO error : Received response for unknown download request from nodeId", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1144
	failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1145
	return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1146
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1147
      /* Reset the watchdog */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1148
      RestartSDO_TIMER(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1149
      index = d->transfers[line].index;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1150
      subIndex = d->transfers[line].subIndex;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1151
      /* End transmission or requesting  next segment. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1152
      getSDOlineRestBytes(d, line, &nbBytes);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1153
      if (nbBytes == 0) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1154
	MSG_WAR(0x3AA6, "SDO End download expedited. Response received. from nodeId", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1155
	StopSDO_TIMER(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1156
	d->transfers[line].state = SDO_FINISHED;
32
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1157
	if(d->transfers[line].Callback) (*d->transfers[line].Callback)(d,nodeId);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1158
	return 0x00;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1159
      }	  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1160
      if (nbBytes > 7) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1161
	/* more than one request to send */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1162
	/* code to send the next segment. (cs = 0; c = 0)	*/    
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1163
	sdo.nodeId = nodeId; /** The server node Id; */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1164
	sdo.body.data[0] = (d->transfers[line].toggle << 4);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1165
	err = lineToSDO(d, line, 7, sdo.body.data + 1);	 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1166
	if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1167
	  failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1168
	  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1169
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1170
      } 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1171
      else {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1172
	/* Last segment.*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1173
	/* code to send the last segment. (cs = 0; c = 1)	*/   
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1174
	sdo.nodeId = nodeId; /* The server node Id; */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1175
	sdo.body.data[0] = (d->transfers[line].toggle << 4) | ((7 - nbBytes) << 1) | 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1176
	err = lineToSDO(d, line, nbBytes, sdo.body.data + 1);	 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1177
	if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1178
	  failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1179
	  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1180
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1181
	for (i = nbBytes + 1 ; i < 8 ; i++)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1182
	  sdo.body.data[i] = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1183
      }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1184
      MSG_WAR(0x3AA7, "SDO sending download segment to nodeId", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1185
      sendSDO(d, whoami, sdo); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1186
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1187
    } /* end if I am a CLIENT		*/	  
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1188
    break;  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1189
82
81505425b1e5 16 bits arch compatibility and unused variables
frdupin
parents: 71
diff changeset
  1190
   case 4:
81505425b1e5 16 bits arch compatibility and unused variables
frdupin
parents: 71
diff changeset
  1191
     abortCode = (*m).data[3] |
81505425b1e5 16 bits arch compatibility and unused variables
frdupin
parents: 71
diff changeset
  1192
      ((UNS32)m->data[5] << 8) |
81505425b1e5 16 bits arch compatibility and unused variables
frdupin
parents: 71
diff changeset
  1193
      ((UNS32)m->data[6] << 16) |
81505425b1e5 16 bits arch compatibility and unused variables
frdupin
parents: 71
diff changeset
  1194
      ((UNS32)m->data[7] << 24);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1195
    /* Received SDO abort. */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1196
    /* Looking for the line concerned. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1197
    if (whoami == SDO_SERVER) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1198
      err = getSDOlineOnUse( d, nodeId, whoami, &line );
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1199
      if (!err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1200
	resetSDOline( d, line );
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1201
	MSG_WAR(0x3AA8, "SD0. Received SDO abort. Line released. Code : ", abortCode);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1202
      }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1203
      else
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1204
	MSG_WAR(0x3AA9, "SD0. Received SDO abort. No line found. Code : ", abortCode);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1205
      /* Tips : The end user has no way to know that the server node has received an abort SDO. */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1206
      /* Its is ok, I think.*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1207
    }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1208
    else { /* If I am CLIENT */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1209
      err = getSDOlineOnUse( d, nodeId, whoami, &line );
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1210
      if (!err) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1211
	/* The line *must* be released by the core program. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1212
	StopSDO_TIMER(line)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1213
	d->transfers[line].state = SDO_ABORTED_RCV;
166
b6fbc1c59a44 Added a MicroMod Master sample in examples/TestMasterMicroMod. Fixed some SDO abort code and callback problem in sdo.c.
etisserant
parents: 163
diff changeset
  1214
	d->transfers[line].abortCode = abortCode;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1215
	MSG_WAR(0x3AB0, "SD0. Received SDO abort. Line state ABORTED. Code : ", abortCode);
163
212a9ea3b968 Added SDO network dictionnary access callback when aborded.
etisserant
parents: 154
diff changeset
  1216
	if(d->transfers[line].Callback) (*d->transfers[line].Callback)(d,nodeId);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1217
      }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1218
      else
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1219
	MSG_WAR(0x3AB1, "SD0. Received SDO abort. No line found. Code : ", abortCode);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1220
    } 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1221
    break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1222
  default:
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1223
    /* Error : Unknown cs */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1224
    MSG_ERR(0x1AB2, "SDO. Received unknown command specifier : ", getSDOcs(m->data[0]));
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1225
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1226
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1227
  } /* End switch */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1228
  return 0;     
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1229
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1230
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1231
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1232
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1233
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1234
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1235
** @param nodeId                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1236
** @param index                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1237
** @param subIndex                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1238
** @param count                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1239
** @param dataType                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1240
** @param data                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1241
** @param Callback                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1242
** @param endianize                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1243
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1244
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1245
**/   
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1246
INLINE UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, 
174
cd1638bc0cb0 Added _writenetworkdictionary option to avoir endianiation
etisserant
parents: 172
diff changeset
  1247
		       UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1248
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1249
  UNS8 err;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1250
  UNS8 SDOfound = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1251
  UNS8 line;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1252
  s_SDO sdo;    /* SDO to transmit */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1253
  UNS8 i, j;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1254
  UNS16     lastIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1255
  UNS16     offset;
311
adf4a929cf8b Bug on type inconsistency in SDO Client fixed
lbessard
parents: 306
diff changeset
  1256
  UNS8      *pNodeIdServer;
adf4a929cf8b Bug on type inconsistency in SDO Client fixed
lbessard
parents: 306
diff changeset
  1257
  UNS8      nodeIdServer;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1258
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1259
  MSG_WAR(0x3AC0, "Send SDO to write in the dictionary of node : ", nodeId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1260
  MSG_WAR(0x3AC1, "                                   At index : ", index);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1261
  MSG_WAR(0x3AC2, "                                   subIndex : ", subIndex);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1262
  MSG_WAR(0x3AC3, "                                   nb bytes : ", count);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1263
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1264
  /* Verify that there is no SDO communication yet. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1265
  err = getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1266
  if (!err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1267
    MSG_ERR(0x1AC4, "SDO error : Communication yet established. with node : ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1268
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1269
  }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1270
  /* Taking the line ... */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1271
  err = getSDOfreeLine( d, SDO_CLIENT, &line );
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1272
  if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1273
    MSG_ERR(0x1AC5, "SDO error : No line free, too many SDO in progress. Aborted for node : ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1274
    return (0xFF);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1275
  }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1276
  /* Check which SDO to use to communicate with the node */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1277
  offset = d->firstIndex->SDO_CLT;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1278
  lastIndex = d->lastIndex->SDO_CLT;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1279
  if (offset == 0) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1280
    MSG_ERR(0x1AC6, "writeNetworkDict : No SDO client index found", 0); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1281
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1282
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1283
  i = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1284
   while (offset <= lastIndex) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1285
     if (d->objdict[offset].bSubCount <= 3) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1286
	 MSG_ERR(0x1AC8, "Subindex 3  not found at index ", 0x1280 + i);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1287
	 return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1288
     }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1289
     /* looking for the nodeId server */
311
adf4a929cf8b Bug on type inconsistency in SDO Client fixed
lbessard
parents: 306
diff changeset
  1290
     pNodeIdServer = (UNS8*) d->objdict[offset].pSubindex[3].pObject;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1291
     nodeIdServer = *pNodeIdServer;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1292
     MSG_WAR(0x1AD2, "index : ", 0x1280 + i);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1293
     MSG_WAR(0x1AD3, "nodeIdServer : ", nodeIdServer);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1294
   
311
adf4a929cf8b Bug on type inconsistency in SDO Client fixed
lbessard
parents: 306
diff changeset
  1295
    if(nodeIdServer == nodeId) {
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1296
      SDOfound = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1297
      break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1298
    }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1299
    offset++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1300
    i++;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1301
  } /* end while */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1302
  if (!SDOfound) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1303
    MSG_ERR(0x1AC9, "SDO. Error. No client found to communicate with node : ", nodeId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1304
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1305
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1306
  MSG_WAR(0x3AD0,"        SDO client defined at index  : ", 0x1280 + i);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1307
  initSDOline(d, line, nodeId, index, subIndex, SDO_DOWNLOAD_IN_PROGRESS);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1308
  d->transfers[line].count = count;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1309
  d->transfers[line].dataType = dataType;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1310
  
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1311
  /* Copy data to transfers structure. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1312
  for (j = 0 ; j < count ; j++) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1313
# ifdef CANOPEN_BIG_ENDIAN
174
cd1638bc0cb0 Added _writenetworkdictionary option to avoir endianiation
etisserant
parents: 172
diff changeset
  1314
    if (dataType == 0 && endianize)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1315
      d->transfers[line].data[count - 1 - j] = ((char *)data)[j];
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1316
    else /* String of bytes. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1317
      d->transfers[line].data[j] = ((char *)data)[j];
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1318
#  else 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1319
    d->transfers[line].data[j] = ((char *)data)[j];
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1320
#  endif
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1321
  }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1322
  /* Send the SDO to the server. Initiate download, cs=1. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1323
  sdo.nodeId = nodeId;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1324
  if (count <= 4) { /* Expedited transfert */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1325
    sdo.body.data[0] = (1 << 5) | ((4 - count) << 2) | 3;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1326
    for (i = 4 ; i < 8 ; i++)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1327
      sdo.body.data[i] = d->transfers[line].data[i - 4];
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1328
    d->transfers[line].offset = count;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1329
  }	
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1330
  else { /** Normal transfert */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1331
    sdo.body.data[0] = (1 << 5) | 1;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1332
    sdo.body.data[4] = count; /* nb of byte to transmit. Max = 255. (canfestival2 limitation). */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1333
    for (i = 5 ; i < 8 ; i++)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1334
      sdo.body.data[i] = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1335
  }
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1336
  sdo.body.data[1] = index & 0xFF;        /* LSB */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1337
  sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1338
  sdo.body.data[3] = subIndex;
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
  1339
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
  1340
  d->transfers[line].Callback = Callback;
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
  1341
    
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1342
  err = sendSDO(d, SDO_CLIENT, sdo);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1343
  if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1344
    MSG_ERR(0x1AD1, "SDO. Error while sending SDO to node : ", nodeId);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1345
    /* release the line */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1346
    resetSDOline(d, line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1347
    return 0xFF;
32
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1348
  }
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
  1349
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
  1350
  
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1351
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1352
}
53
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
  1353
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1354
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1355
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1356
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1357
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1358
** @param nodeId                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1359
** @param index                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1360
** @param subIndex                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1361
** @param count                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1362
** @param dataType                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1363
** @param data                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1364
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1365
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1366
**/   
32
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1367
UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, 
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1368
		       UNS8 subIndex, UNS8 count, UNS8 dataType, void *data)
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1369
{
174
cd1638bc0cb0 Added _writenetworkdictionary option to avoir endianiation
etisserant
parents: 172
diff changeset
  1370
	return _writeNetworkDict (d, nodeId, index, subIndex, count, dataType, data, NULL, 1);
32
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1371
}
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1372
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1373
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1374
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1375
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1376
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1377
** @param nodeId                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1378
** @param index                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1379
** @param subIndex                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1380
** @param count                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1381
** @param dataType                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1382
** @param data                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1383
** @param Callback                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1384
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1385
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1386
**/  
32
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1387
UNS8 writeNetworkDictCallBack (CO_Data* d, UNS8 nodeId, UNS16 index, 
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1388
		       UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback)
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1389
{
174
cd1638bc0cb0 Added _writenetworkdictionary option to avoir endianiation
etisserant
parents: 172
diff changeset
  1390
	return _writeNetworkDict (d, nodeId, index, subIndex, count, dataType, data, Callback, 1);	
32
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1391
}
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1392
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1393
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1394
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1395
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1396
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1397
** @param nodeId                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1398
** @param index                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1399
** @param subIndex                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1400
** @param dataType                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1401
** @param Callback                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1402
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1403
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1404
**/ 
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1405
INLINE UNS8 _readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1406
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1407
  UNS8 err;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1408
  UNS8 SDOfound = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1409
  UNS8 i;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1410
  UNS8 line;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1411
  s_SDO sdo;    /* SDO to transmit */
311
adf4a929cf8b Bug on type inconsistency in SDO Client fixed
lbessard
parents: 306
diff changeset
  1412
  UNS8      *pNodeIdServer;
adf4a929cf8b Bug on type inconsistency in SDO Client fixed
lbessard
parents: 306
diff changeset
  1413
  UNS8      nodeIdServer;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1414
  UNS16     offset;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1415
  UNS16     lastIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1416
  MSG_WAR(0x3AD5, "Send SDO to read in the dictionary of node : ", nodeId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1417
  MSG_WAR(0x3AD6, "                                  At index : ", index);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1418
  MSG_WAR(0x3AD7, "                                  subIndex : ", subIndex);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1419
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1420
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1421
  /* Verify that there is no SDO communication yet. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1422
  err = getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1423
  if (!err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1424
    MSG_ERR(0x1AD8, "SDO error : Communication yet established. with node : ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1425
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1426
  }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1427
  /* Taking the line ... */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1428
  err = getSDOfreeLine( d, SDO_CLIENT, &line );
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1429
  if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1430
    MSG_ERR(0x1AD9, "SDO error : No line free, too many SDO in progress. Aborted for node : ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1431
    return (0xFF);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1432
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1433
  else
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1434
    MSG_WAR(0x3AE0, "Transmission on line : ", line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1435
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1436
  /* Check which SDO to use to communicate with the node */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1437
  offset = d->firstIndex->SDO_CLT;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1438
  lastIndex = d->lastIndex->SDO_CLT;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1439
  if (offset == 0) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1440
    MSG_ERR(0x1AE1, "writeNetworkDict : No SDO client index found", 0); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1441
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1442
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1443
  i = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1444
  while (offset <= lastIndex) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1445
     if (d->objdict[offset].bSubCount <= 3) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1446
	 MSG_ERR(0x1AE2, "Subindex 3  not found at index ", 0x1280 + i);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1447
	 return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1448
     }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1449
     /* looking for the nodeId server */
311
adf4a929cf8b Bug on type inconsistency in SDO Client fixed
lbessard
parents: 306
diff changeset
  1450
     pNodeIdServer = (UNS8*) d->objdict[offset].pSubindex[3].pObject;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1451
     nodeIdServer = *pNodeIdServer;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1452
   
311
adf4a929cf8b Bug on type inconsistency in SDO Client fixed
lbessard
parents: 306
diff changeset
  1453
    if(nodeIdServer == nodeId) {
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1454
      SDOfound = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1455
      break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1456
    }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1457
    offset++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1458
    i++;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1459
  } /* end while */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1460
  if (!SDOfound) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1461
    MSG_ERR(0x1AE3, "SDO. Error. No client found to communicate with node : ", nodeId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1462
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1463
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1464
  MSG_WAR(0x3AE4,"        SDO client defined at index  : ", 0x1280 + i);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1465
  initSDOline(d, line, nodeId, index, subIndex, SDO_UPLOAD_IN_PROGRESS);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1466
  getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1467
  sdo.nodeId = nodeId;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1468
  /* Send the SDO to the server. Initiate upload, cs=2. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1469
  d->transfers[line].dataType = dataType;				
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1470
  sdo.body.data[0] = (2 << 5);	
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1471
  sdo.body.data[1] = index & 0xFF;        /* LSB */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1472
  sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1473
  sdo.body.data[3] = subIndex;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1474
  for (i = 4 ; i < 8 ; i++)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1475
    sdo.body.data[i] = 0;
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
  1476
  d->transfers[line].Callback = Callback;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1477
  err = sendSDO(d, SDO_CLIENT, sdo);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1478
  if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1479
    MSG_ERR(0x1AE5, "SDO. Error while sending SDO to node : ", nodeId);
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
  1480
    /* release the line */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1481
    resetSDOline(d, line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1482
    return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1483
  }		
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1484
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1485
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1486
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1487
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1488
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1489
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1490
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1491
** @param nodeId                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1492
** @param index                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1493
** @param subIndex                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1494
** @param dataType                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1495
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1496
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1497
**/   
32
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1498
UNS8 readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType)
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1499
{
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1500
	return _readNetworkDict (d, nodeId, index, subIndex, dataType, NULL);
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1501
}
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1502
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1503
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1504
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1505
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1506
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1507
** @param nodeId                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1508
** @param index                                                                                    
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1509
** @param subIndex                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1510
** @param dataType                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1511
** @param Callback                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1512
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1513
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1514
**/ 
32
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1515
UNS8 readNetworkDictCallback (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback)
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1516
{
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1517
	return _readNetworkDict (d, nodeId, index, subIndex, dataType, Callback);
8afa33692372 SDO callbacks.
etisserant
parents: 31
diff changeset
  1518
}
53
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
  1519
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1520
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1521
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1522
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1523
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1524
** @param nodeId                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1525
** @param data                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1526
** @param size                                                                                     
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1527
** @param abortCode                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1528
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1529
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1530
**/   
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1531
UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, UNS8 *size, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1532
			       UNS32 * abortCode)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1533
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1534
  UNS8 i;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1535
  UNS8 err;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1536
  UNS8 line;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1537
  * size = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1538
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1539
  /* Looking for the line tranfert. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1540
  err = getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1541
  if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1542
    MSG_ERR(0x1AF0, "SDO error : No line found for communication with node : ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1543
    return SDO_ABORTED_INTERNAL;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1544
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1545
  if (d->transfers[line].state != SDO_FINISHED)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1546
    return d->transfers[line].state;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1547
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1548
  /* Transfert is finished. Put the value in the data. */
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents: 87
diff changeset
  1549
  * size = (UNS8)d->transfers[line].count;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1550
  for  ( i = 0 ; i < *size ; i++) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1551
# ifdef CANOPEN_BIG_ENDIAN
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1552
    if (d->transfers[line].dataType != visible_string)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1553
      ( (char *) data)[*size - 1 - i] = d->transfers[line].data[i];
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1554
    else /* String of bytes. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1555
      ( (char *) data)[i] = d->transfers[line].data[i];
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1556
# else 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1557
    ( (char *) data)[i] = d->transfers[line].data[i];
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1558
# endif
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1559
  } 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1560
  return SDO_FINISHED;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1561
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1562
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1563
/*!                                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1564
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1565
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1566
** @param d                                                                                        
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1567
** @param nodeId                                                                                   
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1568
** @param abortCode                                                                                
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1569
**                                                                                                 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1570
** @return                                                                                         
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 174
diff changeset
  1571
**/  
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1572
UNS8 getWriteResultNetworkDict (CO_Data* d, UNS8 nodeId, UNS32 * abortCode)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1573
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1574
  UNS8 line = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1575
  UNS8 err;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1576
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1577
  * abortCode = 0;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
  1578
  /* Looking for the line tranfert. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1579
  err = getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1580
  if (err) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1581
    MSG_ERR(0x1AF1, "SDO error : No line found for communication with node : ", nodeId); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1582
    return SDO_ABORTED_INTERNAL;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1583
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1584
  * abortCode = d->transfers[line].abortCode;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1585
  return d->transfers[line].state;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1586
}