include/objacces.h
changeset 561 f9be4262c68d
parent 539 187058b4a4b8
child 588 ee181b4f177b
equal deleted inserted replaced
560:0bb927393dd0 561:f9be4262c68d
    44 typedef UNS32 (*valueRangeTest_t)(UNS8 typeValue, void *Value);
    44 typedef UNS32 (*valueRangeTest_t)(UNS8 typeValue, void *Value);
    45 typedef void (* storeODSubIndex_t)(CO_Data* d, UNS16 wIndex, UNS8 bSubindex);
    45 typedef void (* storeODSubIndex_t)(CO_Data* d, UNS16 wIndex, UNS8 bSubindex);
    46 void _storeODSubIndex (CO_Data* d, UNS16 wIndex, UNS8 bSubindex);
    46 void _storeODSubIndex (CO_Data* d, UNS16 wIndex, UNS8 bSubindex);
    47 
    47 
    48 /**
    48 /**
    49  * @ingroup od
       
    50  * @brief Print MSG_WAR (s) if error to the access to the object dictionary occurs.
    49  * @brief Print MSG_WAR (s) if error to the access to the object dictionary occurs.
    51  * 
    50  * 
    52  * You must uncomment the lines in the file objaccess.c :\n
    51  * You must uncomment the lines in the file objaccess.c :\n
    53  * //#define DEBUG_CAN\n
    52  * //#define DEBUG_CAN\n
    54  * //#define DEBUG_WAR_CONSOLE_ON\n
    53  * //#define DEBUG_WAR_CONSOLE_ON\n
    83  * if( returnValue != SUCCESSFUL )
    82  * if( returnValue != SUCCESSFUL )
    84  * {
    83  * {
    85  *     // error handling
    84  *     // error handling
    86  * }
    85  * }
    87  * @endcode 
    86  * @endcode 
    88  * @param *d Pointer on a CAN object data structure
    87  * @param *d Pointer to a CAN object data structure
    89  * @param wIndex The index in the object dictionary where you want to read
    88  * @param wIndex The index in the object dictionary where you want to read
    90  *               an entry
    89  *               an entry
    91  * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
    90  * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
    92  *                  used to tell you how many valid entries you can find
    91  *                  used to tell you how many valid entries you can find
    93  *                  in this index. Look at the canopen standard for further
    92  *                  in this index. Look at the canopen standard for further
    94  *                  information
    93  *                  information
    95  * @param *pDestData Pointer to the pointer which points to the variable where
    94  * @param *pDestData Pointer to the pointer which points to the variable where
    96  *                   the value of this object dictionary entry should be copied
    95  *                   the value of this object dictionary entry should be copied
    97  * @param pExpectedSize This function writes the size of the copied value (in Byte)
    96  * @param pExpectedSize This function writes the size of the copied value (in Byte)
    98  *                      into this variable.
    97  *                      into this variable.
    99  * @param *pDataType Pointer on the type of the data. See objdictdef.h
    98  * @param *pDataType Pointer to the type of the data. See objdictdef.h
   100  * @param CheckAccess if other than 0, do not read if the data is Write Only
    99  * @param CheckAccess if other than 0, do not read if the data is Write Only
   101  *                    [Not used today. Put always 0].
   100  *                    [Not used today. Put always 0].
   102  * @param Endianize  When not 0, data is endianized into network byte order
   101  * @param Endianize  When not 0, data is endianized into network byte order
   103  *                   when 0, data is not endianized and copied in machine native
   102  *                   when 0, data is not endianized and copied in machine native
   104  *                   endianness 
   103  *                   endianness 
   105  * @return OD_SUCCESSFUL or SDO abort code. (See file def.h)
   104  * @return 
       
   105  * - OD_SUCCESSFUL is returned upon success. 
       
   106  * - SDO abort code is returned if error occurs . (See file def.h)
   106  */
   107  */
   107 UNS32 _getODentry( CO_Data* d, 
   108 UNS32 _getODentry( CO_Data* d, 
   108 		  UNS16 wIndex,
   109 		  UNS16 wIndex,
   109 		  UNS8 bSubindex,
   110 		  UNS8 bSubindex,
   110 		  void * pDestData,
   111 		  void * pDestData,
   114 		  UNS8 endianize);
   115 		  UNS8 endianize);
   115 
   116 
   116 /** 
   117 /** 
   117  * @ingroup od
   118  * @ingroup od
   118  * @brief getODentry() to read from object and endianize
   119  * @brief getODentry() to read from object and endianize
   119  * @param OD Pointer on a CAN object data structure
   120  * @param OD Pointer to a CAN object data structure
   120  * @param wIndex The index in the object dictionary where you want to read
   121  * @param wIndex The index in the object dictionary where you want to read
   121  *                an entry
   122  *                an entry
   122  * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
   123  * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
   123  *                  used to tell you how many valid entries you can find
   124  *                  used to tell you how many valid entries you can find
   124  *                  in this index. Look at the canopen standard for further
   125  *                  in this index. Look at the canopen standard for further
   125  *                  information
   126  *                  information
   126  * @param *pDestData Pointer to the pointer which points to the variable where
   127  * @param *pDestData Pointer to the pointer which points to the variable where
   127  *                   the value of this object dictionary entry should be copied
   128  *                   the value of this object dictionary entry should be copied
   128  * @param pExpectedSize This function writes the size of the copied value (in Byte)
   129  * @param pExpectedSize This function writes the size of the copied value (in Byte)
   129  *                      into this variable.
   130  *                      into this variable.
   130  * @param *pDataType Pointer on the type of the data. See objdictdef.h
   131  * @param *pDataType Pointer to the type of the data. See objdictdef.h
   131  * @param checkAccess if other than 0, do not read if the data is Write Only
   132  * @param checkAccess Flag that indicate if a check rights must be perfomed (0 : no , other than 0 : yes)
   132  *                    [Not used today. Put always 0].
       
   133  * @param endianize  Set to 1 : endianized into network byte order 
   133  * @param endianize  Set to 1 : endianized into network byte order 
   134  * @return OD_SUCCESSFUL or SDO abort code. (See file def.h)
   134  * @return 
       
   135  * - OD_SUCCESSFUL is returned upon success. 
       
   136  * - SDO abort code is returned if error occurs . (See file def.h)
   135  */
   137  */
   136 #define getODentry( OD, wIndex, bSubindex, pDestData, pExpectedSize, \
   138 #define getODentry( OD, wIndex, bSubindex, pDestData, pExpectedSize, \
   137 		          pDataType,  checkAccess)                         \
   139 		          pDataType,  checkAccess)                         \
   138        _getODentry( OD, wIndex, bSubindex, pDestData, pExpectedSize, \
   140        _getODentry( OD, wIndex, bSubindex, pDestData, pExpectedSize, \
   139 		          pDataType,  checkAccess, 1)            
   141 		          pDataType,  checkAccess, 1)            
   141 /** 
   143 /** 
   142  * @ingroup od
   144  * @ingroup od
   143  * @brief readLocalDict() reads an entry from the object dictionary, but in 
   145  * @brief readLocalDict() reads an entry from the object dictionary, but in 
   144  * contrast to getODentry(), readLocalDict() doesn't endianize entry and reads
   146  * contrast to getODentry(), readLocalDict() doesn't endianize entry and reads
   145  * entry in machine native endianness. 
   147  * entry in machine native endianness. 
   146  * @param OD Pointer on a CAN object data structure
   148  * @param OD Pointer to a CAN object data structure
   147  * @param wIndex The index in the object dictionary where you want to read
   149  * @param wIndex The index in the object dictionary where you want to read
   148  *                an entry
   150  *                an entry
   149  * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
   151  * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
   150  *                  used to tell you how many valid entries you can find
   152  *                  used to tell you how many valid entries you can find
   151  *                  in this index. Look at the canopen standard for further
   153  *                  in this index. Look at the canopen standard for further
   152  *                  information
   154  *                  information
   153  * @param *pDestData Pointer to the pointer which points to the variable where
   155  * @param *pDestData Pointer to the pointer which points to the variable where
   154  *                   the value of this object dictionary entry should be copied
   156  *                   the value of this object dictionary entry should be copied
   155  * @param pExpectedSize This function writes the size of the copied value (in Byte)
   157  * @param pExpectedSize This function writes the size of the copied value (in Byte)
   156  *                      into this variable.
   158  *                      into this variable.
   157  * @param *pDataType Pointer on the type of the data. See objdictdef.h
   159  * @param *pDataType Pointer to the type of the data. See objdictdef.h
   158  * @param checkAccess if other than 0, do not read if the data is Write Only
   160  * @param checkAccess if other than 0, do not read if the data is Write Only
   159  *                    [Not used today. Put always 0].
   161  *                    [Not used today. Put always 0].
   160  * @param endianize Set to 0, data is not endianized and copied in machine native
   162  * @param endianize Set to 0, data is not endianized and copied in machine native
   161  *                  endianness 
   163  *                  endianness 
   162  * @return OD_SUCCESSFUL or SDO abort code. (See file def.h)
   164  * @return 
       
   165  * - OD_SUCCESSFUL is returned upon success. 
       
   166  * - SDO abort code is returned if error occurs . (See file def.h)
   163  */
   167  */
   164 #define readLocalDict( OD, wIndex, bSubindex, pDestData, pExpectedSize, \
   168 #define readLocalDict( OD, wIndex, bSubindex, pDestData, pExpectedSize, \
   165 		          pDataType,  checkAccess)                         \
   169 		          pDataType,  checkAccess)                         \
   166        _getODentry( OD, wIndex, bSubindex, pDestData, pExpectedSize, \
   170        _getODentry( OD, wIndex, bSubindex, pDestData, pExpectedSize, \
   167 		          pDataType,  checkAccess, 0)
   171 		          pDataType,  checkAccess, 0)
   168 
   172 
   169 /**
   173 /* By this function you can write an entry into the object dictionary
   170  * @brief By this function you can write an entry into the object dictionary
   174  * @param *d Pointer to a CAN object data structure
   171  * @param *d Pointer on a CAN object data structure
       
   172  * @param wIndex The index in the object dictionary where you want to write
   175  * @param wIndex The index in the object dictionary where you want to write
   173  *               an entry
   176  *               an entry
   174  * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
   177  * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
   175  *                  used to tell you how many valid entries you can find
   178  *                  used to tell you how many valid entries you can find
   176  *                  in this index. Look at the canopen standard for further
   179  *                  in this index. Look at the canopen standard for further
   177  *                  information
   180  *                  information
   178  * @param *pSourceData Pointer to the variable that holds the value that should
   181  * @param *pSourceData Pointer to the variable that holds the value that should
   179  *                     be copied into the object dictionary
   182  *                     be copied into the object dictionary
   180  * @param *pExpectedSize The size of the value (in Byte).
   183  * @param *pExpectedSize The size of the value (in Byte).
   181  * @param checkAccess if other than 0, do not read if the data is Read Only or Constant
   184  * @param checkAccess Flag that indicate if a check rights must be perfomed (0 : no , other than 0 : yes)
   182  * @param endianize When not 0, data is endianized into network byte order
   185  * @param endianize When not 0, data is endianized into network byte order
   183  *                  when 0, data is not endianized and copied in machine native
   186  *                  when 0, data is not endianized and copied in machine native
   184  *                  endianness   
   187  *                  endianness   
   185  * @return OD_SUCCESSFUL or SDO abort code. (See file def.h)
   188  * @return 
       
   189  * - OD_SUCCESSFUL is returned upon success. 
       
   190  * - SDO abort code is returned if error occurs . (See file def.h)
   186  */
   191  */
   187 UNS32 _setODentry( CO_Data* d,
   192 UNS32 _setODentry( CO_Data* d,
   188                    UNS16 wIndex,
   193                    UNS16 wIndex,
   189                    UNS8 bSubindex,
   194                    UNS8 bSubindex,
   190                    void * pSourceData,
   195                    void * pSourceData,
   201  * UNS8 B;
   206  * UNS8 B;
   202  * B = 0xFF; // set transmission type
   207  * B = 0xFF; // set transmission type
   203  *
   208  *
   204  * retcode = setODentry( (UNS16)0x1800, (UNS8)2, &B, sizeof(UNS8), 1 );
   209  * retcode = setODentry( (UNS16)0x1800, (UNS8)2, &B, sizeof(UNS8), 1 );
   205  * @endcode
   210  * @endcode
   206  * @param d Pointer on a CAN object data structure
   211  * @param d Pointer to a CAN object data structure
   207  * @param wIndex The index in the object dictionary where you want to write
   212  * @param wIndex The index in the object dictionary where you want to write
   208  *               an entry
   213  *               an entry
   209  * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
   214  * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
   210  *                  used to tell you how many valid entries you can find
   215  *                  used to tell you how many valid entries you can find
   211  *                  in this index. Look at the canopen standard for further
   216  *                  in this index. Look at the canopen standard for further
   212  *                  information
   217  *                  information
   213  * @param *pSourceData Pointer to the variable that holds the value that should
   218  * @param *pSourceData Pointer to the variable that holds the value that should
   214  *                     be copied into the object dictionary
   219  *                     be copied into the object dictionary
   215  * @param *pExpectedSize The size of the value (in Byte).
   220  * @param *pExpectedSize The size of the value (in Byte).
   216  * @param checkAccess if other than 0, do not read if the data is Read Only or Constant
   221  * @param checkAccess Flag that indicate if a check rights must be perfomed (0 : no , other than 0 : yes)
   217  * @param endianize Set to 1 : endianized into network byte order
   222  * @param endianize Set to 1 : endianized into network byte order
   218  * @return OD_SUCCESSFUL or SDO abort code. (See file def.h)
   223  * @return 
   219  */
   224  * - OD_SUCCESSFUL is returned upon success. 
   220 #define setODentry( d, wIndex, bSubindex, pSourceData, pExpectedSize, checkAccess) \
   225  * - SDO abort code is returned if error occurs . (See file def.h)
   221        _setODentry( d, wIndex, bSubindex, pSourceData, pExpectedSize, checkAccess, 1)
   226  */
   222 
   227 #define setODentry( d, wIndex, bSubindex, pSourceData, pExpectedSize, \
   223 /**
   228                   checkAccess) \
   224  * @ingroup od
   229        _setODentry( d, wIndex, bSubindex, pSourceData, pExpectedSize, \
       
   230                   checkAccess, 1)
       
   231 
       
   232 /** @fn UNS32 writeLocalDict(d, wIndex, bSubindex, pSourceData, pExpectedSize, checkAccess)
       
   233  * @ingroup od
       
   234  * @hideinitializer
   225  * @brief Writes machine native SourceData to OD.
   235  * @brief Writes machine native SourceData to OD.
       
   236  * @param d Pointer to a CAN object data structure
       
   237  * @param wIndex The index in the object dictionary where you want to write
       
   238  *               an entry
       
   239  * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
       
   240  *                  used to tell you how many valid entries you can find
       
   241  *                  in this index. Look at the canopen standard for further
       
   242  *                  information
       
   243  * @param *pSourceData Pointer to the variable that holds the value that should
       
   244  *                     be copied into the object dictionary
       
   245  * @param *pExpectedSize The size of the value (in Byte).
       
   246  * @param checkAccess Flag that indicate if a check rights must be perfomed (0 : no , other than 0 : yes)
       
   247  * @param endianize Data is not endianized and copied in machine native endianness 
       
   248  * @return 
       
   249  * - OD_SUCCESSFUL is returned upon success. 
       
   250  * - SDO abort code is returned if error occurs . (See file def.h)
       
   251  * \n\n
   226  * @code
   252  * @code
   227  * // Example usage:
   253  * // Example usage:
   228  * UNS8 B;
   254  * UNS8 B;
   229  * B = 0xFF; // set transmission type
   255  * B = 0xFF; // set transmission type
   230  *
   256  *
   231  * retcode = writeLocalDict( (UNS16)0x1800, (UNS8)2, &B, sizeof(UNS8), 1 );
   257  * retcode = writeLocalDict( (UNS16)0x1800, (UNS8)2, &B, sizeof(UNS8), 1 );
   232  * @endcode
   258  * @endcode
   233  * @param d Pointer on a CAN object data structure
       
   234  * @param wIndex The index in the object dictionary where you want to write
       
   235  *               an entry
       
   236  * @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
       
   237  *                  used to tell you how many valid entries you can find
       
   238  *                  in this index. Look at the canopen standard for further
       
   239  *                  information
       
   240  * @param *pSourceData Pointer to the variable that holds the value that should
       
   241  *                     be copied into the object dictionary
       
   242  * @param *pExpectedSize The size of the value (in Byte).
       
   243  * @param checkAccess if other than 0, do not read if the data is Read Only or Constant
       
   244  * @param endianize Data is not endianized and copied in machine native endianness 
       
   245  * @return OD_SUCCESSFUL or SDO abort code. (See file def.h)
       
   246  */
   259  */
   247 #define writeLocalDict( d, wIndex, bSubindex, pSourceData, pExpectedSize, checkAccess) \
   260 #define writeLocalDict( d, wIndex, bSubindex, pSourceData, pExpectedSize, checkAccess) \
   248        _setODentry( d, wIndex, bSubindex, pSourceData, pExpectedSize, checkAccess, 0)
   261        _setODentry( d, wIndex, bSubindex, pSourceData, pExpectedSize, checkAccess, 0)
   249 
   262 
   250 
   263 
   251 
   264 
   252 /**
   265 /**
   253  * @brief Scan the index of object dictionary. Used only by setODentry and getODentry.
   266  * @brief Scan the index of object dictionary. Used only by setODentry and getODentry.
   254  * @param *d Pointer on a CAN object data structure
   267  * @param *d Pointer to a CAN object data structure
   255  * @param wIndex
   268  * @param wIndex
   256  * @param *errorCode :  OD_SUCCESSFUL if index foundor SDO abort code. (See file def.h)
   269  * @param *errorCode :  OD_SUCCESSFUL if index foundor SDO abort code. (See file def.h)
   257  * @param **Callback
   270  * @param **Callback
   258  * @return NULL if index not found. Else : return the table part of the object dictionary.
   271  * @return NULL if index not found. Else : return the table part of the object dictionary.
   259  */
   272  */