author | etisserant |
Fri, 08 Jun 2007 09:02:43 +0200 | |
changeset 214 | 003cc3c63855 |
parent 212 | 945b5eacc733 |
child 215 | f49e5a6b7804 |
permissions | -rw-r--r-- |
178 | 1 |
/* |
207 | 2 |
This file is part of CanFestival, a library implementing CanOpen |
3 |
Stack. |
|
178 | 4 |
|
207 | 5 |
Copyright (C): Edouard TISSERANT and Francis DUPIN |
178 | 6 |
|
207 | 7 |
See COPYING file for copyrights details. |
178 | 8 |
|
207 | 9 |
This library is free software; you can redistribute it and/or |
10 |
modify it under the terms of the GNU Lesser General Public |
|
11 |
License as published by the Free Software Foundation; either |
|
12 |
version 2.1 of the License, or (at your option) any later version. |
|
178 | 13 |
|
207 | 14 |
This library is distributed in the hope that it will be useful, |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
17 |
Lesser General Public License for more details. |
|
178 | 18 |
|
207 | 19 |
You should have received a copy of the GNU Lesser General Public |
20 |
License along with this library; if not, write to the Free Software |
|
21 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|
22 |
USA |
|
178 | 23 |
*/ |
24 |
||
210 | 25 |
|
208 | 26 |
/** |
207 | 27 |
** @file dcf.c |
28 |
** @author Edouard TISSERANT and Francis DUPIN |
|
29 |
** @date Mon Jun 4 17:06:12 2007 |
|
30 |
** |
|
208 | 31 |
** @brief EXEMPLE OF SOMMARY |
207 | 32 |
** |
33 |
** |
|
34 |
*/ |
|
178 | 35 |
#include "objacces.h" |
36 |
#include "sdo.h" |
|
37 |
#include "dcf.h" |
|
200 | 38 |
#include "sysdep.h" |
178 | 39 |
|
207 | 40 |
extern UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, |
41 |
UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize); |
|
204
44ce74232ccb
Some fixes for visual studio C compiler compatiblity.
etisserant
parents:
202
diff
changeset
|
42 |
|
178 | 43 |
const indextable *ptrTable; |
44 |
||
208 | 45 |
/** |
207 | 46 |
** |
47 |
** |
|
48 |
** @param d |
|
49 |
** @param nodeId |
|
208 | 50 |
*/ |
178 | 51 |
static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId) |
52 |
{ |
|
207 | 53 |
UNS32 abortCode; |
191 | 54 |
|
207 | 55 |
if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED) |
56 |
{ |
|
57 |
MSG_ERR(0x1A01, "SDO error in consise DCF", abortCode); |
|
58 |
MSG_WAR(0x2A02, "server node : ", nodeId); |
|
59 |
} |
|
60 |
||
61 |
closeSDOtransfer(d, nodeId, SDO_CLIENT); |
|
62 |
decompo_dcf(d,nodeId); |
|
178 | 63 |
} |
64 |
||
208 | 65 |
/** |
207 | 66 |
** |
67 |
** |
|
68 |
** @param d |
|
69 |
** @param nodeId |
|
70 |
** |
|
71 |
** @return |
|
208 | 72 |
*/ |
178 | 73 |
UNS32 decompo_dcf(CO_Data* d,UNS8 nodeId) |
74 |
{ |
|
207 | 75 |
UNS32 errorCode; |
76 |
UNS16 target_Index; |
|
77 |
UNS8 target_Subindex; |
|
78 |
UNS32 target_Size; |
|
79 |
UNS32 res; |
|
80 |
ODCallback_t *Callback; |
|
178 | 81 |
|
207 | 82 |
ptrTable = (*d->scanIndexOD)(0x1F22, &errorCode, &Callback); |
83 |
if (errorCode != OD_SUCCESSFUL) |
|
84 |
{ |
|
85 |
return errorCode; |
|
86 |
} |
|
178 | 87 |
|
208 | 88 |
/** Loop on all Nodes supported in DCF subindexes*/ |
207 | 89 |
while (nodeId < ptrTable->bSubCount){ |
90 |
UNS32 nb_targets; |
|
91 |
||
92 |
UNS8 szData = ptrTable->pSubindex[nodeId].size; |
|
93 |
UNS8* dcfend; |
|
94 |
||
95 |
{ |
|
96 |
UNS8* dcf = *((UNS8**)ptrTable->pSubindex[nodeId].pObject); |
|
97 |
dcfend = dcf + szData; |
|
98 |
if (!d->dcf_cursor){ |
|
99 |
d->dcf_cursor = (UNS8*)dcf + 4; |
|
100 |
d->dcf_count_targets = 0; |
|
101 |
} |
|
102 |
nb_targets = UNS32_LE(*((UNS32*)dcf)); |
|
103 |
} |
|
104 |
||
208 | 105 |
/** condition on consise DCF string for NodeID, if big enough */ |
207 | 106 |
if((UNS8*)d->dcf_cursor + 7 < (UNS8*)dcfend && d->dcf_count_targets < nb_targets) |
107 |
{ |
|
208 | 108 |
/** pointer to the DCF string for NodeID */ |
207 | 109 |
target_Index = UNS16_LE(*((UNS16*)(d->dcf_cursor))); d->dcf_cursor += 2; |
110 |
target_Subindex = *((UNS8*)(((UNS8*)d->dcf_cursor)++)); |
|
111 |
target_Size = UNS32_LE(*((UNS32*)(d->dcf_cursor))); d->dcf_cursor += 4; |
|
112 |
||
208 | 113 |
/* printf("Master : ConfigureSlaveNode %2.2x (Concise |
207 | 114 |
DCF)\n",nodeId);*/ |
208 | 115 |
res = _writeNetworkDict(d, /** CO_Data* d*/ |
116 |
nodeId, /** UNS8 nodeId*/ |
|
117 |
target_Index, /** UNS16 index*/ |
|
118 |
target_Subindex, /** UNS8 subindex*/ |
|
119 |
target_Size, /** UNS8 count*/ |
|
120 |
0, /** UNS8 dataType*/ |
|
121 |
d->dcf_cursor,/** void *data*/ |
|
122 |
CheckSDOAndContinue,/** SDOCallback_t |
|
207 | 123 |
Callback*/ |
208 | 124 |
0); /** no endianize*/ |
125 |
/** Push d->dcf_cursor to the end of data*/ |
|
207 | 126 |
|
127 |
d->dcf_cursor += target_Size; |
|
128 |
d->dcf_count_targets++; |
|
129 |
||
130 |
return ; |
|
131 |
} |
|
132 |
nodeId++; |
|
133 |
d->dcf_cursor = NULL; |
|
134 |
} |
|
208 | 135 |
/** Switch Master to preOperational state */ |
207 | 136 |
(*d->preOperational)(); |
137 |
||
178 | 138 |
} |