etisserant@0: /* etisserant@0: This file is part of CanFestival, a library implementing CanOpen Stack. etisserant@0: etisserant@0: Copyright (C): Edouard TISSERANT and Francis DUPIN etisserant@0: etisserant@0: See COPYING file for copyrights details. etisserant@0: etisserant@0: This library is free software; you can redistribute it and/or etisserant@0: modify it under the terms of the GNU Lesser General Public etisserant@0: License as published by the Free Software Foundation; either etisserant@0: version 2.1 of the License, or (at your option) any later version. etisserant@0: etisserant@0: This library is distributed in the hope that it will be useful, etisserant@0: but WITHOUT ANY WARRANTY; without even the implied warranty of etisserant@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU etisserant@0: Lesser General Public License for more details. etisserant@0: etisserant@0: You should have received a copy of the GNU Lesser General Public etisserant@0: License along with this library; if not, write to the Free Software etisserant@0: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA etisserant@0: */ etisserant@0: etisserant@0: /** \file etisserant@0: * \brief Responsible for accessing the object dictionary. etisserant@0: * etisserant@0: * This file contains functions for accessing the object dictionary and etisserant@0: * variables that are contained by the object dictionary. etisserant@0: * Accessing the object dictionary contains setting local variables etisserant@0: * as PDOs and accessing (read/write) all entries of the object dictionary etisserant@0: * \warning Only the basic entries of an object dictionary are included etisserant@0: * at the moment. etisserant@0: */ etisserant@0: etisserant@0: #ifndef __objacces_h__ etisserant@0: #define __objacces_h__ etisserant@0: etisserant@0: #include etisserant@0: etisserant@0: typedef UNS32 (*valueRangeTest_t)(UNS8 typeValue, void *Value); etisserant@0: etisserant@0: #include "data.h" etisserant@0: etisserant@0: etisserant@0: frdupin@71: /* etisserant@0: Print MSG_WAR (s) if error to the access to the object dictionary occurs. frdupin@71: You must uncomment the lines etisserant@0: //#define DEBUG_CAN etisserant@0: //#define DEBUG_WAR_CONSOLE_ON etisserant@0: //#define DEBUG_ERR_CONSOLE_ON frdupin@71: in the file objaccess.c etisserant@0: sizeDataDict : Size of the data defined in the dictionary etisserant@0: sizeDataGiven : Size data given by the user. etisserant@0: code : error code to print. (SDO abort code. See file def.h) etisserant@0: Beware that sometimes, we force the sizeDataDict or sizeDataGiven to 0, when we wants to use etisserant@0: this function but we do not have the access to the right value. One example is etisserant@0: getSDOerror(). So do not take attention to these variables if they are null. etisserant@0: */ frdupin@75: etisserant@0: UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex, etisserant@0: UNS8 sizeDataDict, UNS8 sizeDataGiven, UNS32 code); frdupin@75: etisserant@0: frdupin@71: /* Reads an entry from the object dictionary.\n etisserant@0: * \code etisserant@0: * // Example usage: etisserant@0: * UNS8 *pbData; etisserant@0: * UNS8 length; etisserant@0: * UNS32 returnValue; etisserant@0: * etisserant@0: * returnValue = getODentry( (UNS16)0x100B, (UNS8)1, etisserant@0: * (void * *)&pbData, (UNS8 *)&length ); etisserant@0: * if( returnValue != SUCCESSFUL ) etisserant@0: * { etisserant@0: * // error handling etisserant@0: * } etisserant@0: * \endcode etisserant@0: * \param wIndex The index in the object dictionary where you want to read etisserant@0: * an entry etisserant@0: * \param bSubindex The subindex of the Index. e.g. mostly subindex 0 is etisserant@0: * used to tell you how many valid entries you can find etisserant@0: * in this index. Look at the canopen standard for further etisserant@0: * information etisserant@0: * \param ppbData Pointer to the pointer which points to the variable where etisserant@0: * the value of this object dictionary entry should be copied etisserant@0: * \param pdwSize This function writes the size of the copied value (in Byte) etisserant@0: * into this variable. etisserant@0: * \param pDataType : The type of the data. See objdictdef.h etisserant@0: * \param CheckAccess if other than 0, do not read if the data is Write Only etisserant@0: * [Not used today. Put always 0]. etisserant@0: * \return OD_SUCCESSFUL or SDO abort code. (See file def.h) etisserant@0: */ etisserant@0: UNS32 getODentry( CO_Data* d, etisserant@0: UNS16 wIndex, etisserant@0: UNS8 bSubindex, etisserant@0: void * pDestData, etisserant@0: UNS8 * pExpectedSize, etisserant@0: UNS8 * pDataType, etisserant@0: UNS8 checkAccess); etisserant@0: etisserant@0: frdupin@71: /* By this function you can write an entry into the object dictionary\n etisserant@0: * \code etisserant@0: * // Example usage: etisserant@0: * UNS8 B; etisserant@0: * B = 0xFF; // set transmission type etisserant@0: * etisserant@0: * retcode = setODentry( (UNS16)0x1800, (UNS8)2, &B, sizeof(UNS8), 1 ); etisserant@0: * \endocde etisserant@0: * \param wIndex The index in the object dictionary where you want to write etisserant@0: * an entry etisserant@0: * \param bSubindex The subindex of the Index. e.g. mostly subindex 0 is etisserant@0: * used to tell you how many valid entries you can find etisserant@0: * in this index. Look at the canopen standard for further etisserant@0: * information etisserant@0: * \param pbData Pointer to the variable that holds the value that should etisserant@0: * be copied into the object dictionary etisserant@0: * \param dwSize The size of the value (in Byte). etisserant@0: * \param CheckAccess if other than 0, do not read if the data is Read Only or Constant etisserant@0: * \return OD_SUCCESSFUL or SDO abort code. (See file def.h) etisserant@0: */ etisserant@0: UNS32 setODentry( CO_Data* d, etisserant@0: UNS16 wIndex, etisserant@0: UNS8 bSubindex, etisserant@0: void * pSourceData, etisserant@0: UNS8 * pExpectedSize, etisserant@0: UNS8 checkAccess); etisserant@0: etisserant@0: frdupin@71: /* Scan the index of object dictionary. Used only by setODentry and getODentry. etisserant@0: * *errorCode : OD_SUCCESSFUL if index foundor SDO abort code. (See file def.h) etisserant@0: * Return NULL if index not found. Else : return the table part of the object dictionary. etisserant@0: */ etisserant@0: const indextable * scanIndexOD (CO_Data* d, UNS16 wIndex, UNS32 *errorCode, ODCallback_t **Callback); etisserant@0: etisserant@0: UNS32 RegisterSetODentryCallBack(CO_Data* d, UNS16 wIndex, UNS8 bSubindex, ODCallback_t Callback); etisserant@0: frdupin@71: #endif /* __objacces_h__ */