nico@207: nico@207: nico@215: CanFestival: src/dcf.c Source File nico@207: nico@207: nico@207: nico@207: nico@207:
nico@207:
nico@207:
nico@207:
nico@215: nico@215:

dcf.c

Go to the documentation of this file.
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 
nico@215: 00042 extern UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
nico@215: 00043                                UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize);
nico@215: 00044 
nico@215: 00045 const indextable *ptrTable;
nico@215: 00046 
nico@215: 00053 static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId)
nico@215: 00054 {
nico@215: 00055   UNS32 abortCode;
nico@210: 00056 
nico@215: 00057   if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
nico@215: 00058     {
nico@215: 00059       MSG_ERR(0x1A01, "SDO error in consise DCF", abortCode);
nico@215: 00060       MSG_WAR(0x2A02, "server node : ", nodeId);
nico@215: 00061     }
nico@215: 00062 
nico@215: 00063   closeSDOtransfer(d, nodeId, SDO_CLIENT);
nico@215: 00064   decompo_dcf(d,nodeId);
nico@215: 00065 }
nico@215: 00066 
nico@215: 00075 UNS32 decompo_dcf(CO_Data* d,UNS8 nodeId)
nico@215: 00076 {
nico@215: 00077   UNS32 errorCode;
nico@215: 00078   UNS16 target_Index;
nico@215: 00079   UNS8 target_Subindex;
nico@215: 00080   UNS32 target_Size;
nico@215: 00081   UNS32 res;
nico@215: 00082   ODCallback_t *Callback;
nico@215: 00083 
nico@215: 00084   ptrTable = (*d->scanIndexOD)(0x1F22, &errorCode, &Callback);
nico@215: 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){
nico@215: 00092     UNS32 nb_targets;
nico@215: 00093 
nico@215: 00094     UNS8 szData = ptrTable->pSubindex[nodeId].size;
nico@215: 00095     UNS8* dcfend;
nico@215: 00096 
nico@215: 00097     {
nico@215: 00098       UNS8* dcf = *((UNS8**)ptrTable->pSubindex[nodeId].pObject);
nico@215: 00099       dcfend = dcf + szData;
nico@215: 00100       if (!d->dcf_cursor){
nico@215: 00101         d->dcf_cursor = (UNS8*)dcf + 4;
nico@215: 00102         d->dcf_count_targets = 0;
nico@215: 00103       }
nico@215: 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 */
nico@215: 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 */
nico@215: 00111         target_Index = UNS16_LE(*((UNS16*)(d->dcf_cursor))); d->dcf_cursor += 2;
nico@215: 00112         target_Subindex = *((UNS8*)(((UNS8*)d->dcf_cursor)++));
nico@215: 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);*/
nico@215: 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*/
nico@215: 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 
nico@215: 00129         d->dcf_cursor += target_Size;
nico@215: 00130         d->dcf_count_targets++;
nico@215: 00131 
nico@215: 00132         return ;
nico@215: 00133       }
nico@215: 00134     nodeId++;
nico@215: 00135     d->dcf_cursor = NULL;
nico@215: 00136   }
nico@215: 00137   /*  Switch Master to preOperational state */
nico@215: 00138   (*d->preOperational)();
nico@215: 00139 
nico@215: 00140 }
nico@215: 

Generated on Fri Jun 8 08:51:39 2007 for CanFestival by  nico@207: nico@207: doxygen 1.5.1
nico@207: nico@207: