src/dcf.c
changeset 208 05d95c45b388
parent 207 b6572d0336c3
child 210 6b5a4c21e061
equal deleted inserted replaced
207:b6572d0336c3 208:05d95c45b388
    20   License along with this library; if not, write to the Free Software
    20   License along with this library; if not, write to the Free Software
    21   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
    21   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
    22   USA
    22   USA
    23 */
    23 */
    24 
    24 
    25 /*!
    25 /**
    26 ** @file   dcf.c
    26 ** @file   dcf.c
    27 ** @author Edouard TISSERANT and Francis DUPIN
    27 ** @author Edouard TISSERANT and Francis DUPIN
    28 ** @date   Mon Jun  4 17:06:12 2007
    28 ** @date   Mon Jun  4 17:06:12 2007
    29 **
    29 **
    30 ** @brief
    30 ** @brief EXEMPLE OF SOMMARY
    31 **
    31 **
    32 **
    32 **
    33 */
    33 */
    34 #include "objacces.h"
    34 #include "objacces.h"
    35 #include "sdo.h"
    35 #include "sdo.h"
    36 #include "dcf.h"
    36 #include "dcf.h"
    37 #include "sysdep.h"
    37 #include "sysdep.h"
    38 
    38 
    39 
    39 
    40 
    40 /**
       
    41 **
       
    42 **
       
    43 ** @param d fuck fuck fuck
       
    44 ** @param nodeId
       
    45 ** @param index
       
    46 ** @param subIndex
       
    47 ** @param count
       
    48 ** @param dataType
       
    49 ** @param data
       
    50 ** @param Callback
       
    51 ** @param endianize
       
    52 */
    41 extern UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
    53 extern UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
    42                                UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize);
    54                                UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize);
    43 
    55 
    44 const indextable *ptrTable;
    56 const indextable *ptrTable;
    45 
    57 
    46 /*!
    58 /**
    47 **
    59 **
    48 **
    60 **
    49 ** @param d
    61 ** @param d
    50 ** @param nodeId
    62 ** @param nodeId
    51 **/
    63 */
    52 static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId)
    64 static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId)
    53 {
    65 {
    54   UNS32 abortCode;
    66   UNS32 abortCode;
    55 
    67 
    56   if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
    68   if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
    61 
    73 
    62   closeSDOtransfer(d, nodeId, SDO_CLIENT);
    74   closeSDOtransfer(d, nodeId, SDO_CLIENT);
    63   decompo_dcf(d,nodeId);
    75   decompo_dcf(d,nodeId);
    64 }
    76 }
    65 
    77 
    66 /*!
    78 /**
    67 **
    79 **
    68 **
    80 **
    69 ** @param d
    81 ** @param d
    70 ** @param nodeId
    82 ** @param nodeId
    71 **
    83 **
    72 ** @return
    84 ** @return
    73 **/
    85 */
    74 UNS32 decompo_dcf(CO_Data* d,UNS8 nodeId)
    86 UNS32 decompo_dcf(CO_Data* d,UNS8 nodeId)
    75 {
    87 {
    76   UNS32 errorCode;
    88   UNS32 errorCode;
    77   UNS16 target_Index;
    89   UNS16 target_Index;
    78   UNS8 target_Subindex;
    90   UNS8 target_Subindex;
    84   if (errorCode != OD_SUCCESSFUL)
    96   if (errorCode != OD_SUCCESSFUL)
    85     {
    97     {
    86       return errorCode;
    98       return errorCode;
    87     }
    99     }
    88 
   100 
    89   /*Loop on all Nodes supported in DCF subindexes*/
   101   /** Loop on all Nodes supported in DCF subindexes*/
    90   while (nodeId < ptrTable->bSubCount){
   102   while (nodeId < ptrTable->bSubCount){
    91     UNS32 nb_targets;
   103     UNS32 nb_targets;
    92 
   104 
    93     UNS8 szData = ptrTable->pSubindex[nodeId].size;
   105     UNS8 szData = ptrTable->pSubindex[nodeId].size;
    94     UNS8* dcfend;
   106     UNS8* dcfend;
   101         d->dcf_count_targets = 0;
   113         d->dcf_count_targets = 0;
   102       }
   114       }
   103       nb_targets = UNS32_LE(*((UNS32*)dcf));
   115       nb_targets = UNS32_LE(*((UNS32*)dcf));
   104     }
   116     }
   105 
   117 
   106     // condition on consise DCF string for NodeID, if big enough
   118     /** condition on consise DCF string for NodeID, if big enough */
   107     if((UNS8*)d->dcf_cursor + 7 < (UNS8*)dcfend && d->dcf_count_targets < nb_targets)
   119     if((UNS8*)d->dcf_cursor + 7 < (UNS8*)dcfend && d->dcf_count_targets < nb_targets)
   108       {
   120       {
   109         // pointer to the DCF string for NodeID
   121         /** pointer to the DCF string for NodeID */
   110         target_Index = UNS16_LE(*((UNS16*)(d->dcf_cursor))); d->dcf_cursor += 2;
   122         target_Index = UNS16_LE(*((UNS16*)(d->dcf_cursor))); d->dcf_cursor += 2;
   111         target_Subindex = *((UNS8*)(((UNS8*)d->dcf_cursor)++));
   123         target_Subindex = *((UNS8*)(((UNS8*)d->dcf_cursor)++));
   112         target_Size = UNS32_LE(*((UNS32*)(d->dcf_cursor))); d->dcf_cursor += 4;
   124         target_Size = UNS32_LE(*((UNS32*)(d->dcf_cursor))); d->dcf_cursor += 4;
   113 
   125 
   114         /*printf("Master : ConfigureSlaveNode %2.2x (Concise
   126         /* printf("Master : ConfigureSlaveNode %2.2x (Concise
   115           DCF)\n",nodeId);*/
   127           DCF)\n",nodeId);*/
   116         res = _writeNetworkDict(d, /*CO_Data* d*/
   128         res = _writeNetworkDict(d, /** CO_Data* d*/
   117                                 nodeId, /*UNS8 nodeId*/
   129                                 nodeId, /** UNS8 nodeId*/
   118                                 target_Index, /*UNS16 index*/
   130                                 target_Index, /** UNS16 index*/
   119                                 target_Subindex, /*UNS8 subindex*/
   131                                 target_Subindex, /** UNS8 subindex*/
   120                                 target_Size, /*UNS8 count*/
   132                                 target_Size, /** UNS8 count*/
   121                                 0, /*UNS8 dataType*/
   133                                 0, /** UNS8 dataType*/
   122                                 d->dcf_cursor,/*void *data*/
   134                                 d->dcf_cursor,/** void *data*/
   123                                 CheckSDOAndContinue,/*SDOCallback_t
   135                                 CheckSDOAndContinue,/** SDOCallback_t
   124                                                       Callback*/
   136                                                       Callback*/
   125                                 0); /* no endianize*/
   137                                 0); /** no endianize*/
   126         /*Push d->dcf_cursor to the end of data*/
   138         /** Push d->dcf_cursor to the end of data*/
   127 
   139 
   128         d->dcf_cursor += target_Size;
   140         d->dcf_cursor += target_Size;
   129         d->dcf_count_targets++;
   141         d->dcf_count_targets++;
   130 
   142 
   131         return ;
   143         return ;
   132       }
   144       }
   133     nodeId++;
   145     nodeId++;
   134     d->dcf_cursor = NULL;
   146     d->dcf_cursor = NULL;
   135   }
   147   }
   136   /* Switch Master to preOperational state */
   148   /**  Switch Master to preOperational state */
   137   (*d->preOperational)();
   149   (*d->preOperational)();
   138 
   150 
   139 }
   151 }