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