author | lbessard |
Tue, 05 Jun 2007 17:34:33 +0200 | |
changeset 209 | 2cb34a4ac65a |
parent 208 | 05d95c45b388 |
child 210 | 6b5a4c21e061 |
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 |
||
208 | 25 |
/** |
207 | 26 |
** @file dcf.c |
27 |
** @author Edouard TISSERANT and Francis DUPIN |
|
28 |
** @date Mon Jun 4 17:06:12 2007 |
|
29 |
** |
|
208 | 30 |
** @brief EXEMPLE OF SOMMARY |
207 | 31 |
** |
32 |
** |
|
33 |
*/ |
|
178 | 34 |
#include "objacces.h" |
35 |
#include "sdo.h" |
|
36 |
#include "dcf.h" |
|
200 | 37 |
#include "sysdep.h" |
178 | 38 |
|
204
44ce74232ccb
Some fixes for visual studio C compiler compatiblity.
etisserant
parents:
202
diff
changeset
|
39 |
|
208 | 40 |
/** |
41 |
** |
|
42 |
** |
|
43 |
** @param d fuck fuck fuck |
|
44 |
** @param nodeId |
|
45 |
** @param index |
|
46 |
** @param subIndex |
|
47 |
** @param count |
|
48 |
** @param dataType |
|
49 |
** @param data |
|
50 |
** @param Callback |
|
51 |
** @param endianize |
|
52 |
*/ |
|
207 | 53 |
extern UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, |
54 |
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
|
55 |
|
178 | 56 |
const indextable *ptrTable; |
57 |
||
208 | 58 |
/** |
207 | 59 |
** |
60 |
** |
|
61 |
** @param d |
|
62 |
** @param nodeId |
|
208 | 63 |
*/ |
178 | 64 |
static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId) |
65 |
{ |
|
207 | 66 |
UNS32 abortCode; |
191 | 67 |
|
207 | 68 |
if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED) |
69 |
{ |
|
70 |
MSG_ERR(0x1A01, "SDO error in consise DCF", abortCode); |
|
71 |
MSG_WAR(0x2A02, "server node : ", nodeId); |
|
72 |
} |
|
73 |
||
74 |
closeSDOtransfer(d, nodeId, SDO_CLIENT); |
|
75 |
decompo_dcf(d,nodeId); |
|
178 | 76 |
} |
77 |
||
208 | 78 |
/** |
207 | 79 |
** |
80 |
** |
|
81 |
** @param d |
|
82 |
** @param nodeId |
|
83 |
** |
|
84 |
** @return |
|
208 | 85 |
*/ |
178 | 86 |
UNS32 decompo_dcf(CO_Data* d,UNS8 nodeId) |
87 |
{ |
|
207 | 88 |
UNS32 errorCode; |
89 |
UNS16 target_Index; |
|
90 |
UNS8 target_Subindex; |
|
91 |
UNS32 target_Size; |
|
92 |
UNS32 res; |
|
93 |
ODCallback_t *Callback; |
|
178 | 94 |
|
207 | 95 |
ptrTable = (*d->scanIndexOD)(0x1F22, &errorCode, &Callback); |
96 |
if (errorCode != OD_SUCCESSFUL) |
|
97 |
{ |
|
98 |
return errorCode; |
|
99 |
} |
|
178 | 100 |
|
208 | 101 |
/** Loop on all Nodes supported in DCF subindexes*/ |
207 | 102 |
while (nodeId < ptrTable->bSubCount){ |
103 |
UNS32 nb_targets; |
|
104 |
||
105 |
UNS8 szData = ptrTable->pSubindex[nodeId].size; |
|
106 |
UNS8* dcfend; |
|
107 |
||
108 |
{ |
|
109 |
UNS8* dcf = *((UNS8**)ptrTable->pSubindex[nodeId].pObject); |
|
110 |
dcfend = dcf + szData; |
|
111 |
if (!d->dcf_cursor){ |
|
112 |
d->dcf_cursor = (UNS8*)dcf + 4; |
|
113 |
d->dcf_count_targets = 0; |
|
114 |
} |
|
115 |
nb_targets = UNS32_LE(*((UNS32*)dcf)); |
|
116 |
} |
|
117 |
||
208 | 118 |
/** condition on consise DCF string for NodeID, if big enough */ |
207 | 119 |
if((UNS8*)d->dcf_cursor + 7 < (UNS8*)dcfend && d->dcf_count_targets < nb_targets) |
120 |
{ |
|
208 | 121 |
/** pointer to the DCF string for NodeID */ |
207 | 122 |
target_Index = UNS16_LE(*((UNS16*)(d->dcf_cursor))); d->dcf_cursor += 2; |
123 |
target_Subindex = *((UNS8*)(((UNS8*)d->dcf_cursor)++)); |
|
124 |
target_Size = UNS32_LE(*((UNS32*)(d->dcf_cursor))); d->dcf_cursor += 4; |
|
125 |
||
208 | 126 |
/* printf("Master : ConfigureSlaveNode %2.2x (Concise |
207 | 127 |
DCF)\n",nodeId);*/ |
208 | 128 |
res = _writeNetworkDict(d, /** CO_Data* d*/ |
129 |
nodeId, /** UNS8 nodeId*/ |
|
130 |
target_Index, /** UNS16 index*/ |
|
131 |
target_Subindex, /** UNS8 subindex*/ |
|
132 |
target_Size, /** UNS8 count*/ |
|
133 |
0, /** UNS8 dataType*/ |
|
134 |
d->dcf_cursor,/** void *data*/ |
|
135 |
CheckSDOAndContinue,/** SDOCallback_t |
|
207 | 136 |
Callback*/ |
208 | 137 |
0); /** no endianize*/ |
138 |
/** Push d->dcf_cursor to the end of data*/ |
|
207 | 139 |
|
140 |
d->dcf_cursor += target_Size; |
|
141 |
d->dcf_count_targets++; |
|
142 |
||
143 |
return ; |
|
144 |
} |
|
145 |
nodeId++; |
|
146 |
d->dcf_cursor = NULL; |
|
147 |
} |
|
208 | 148 |
/** Switch Master to preOperational state */ |
207 | 149 |
(*d->preOperational)(); |
150 |
||
178 | 151 |
} |