nico@207: nico@207:
nico@215:00001 /* nico@210: 00002 This file is part of CanFestival, a library implementing CanOpen nico@210: 00003 Stack. nico@210: 00004 nico@210: 00005 Copyright (C): Edouard TISSERANT and Francis DUPIN nico@210: 00006 nico@210: 00007 See COPYING file for copyrights details. nico@210: 00008 nico@210: 00009 This library is free software; you can redistribute it and/or nico@210: 00010 modify it under the terms of the GNU Lesser General Public nico@210: 00011 License as published by the Free Software Foundation; either nico@210: 00012 version 2.1 of the License, or (at your option) any later version. nico@210: 00013 nico@210: 00014 This library is distributed in the hope that it will be useful, nico@210: 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of nico@210: 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU nico@210: 00017 Lesser General Public License for more details. nico@210: 00018 nico@210: 00019 You should have received a copy of the GNU Lesser General Public nico@210: 00020 License along with this library; if not, write to the Free Software nico@210: 00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 nico@210: 00022 USA nico@210: 00023 */ nico@210: 00024 nico@210: 00025 nico@215: 00037 #include "objacces.h" nico@215: 00038 #include "sdo.h" nico@215: 00039 #include "dcf.h" nico@215: 00040 #include "sysdep.h" nico@215: 00041 etisserant@240: 00042 extern UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, etisserant@240: 00043 UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize); nico@215: 00044 etisserant@240: 00045 const indextable *ptrTable; nico@215: 00046 etisserant@240: 00053 static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId) nico@215: 00054 { etisserant@240: 00055 UNS32 abortCode; nico@210: 00056 etisserant@240: 00057 if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED) nico@215: 00058 { etisserant@240: 00059 MSG_ERR(0x1A01, "SDO error in consise DCF", abortCode); etisserant@240: 00060 MSG_WAR(0x2A02, "server node : ", nodeId); nico@215: 00061 } nico@215: 00062 etisserant@240: 00063 closeSDOtransfer(d, nodeId, SDO_CLIENT); etisserant@240: 00064 decompo_dcf(d,nodeId); nico@215: 00065 } nico@215: 00066 etisserant@240: 00075 UNS32 decompo_dcf(CO_Data* d,UNS8 nodeId) nico@215: 00076 { etisserant@240: 00077 UNS32 errorCode; etisserant@240: 00078 UNS16 target_Index; etisserant@240: 00079 UNS8 target_Subindex; etisserant@240: 00080 UNS32 target_Size; etisserant@240: 00081 UNS32 res; etisserant@240: 00082 ODCallback_t *Callback; nico@215: 00083 etisserant@240: 00084 ptrTable = (*d->scanIndexOD)(0x1F22, &errorCode, &Callback); etisserant@240: 00085 if (errorCode != OD_SUCCESSFUL) nico@215: 00086 { nico@215: 00087 return errorCode; nico@215: 00088 } nico@215: 00089 nico@215: 00090 /* Loop on all Nodes supported in DCF subindexes*/ nico@215: 00091 while (nodeId < ptrTable->bSubCount){ etisserant@240: 00092 UNS32 nb_targets; nico@215: 00093 etisserant@240: 00094 UNS8 szData = ptrTable->pSubindex[nodeId].size; etisserant@240: 00095 UNS8* dcfend; nico@215: 00096 nico@215: 00097 { etisserant@240: 00098 UNS8* dcf = *((UNS8**)ptrTable->pSubindex[nodeId].pObject); nico@215: 00099 dcfend = dcf + szData; etisserant@240: 00100 if (!d->dcf_cursor){ etisserant@240: 00101 d->dcf_cursor = (UNS8*)dcf + 4; etisserant@240: 00102 d->dcf_count_targets = 0; nico@215: 00103 } etisserant@240: 00104 nb_targets = UNS32_LE(*((UNS32*)dcf)); nico@215: 00105 } nico@215: 00106 nico@215: 00107 /* condition on consise DCF string for NodeID, if big enough */ etisserant@240: 00108 if((UNS8*)d->dcf_cursor + 7 < (UNS8*)dcfend && d->dcf_count_targets < nb_targets) nico@215: 00109 { nico@215: 00110 /* pointer to the DCF string for NodeID */ etisserant@240: 00111 target_Index = UNS16_LE(*((UNS16*)(d->dcf_cursor))); d->dcf_cursor += 2; etisserant@240: 00112 target_Subindex = *((UNS8*)(((UNS8*)d->dcf_cursor)++)); etisserant@240: 00113 target_Size = UNS32_LE(*((UNS32*)(d->dcf_cursor))); d->dcf_cursor += 4; nico@215: 00114 nico@215: 00115 /* printf("Master : ConfigureSlaveNode %2.2x (Concise nico@215: 00116 DCF)\n",nodeId);*/ etisserant@240: 00117 res = _writeNetworkDict(d, /* CO_Data* d*/ nico@215: 00118 nodeId, /* UNS8 nodeId*/ nico@215: 00119 target_Index, /* UNS16 index*/ nico@215: 00120 target_Subindex, /* UNS8 subindex*/ nico@215: 00121 target_Size, /* UNS8 count*/ nico@215: 00122 0, /* UNS8 dataType*/ etisserant@240: 00123 d->dcf_cursor,/* void *data*/ nico@215: 00124 CheckSDOAndContinue,/* SDOCallback_t nico@215: 00125 Callback*/ nico@215: 00126 0); /* no endianize*/ nico@215: 00127 /* Push d->dcf_cursor to the end of data*/ nico@215: 00128 etisserant@240: 00129 d->dcf_cursor += target_Size; etisserant@240: 00130 d->dcf_count_targets++; nico@215: 00131 nico@215: 00132 return ; nico@215: 00133 } nico@215: 00134 nodeId++; etisserant@240: 00135 d->dcf_cursor = NULL; nico@215: 00136 } nico@215: 00137 /* Switch Master to preOperational state */ etisserant@240: 00138 (*d->preOperational)(); nico@215: 00139 nico@215: 00140 } etisserant@240: