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