/home/epimerde/documents/tc11/CanFestival-3/src/dcf.c

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

Generated on Mon Jun 4 17:09:26 2007 for CanFestival by  doxygen 1.5.1