nico@215: nico@215:
nico@215:00001 /* nico@215: 00002 This file is part of CanFestival, a library implementing CanOpen Stack. nico@215: 00003 nico@215: 00004 Copyright (C): Edouard TISSERANT and Francis DUPIN nico@215: 00005 nico@215: 00006 See COPYING file for copyrights details. nico@215: 00007 nico@215: 00008 This library is free software; you can redistribute it and/or nico@215: 00009 modify it under the terms of the GNU Lesser General Public nico@215: 00010 License as published by the Free Software Foundation; either nico@215: 00011 version 2.1 of the License, or (at your option) any later version. nico@215: 00012 nico@215: 00013 This library is distributed in the hope that it will be useful, nico@215: 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of nico@215: 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU nico@215: 00016 Lesser General Public License for more details. nico@215: 00017 nico@215: 00018 You should have received a copy of the GNU Lesser General Public nico@215: 00019 License along with this library; if not, write to the Free Software nico@215: 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA nico@215: 00021 */ nico@215: 00022 nico@215: 00034 #ifndef __objacces_h__ nico@215: 00035 #define __objacces_h__ nico@215: 00036 nico@215: 00037 #include <applicfg.h> nico@215: 00038 etisserant@240: 00039 typedef UNS32 (*valueRangeTest_t)(UNS8 typeValue, void *Value); etisserant@240: 00040 typedef void (* storeODSubIndex_t)(UNS16 wIndex, UNS8 bSubindex); etisserant@240: 00041 void _storeODSubIndex (UNS16 wIndex, UNS8 bSubindex); nico@215: 00042 nico@215: 00043 #include "data.h" nico@215: 00044 nico@215: 00045 nico@215: 00046 nico@215: 00047 /* nico@215: 00048 Print MSG_WAR (s) if error to the access to the object dictionary occurs. nico@215: 00049 You must uncomment the lines nico@215: 00050 //#define DEBUG_CAN nico@215: 00051 //#define DEBUG_WAR_CONSOLE_ON nico@215: 00052 //#define DEBUG_ERR_CONSOLE_ON nico@215: 00053 in the file objaccess.c nico@215: 00054 sizeDataDict : Size of the data defined in the dictionary nico@215: 00055 sizeDataGiven : Size data given by the user. nico@215: 00056 code : error code to print. (SDO abort code. See file def.h) nico@215: 00057 Beware that sometimes, we force the sizeDataDict or sizeDataGiven to 0, when we wants to use nico@215: 00058 this function but we do not have the access to the right value. One example is nico@215: 00059 getSDOerror(). So do not take attention to these variables if they are null. nico@215: 00060 */ nico@215: 00061 etisserant@240: 00062 UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex, etisserant@240: 00063 UNS8 sizeDataDict, UNS8 sizeDataGiven, UNS32 code); nico@215: 00064 nico@215: 00065 nico@215: 00066 /* Reads an entry from the object dictionary.\n nico@215: 00067 * \code nico@215: 00068 * // Example usage: nico@215: 00069 * UNS8 *pbData; nico@215: 00070 * UNS8 length; nico@215: 00071 * UNS32 returnValue; nico@215: 00072 * nico@215: 00073 * returnValue = getODentry( (UNS16)0x100B, (UNS8)1, nico@215: 00074 * (void * *)&pbData, (UNS8 *)&length ); nico@215: 00075 * if( returnValue != SUCCESSFUL ) nico@215: 00076 * { nico@215: 00077 * // error handling nico@215: 00078 * } nico@215: 00079 * \endcode nico@215: 00080 * \param wIndex The index in the object dictionary where you want to read nico@215: 00081 * an entry nico@215: 00082 * \param bSubindex The subindex of the Index. e.g. mostly subindex 0 is nico@215: 00083 * used to tell you how many valid entries you can find nico@215: 00084 * in this index. Look at the canopen standard for further nico@215: 00085 * information nico@215: 00086 * \param ppbData Pointer to the pointer which points to the variable where nico@215: 00087 * the value of this object dictionary entry should be copied nico@215: 00088 * \param pdwSize This function writes the size of the copied value (in Byte) nico@215: 00089 * into this variable. nico@215: 00090 * \param pDataType : The type of the data. See objdictdef.h nico@215: 00091 * \param CheckAccess if other than 0, do not read if the data is Write Only nico@215: 00092 * [Not used today. Put always 0]. nico@215: 00093 * \return OD_SUCCESSFUL or SDO abort code. (See file def.h) nico@215: 00094 */ etisserant@240: 00095 UNS32 getODentry( CO_Data* d, etisserant@240: 00096 UNS16 wIndex, etisserant@240: 00097 UNS8 bSubindex, nico@215: 00098 void * pDestData, etisserant@240: 00099 UNS8 * pExpectedSize, etisserant@240: 00100 UNS8 * pDataType, etisserant@240: 00101 UNS8 checkAccess); nico@215: 00102 nico@215: 00103 nico@215: 00104 /* By this function you can write an entry into the object dictionary\n nico@215: 00105 * \code nico@215: 00106 * // Example usage: nico@215: 00107 * UNS8 B; nico@215: 00108 * B = 0xFF; // set transmission type nico@215: 00109 * nico@215: 00110 * retcode = setODentry( (UNS16)0x1800, (UNS8)2, &B, sizeof(UNS8), 1 ); nico@215: 00111 * \endocde nico@215: 00112 * \param wIndex The index in the object dictionary where you want to write nico@215: 00113 * an entry nico@215: 00114 * \param bSubindex The subindex of the Index. e.g. mostly subindex 0 is nico@215: 00115 * used to tell you how many valid entries you can find nico@215: 00116 * in this index. Look at the canopen standard for further nico@215: 00117 * information nico@215: 00118 * \param pbData Pointer to the variable that holds the value that should nico@215: 00119 * be copied into the object dictionary nico@215: 00120 * \param dwSize The size of the value (in Byte). nico@215: 00121 * \param CheckAccess if other than 0, do not read if the data is Read Only or Constant nico@215: 00122 * \return OD_SUCCESSFUL or SDO abort code. (See file def.h) nico@215: 00123 */ etisserant@240: 00124 UNS32 setODentry( CO_Data* d, etisserant@240: 00125 UNS16 wIndex, etisserant@240: 00126 UNS8 bSubindex, nico@215: 00127 void * pSourceData, etisserant@240: 00128 UNS8 * pExpectedSize, etisserant@240: 00129 UNS8 checkAccess); nico@215: 00130 nico@215: 00131 /*The same, without endianisation*/ etisserant@240: 00132 UNS32 writeLocalDict( CO_Data* d, etisserant@240: 00133 UNS16 wIndex, etisserant@240: 00134 UNS8 bSubindex, nico@215: 00135 void * pSourceData, etisserant@240: 00136 UNS8 * pExpectedSize, etisserant@240: 00137 UNS8 checkAccess); nico@215: 00138 nico@215: 00139 nico@215: 00140 /* Scan the index of object dictionary. Used only by setODentry and getODentry. nico@215: 00141 * *errorCode : OD_SUCCESSFUL if index foundor SDO abort code. (See file def.h) nico@215: 00142 * Return NULL if index not found. Else : return the table part of the object dictionary. nico@215: 00143 */ etisserant@240: 00144 const indextable * scanIndexOD (CO_Data* d, UNS16 wIndex, UNS32 *errorCode, ODCallback_t **Callback); nico@215: 00145 etisserant@240: 00146 UNS32 RegisterSetODentryCallBack(CO_Data* d, UNS16 wIndex, UNS8 bSubindex, ODCallback_t Callback); nico@215: 00147 nico@215: 00148 #endif /* __objacces_h__ */ etisserant@240: