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