Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | |
| 3 | (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29 |
| 4 | www.systec-electronic.com |
| 5 | |
| 6 | Project: openPOWERLINK |
| 7 | |
| 8 | Description: source file for api function of EplOBD-Module |
| 9 | |
| 10 | License: |
| 11 | |
| 12 | Redistribution and use in source and binary forms, with or without |
| 13 | modification, are permitted provided that the following conditions |
| 14 | are met: |
| 15 | |
| 16 | 1. Redistributions of source code must retain the above copyright |
| 17 | notice, this list of conditions and the following disclaimer. |
| 18 | |
| 19 | 2. Redistributions in binary form must reproduce the above copyright |
| 20 | notice, this list of conditions and the following disclaimer in the |
| 21 | documentation and/or other materials provided with the distribution. |
| 22 | |
| 23 | 3. Neither the name of SYSTEC electronic GmbH nor the names of its |
| 24 | contributors may be used to endorse or promote products derived |
| 25 | from this software without prior written permission. For written |
| 26 | permission, please contact info@systec-electronic.com. |
| 27 | |
| 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 31 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 32 | COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 33 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 34 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 35 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 36 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 37 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 38 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 39 | POSSIBILITY OF SUCH DAMAGE. |
| 40 | |
| 41 | Severability Clause: |
| 42 | |
| 43 | If a provision of this License is or becomes illegal, invalid or |
| 44 | unenforceable in any jurisdiction, that shall not affect: |
| 45 | 1. the validity or enforceability in that jurisdiction of any other |
| 46 | provision of this License; or |
| 47 | 2. the validity or enforceability in other jurisdictions of that or |
| 48 | any other provision of this License. |
| 49 | |
| 50 | ------------------------------------------------------------------------- |
| 51 | |
| 52 | $RCSfile: EplObd.c,v $ |
| 53 | |
| 54 | $Author: D.Krueger $ |
| 55 | |
| 56 | $Revision: 1.12 $ $Date: 2008/10/17 15:32:32 $ |
| 57 | |
| 58 | $State: Exp $ |
| 59 | |
| 60 | Build Environment: |
| 61 | Microsoft VC7 |
| 62 | |
| 63 | ------------------------------------------------------------------------- |
| 64 | |
| 65 | Revision History: |
| 66 | |
| 67 | 2006/06/02 k.t.: start of the implementation, version 1.00 |
| 68 | ->based on CANopen OBD-Modul |
| 69 | |
| 70 | ****************************************************************************/ |
| 71 | |
| 72 | #include "EplInc.h" |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 73 | #include "kernel/EplObdk.h" // function prototyps of the EplOBD-Modul |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 74 | |
| 75 | #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0) |
| 76 | |
| 77 | /***************************************************************************/ |
| 78 | /* */ |
| 79 | /* */ |
| 80 | /* G L O B A L D E F I N I T I O N S */ |
| 81 | /* */ |
| 82 | /* */ |
| 83 | /***************************************************************************/ |
| 84 | |
| 85 | //--------------------------------------------------------------------------- |
| 86 | // const defines |
| 87 | //--------------------------------------------------------------------------- |
| 88 | |
| 89 | // float definitions and macros |
| 90 | #define _SHIFTED_EXPONENT_MASK_SP 0xff |
| 91 | #define _BIAS_SP 126 |
| 92 | #define T_SP 23 |
| 93 | #define EXPONENT_DENORM_SP (-_BIAS_SP) |
| 94 | #define BASE_TO_THE_T_SP ((float) 8388608.0) |
| 95 | #define GET_EXPONENT_SP(x) ((((x) >> T_SP) & _SHIFTED_EXPONENT_MASK_SP) - _BIAS_SP) |
| 96 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 97 | //--------------------------------------------------------------------------- |
| 98 | // local types |
| 99 | //--------------------------------------------------------------------------- |
| 100 | |
| 101 | // struct for instance table |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 102 | INSTANCE_TYPE_BEGIN EPL_MCO_DECL_INSTANCE_MEMBER() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 103 | |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 104 | STATIC tEplObdInitParam m_ObdInitParam; |
Greg Kroah-Hartman | 44b7117 | 2009-03-23 11:39:15 -0700 | [diff] [blame] | 105 | STATIC tEplObdStoreLoadObjCallback m_fpStoreLoadObjCallback; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 106 | |
| 107 | INSTANCE_TYPE_END |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 108 | // decomposition of float |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 109 | typedef union { |
| 110 | tEplObdReal32 m_flRealPart; |
| 111 | int m_nIntegerPart; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 112 | |
| 113 | } tEplObdRealParts; |
| 114 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 115 | //--------------------------------------------------------------------------- |
| 116 | // modul globale vars |
| 117 | //--------------------------------------------------------------------------- |
| 118 | |
| 119 | // This macro replace the unspecific pointer to an instance through |
| 120 | // the modul specific type for the local instance table. This macro |
| 121 | // must defined in each modul. |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 122 | //#define tEplPtrInstance tEplInstanceInfo * |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 123 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 124 | EPL_MCO_DECL_INSTANCE_VAR() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 125 | |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 126 | u8 abEplObdTrashObject_g[8]; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 127 | |
| 128 | //--------------------------------------------------------------------------- |
| 129 | // local function prototypes |
| 130 | //--------------------------------------------------------------------------- |
| 131 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 132 | EPL_MCO_DEFINE_INSTANCE_FCT() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 133 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 134 | static tEplKernel EplObdCallObjectCallback(EPL_MCO_DECL_INSTANCE_PTR_ |
| 135 | tEplObdCallback fpCallback_p, |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 136 | tEplObdCbParam *pCbParam_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 137 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 138 | static tEplObdSize EplObdGetDataSizeIntern(tEplObdSubEntryPtr pSubIndexEntry_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 139 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 140 | static tEplObdSize EplObdGetStrLen(void *pObjData_p, |
| 141 | tEplObdSize ObjLen_p, tEplObdType ObjType_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 142 | |
| 143 | #if (EPL_OBD_CHECK_OBJECT_RANGE != FALSE) |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 144 | static tEplKernel EplObdCheckObjectRange(tEplObdSubEntryPtr pSubindexEntry_p, |
| 145 | void *pData_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 146 | #endif |
| 147 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 148 | static tEplKernel EplObdGetVarEntry(tEplObdSubEntryPtr pSubindexEntry_p, |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 149 | tEplObdVarEntry **ppVarEntry_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 150 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 151 | static tEplKernel EplObdGetEntry(EPL_MCO_DECL_INSTANCE_PTR_ |
| 152 | unsigned int uiIndex_p, |
| 153 | unsigned int uiSubindex_p, |
| 154 | tEplObdEntryPtr * ppObdEntry_p, |
| 155 | tEplObdSubEntryPtr * ppObdSubEntry_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 156 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 157 | static tEplObdSize EplObdGetObjectSize(tEplObdSubEntryPtr pSubIndexEntry_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 158 | |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 159 | static tEplKernel EplObdGetIndexIntern(tEplObdInitParam *pInitParam_p, |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 160 | unsigned int uiIndex_p, |
| 161 | tEplObdEntryPtr * ppObdEntry_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 162 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 163 | static tEplKernel EplObdGetSubindexIntern(tEplObdEntryPtr pObdEntry_p, |
| 164 | unsigned int uiSubIndex_p, |
| 165 | tEplObdSubEntryPtr * ppObdSubEntry_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 166 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 167 | static tEplKernel EplObdAccessOdPartIntern(EPL_MCO_DECL_INSTANCE_PTR_ |
| 168 | tEplObdPart CurrentOdPart_p, |
| 169 | tEplObdEntryPtr pObdEnty_p, |
| 170 | tEplObdDir Direction_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 171 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 172 | static void *EplObdGetObjectDefaultPtr(tEplObdSubEntryPtr pSubIndexEntry_p); |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 173 | static void *EplObdGetObjectCurrentPtr(tEplObdSubEntryPtr pSubIndexEntry_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 174 | |
| 175 | #if (EPL_OBD_USE_STORE_RESTORE != FALSE) |
| 176 | |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 177 | static tEplKernel EplObdCallStoreCallback(EPL_MCO_DECL_INSTANCE_PTR_ tEplObdCbStoreParam *pCbStoreParam_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 178 | |
| 179 | #endif // (EPL_OBD_USE_STORE_RESTORE != FALSE) |
| 180 | |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 181 | static void EplObdCopyObjectData(void *pDstData_p, |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 182 | void *pSrcData_p, |
| 183 | tEplObdSize ObjSize_p, tEplObdType ObjType_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 184 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 185 | void *EplObdGetObjectDataPtrIntern(tEplObdSubEntryPtr pSubindexEntry_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 186 | |
| 187 | static tEplKernel EplObdIsNumericalIntern(tEplObdSubEntryPtr pObdSubEntry_p, |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 188 | BOOL * pfEntryNumerical_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 189 | |
Greg Kroah-Hartman | d10f469 | 2009-03-23 10:45:12 -0700 | [diff] [blame] | 190 | static tEplKernel EplObdWriteEntryPre(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p, |
| 191 | unsigned int uiSubIndex_p, |
| 192 | void *pSrcData_p, |
| 193 | void **ppDstData_p, |
| 194 | tEplObdSize Size_p, |
| 195 | tEplObdEntryPtr *ppObdEntry_p, |
| 196 | tEplObdSubEntryPtr *ppSubEntry_p, |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 197 | tEplObdCbParam *pCbParam_p, |
Greg Kroah-Hartman | d10f469 | 2009-03-23 10:45:12 -0700 | [diff] [blame] | 198 | tEplObdSize *pObdSize_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 199 | |
Greg Kroah-Hartman | d10f469 | 2009-03-23 10:45:12 -0700 | [diff] [blame] | 200 | static tEplKernel EplObdWriteEntryPost(EPL_MCO_DECL_INSTANCE_PTR_ tEplObdEntryPtr pObdEntry_p, |
| 201 | tEplObdSubEntryPtr pSubEntry_p, |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 202 | tEplObdCbParam *pCbParam_p, |
Greg Kroah-Hartman | d10f469 | 2009-03-23 10:45:12 -0700 | [diff] [blame] | 203 | void *pSrcData_p, |
| 204 | void *pDstData_p, |
| 205 | tEplObdSize ObdSize_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 206 | |
| 207 | //=========================================================================// |
| 208 | // // |
| 209 | // P U B L I C F U N C T I O N S // |
| 210 | // // |
| 211 | //=========================================================================// |
| 212 | |
| 213 | //--------------------------------------------------------------------------- |
| 214 | // |
| 215 | // Function: EplObdInit() |
| 216 | // |
| 217 | // Description: initializes the first instance |
| 218 | // |
| 219 | // Parameters: pInitParam_p = init parameter |
| 220 | // |
| 221 | // Return: tEplKernel = errorcode |
| 222 | // |
| 223 | // State: |
| 224 | // |
| 225 | //--------------------------------------------------------------------------- |
| 226 | |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 227 | tEplKernel EplObdInit(EPL_MCO_DECL_PTR_INSTANCE_PTR_ tEplObdInitParam *pInitParam_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 228 | { |
| 229 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 230 | tEplKernel Ret; |
| 231 | EPL_MCO_DELETE_INSTANCE_TABLE(); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 232 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 233 | if (pInitParam_p == NULL) { |
| 234 | Ret = kEplSuccessful; |
| 235 | goto Exit; |
| 236 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 237 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 238 | Ret = EplObdAddInstance(EPL_MCO_PTR_INSTANCE_PTR_ pInitParam_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 239 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 240 | Exit: |
| 241 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 242 | |
| 243 | } |
| 244 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 245 | //--------------------------------------------------------------------------- |
| 246 | // |
| 247 | // Function: EplObdAddInstance() |
| 248 | // |
| 249 | // Description: adds a new instance |
| 250 | // |
| 251 | // Parameters: pInitParam_p |
| 252 | // |
| 253 | // Return: tEplKernel |
| 254 | // |
| 255 | // State: |
| 256 | // |
| 257 | //--------------------------------------------------------------------------- |
| 258 | |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 259 | tEplKernel EplObdAddInstance(EPL_MCO_DECL_PTR_INSTANCE_PTR_ tEplObdInitParam *pInitParam_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 260 | { |
| 261 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 262 | EPL_MCO_DECL_INSTANCE_PTR_LOCAL tEplKernel Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 263 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 264 | // check if pointer to instance pointer valid |
| 265 | // get free instance and set the globale instance pointer |
| 266 | // set also the instance addr to parameterlist |
| 267 | EPL_MCO_CHECK_PTR_INSTANCE_PTR(); |
| 268 | EPL_MCO_GET_FREE_INSTANCE_PTR(); |
| 269 | EPL_MCO_SET_PTR_INSTANCE_PTR(); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 270 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 271 | // save init parameters |
| 272 | EPL_MEMCPY(&EPL_MCO_GLB_VAR(m_ObdInitParam), pInitParam_p, |
| 273 | sizeof(tEplObdInitParam)); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 274 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 275 | // clear callback function for command LOAD and STORE |
| 276 | EPL_MCO_GLB_VAR(m_fpStoreLoadObjCallback) = NULL; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 277 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 278 | // sign instance as used |
| 279 | EPL_MCO_WRITE_INSTANCE_STATE(kStateUsed); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 280 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 281 | // initialize object dictionary |
| 282 | // so all all VarEntries will be initialized to trash object and default values will be set to current data |
| 283 | Ret = EplObdAccessOdPart(EPL_MCO_INSTANCE_PTR_ |
| 284 | kEplObdPartAll, kEplObdDirInit); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 285 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 286 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 287 | |
| 288 | } |
| 289 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 290 | //--------------------------------------------------------------------------- |
| 291 | // |
| 292 | // Function: EplObdDeleteInstance() |
| 293 | // |
| 294 | // Description: delete instance |
| 295 | // |
| 296 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR |
| 297 | // |
| 298 | // Return: tEplKernel |
| 299 | // |
| 300 | // State: |
| 301 | // |
| 302 | //--------------------------------------------------------------------------- |
| 303 | #if (EPL_USE_DELETEINST_FUNC != FALSE) |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 304 | tEplKernel EplObdDeleteInstance(EPL_MCO_DECL_INSTANCE_PTR) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 305 | { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 306 | // check for all API function if instance is valid |
| 307 | EPL_MCO_CHECK_INSTANCE_STATE(); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 308 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 309 | // sign instance as unused |
| 310 | EPL_MCO_WRITE_INSTANCE_STATE(kStateUnused); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 311 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 312 | return kEplSuccessful; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 313 | |
| 314 | } |
| 315 | #endif // (EPL_USE_DELETEINST_FUNC != FALSE) |
| 316 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 317 | //--------------------------------------------------------------------------- |
| 318 | // |
| 319 | // Function: EplObdWriteEntry() |
| 320 | // |
| 321 | // Description: Function writes data to an OBD entry. Strings |
| 322 | // are stored with added '\0' character. |
| 323 | // |
| 324 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ |
| 325 | // uiIndex_p = Index of the OD entry |
| 326 | // uiSubIndex_p = Subindex of the OD Entry |
| 327 | // pSrcData_p = Pointer to the data to write |
| 328 | // Size_p = Size of the data in Byte |
| 329 | // |
| 330 | // Return: tEplKernel = Errorcode |
| 331 | // |
| 332 | // |
| 333 | // State: |
| 334 | // |
| 335 | //--------------------------------------------------------------------------- |
| 336 | |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 337 | tEplKernel EplObdWriteEntry(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p, |
| 338 | unsigned int uiSubIndex_p, |
| 339 | void *pSrcData_p, tEplObdSize Size_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 340 | { |
| 341 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 342 | tEplKernel Ret; |
| 343 | tEplObdEntryPtr pObdEntry; |
| 344 | tEplObdSubEntryPtr pSubEntry; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 345 | tEplObdCbParam CbParam; |
| 346 | void *pDstData; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 347 | tEplObdSize ObdSize; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 348 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 349 | Ret = EplObdWriteEntryPre(EPL_MCO_INSTANCE_PTR_ |
| 350 | uiIndex_p, |
| 351 | uiSubIndex_p, |
| 352 | pSrcData_p, |
| 353 | &pDstData, |
| 354 | Size_p, |
| 355 | &pObdEntry, &pSubEntry, &CbParam, &ObdSize); |
| 356 | if (Ret != kEplSuccessful) { |
| 357 | goto Exit; |
| 358 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 359 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 360 | Ret = EplObdWriteEntryPost(EPL_MCO_INSTANCE_PTR_ |
| 361 | pObdEntry, |
| 362 | pSubEntry, |
| 363 | &CbParam, pSrcData_p, pDstData, ObdSize); |
| 364 | if (Ret != kEplSuccessful) { |
| 365 | goto Exit; |
| 366 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 367 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 368 | Exit: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 369 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 370 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 371 | |
| 372 | } |
| 373 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 374 | //--------------------------------------------------------------------------- |
| 375 | // |
| 376 | // Function: EplObdReadEntry() |
| 377 | // |
| 378 | // Description: The function reads an object entry. The application |
| 379 | // can always read the data even if attrib kEplObdAccRead |
| 380 | // is not set. The attrib is only checked up for SDO transfer. |
| 381 | // |
| 382 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ |
| 383 | // uiIndex_p = Index oof the OD entry to read |
| 384 | // uiSubIndex_p = Subindex to read |
| 385 | // pDstData_p = pointer to the buffer for data |
| 386 | // Offset_p = offset in data for read access |
| 387 | // pSize_p = IN: Size of the buffer |
| 388 | // OUT: number of readed Bytes |
| 389 | // |
| 390 | // Return: tEplKernel |
| 391 | // |
| 392 | // State: |
| 393 | // |
| 394 | //--------------------------------------------------------------------------- |
| 395 | |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 396 | tEplKernel EplObdReadEntry(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p, |
| 397 | unsigned int uiSubIndex_p, |
| 398 | void *pDstData_p, tEplObdSize *pSize_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 399 | { |
| 400 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 401 | tEplKernel Ret; |
| 402 | tEplObdEntryPtr pObdEntry; |
| 403 | tEplObdSubEntryPtr pSubEntry; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 404 | tEplObdCbParam CbParam; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 405 | void *pSrcData; |
| 406 | tEplObdSize ObdSize; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 407 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 408 | // check for all API function if instance is valid |
| 409 | EPL_MCO_CHECK_INSTANCE_STATE(); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 410 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 411 | ASSERT(pDstData_p != NULL); |
| 412 | ASSERT(pSize_p != NULL); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 413 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 414 | // get address of index and subindex entry |
| 415 | Ret = EplObdGetEntry(EPL_MCO_INSTANCE_PTR_ |
| 416 | uiIndex_p, uiSubIndex_p, &pObdEntry, &pSubEntry); |
| 417 | if (Ret != kEplSuccessful) { |
| 418 | goto Exit; |
| 419 | } |
| 420 | // get pointer to object data |
| 421 | pSrcData = EplObdGetObjectDataPtrIntern(pSubEntry); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 422 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 423 | // check source pointer |
| 424 | if (pSrcData == NULL) { |
| 425 | Ret = kEplObdReadViolation; |
| 426 | goto Exit; |
| 427 | } |
| 428 | //------------------------------------------------------------------------ |
| 429 | // address of source data to structure of callback parameters |
| 430 | // so callback function can change this data before reading |
| 431 | CbParam.m_uiIndex = uiIndex_p; |
| 432 | CbParam.m_uiSubIndex = uiSubIndex_p; |
| 433 | CbParam.m_pArg = pSrcData; |
| 434 | CbParam.m_ObdEvent = kEplObdEvPreRead; |
| 435 | Ret = EplObdCallObjectCallback(EPL_MCO_INSTANCE_PTR_ |
| 436 | pObdEntry->m_fpCallback, &CbParam); |
| 437 | if (Ret != kEplSuccessful) { |
| 438 | goto Exit; |
| 439 | } |
| 440 | // get size of data and check if application has reserved enough memory |
| 441 | ObdSize = EplObdGetDataSizeIntern(pSubEntry); |
| 442 | // check if offset given and calc correct number of bytes to read |
| 443 | if (*pSize_p < ObdSize) { |
| 444 | Ret = kEplObdValueLengthError; |
| 445 | goto Exit; |
| 446 | } |
| 447 | // read value from object |
| 448 | EPL_MEMCPY(pDstData_p, pSrcData, ObdSize); |
| 449 | *pSize_p = ObdSize; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 450 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 451 | // write address of destination data to structure of callback parameters |
| 452 | // so callback function can change this data after reading |
| 453 | CbParam.m_pArg = pDstData_p; |
| 454 | CbParam.m_ObdEvent = kEplObdEvPostRead; |
| 455 | Ret = EplObdCallObjectCallback(EPL_MCO_INSTANCE_PTR_ |
| 456 | pObdEntry->m_fpCallback, &CbParam); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 457 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 458 | Exit: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 459 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 460 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 461 | |
| 462 | } |
| 463 | |
| 464 | //--------------------------------------------------------------------------- |
| 465 | // |
| 466 | // Function: EplObdAccessOdPart() |
| 467 | // |
| 468 | // Description: restores default values of one part of OD |
| 469 | // |
| 470 | // Parameters: ObdPart_p |
| 471 | // Direction_p |
| 472 | // |
| 473 | // Return: tEplKernel |
| 474 | // |
| 475 | // State: |
| 476 | // |
| 477 | //--------------------------------------------------------------------------- |
| 478 | |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 479 | tEplKernel EplObdAccessOdPart(EPL_MCO_DECL_INSTANCE_PTR_ tEplObdPart ObdPart_p, |
| 480 | tEplObdDir Direction_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 481 | { |
| 482 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 483 | tEplKernel Ret = kEplSuccessful; |
| 484 | BOOL fPartFount; |
| 485 | tEplObdEntryPtr pObdEntry; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 486 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 487 | // check for all API function if instance is valid |
| 488 | EPL_MCO_CHECK_INSTANCE_STATE(); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 489 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 490 | // part always has to be unequal to NULL |
| 491 | pObdEntry = EPL_MCO_GLB_VAR(m_ObdInitParam.m_pPart); |
| 492 | ASSERTMSG(pObdEntry != NULL, |
| 493 | "EplObdAccessOdPart(): no OD part is defined!\n"); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 494 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 495 | // if ObdPart_p is not valid fPartFound keeps FALSE and function returns kEplObdIllegalPart |
| 496 | fPartFount = FALSE; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 497 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 498 | // access to part |
| 499 | if ((ObdPart_p & kEplObdPartGen) != 0) { |
| 500 | fPartFount = TRUE; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 501 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 502 | Ret = EplObdAccessOdPartIntern(EPL_MCO_INSTANCE_PTR_ |
| 503 | kEplObdPartGen, pObdEntry, |
| 504 | Direction_p); |
| 505 | if (Ret != kEplSuccessful) { |
| 506 | goto Exit; |
| 507 | } |
| 508 | } |
| 509 | // access to manufacturer part |
| 510 | pObdEntry = EPL_MCO_GLB_VAR(m_ObdInitParam.m_pManufacturerPart); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 511 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 512 | if (((ObdPart_p & kEplObdPartMan) != 0) && (pObdEntry != NULL)) { |
| 513 | fPartFount = TRUE; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 514 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 515 | Ret = EplObdAccessOdPartIntern(EPL_MCO_INSTANCE_PTR_ |
| 516 | kEplObdPartMan, pObdEntry, |
| 517 | Direction_p); |
| 518 | if (Ret != kEplSuccessful) { |
| 519 | goto Exit; |
| 520 | } |
| 521 | } |
| 522 | // access to device part |
| 523 | pObdEntry = EPL_MCO_GLB_VAR(m_ObdInitParam.m_pDevicePart); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 524 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 525 | if (((ObdPart_p & kEplObdPartDev) != 0) && (pObdEntry != NULL)) { |
| 526 | fPartFount = TRUE; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 527 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 528 | Ret = EplObdAccessOdPartIntern(EPL_MCO_INSTANCE_PTR_ |
| 529 | kEplObdPartDev, pObdEntry, |
| 530 | Direction_p); |
| 531 | if (Ret != kEplSuccessful) { |
| 532 | goto Exit; |
| 533 | } |
| 534 | } |
| 535 | #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE)) |
| 536 | { |
| 537 | // access to user part |
| 538 | pObdEntry = EPL_MCO_GLB_VAR(m_ObdInitParam.m_pUserPart); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 539 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 540 | if (((ObdPart_p & kEplObdPartUsr) != 0) && (pObdEntry != NULL)) { |
| 541 | fPartFount = TRUE; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 542 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 543 | Ret = EplObdAccessOdPartIntern(EPL_MCO_INSTANCE_PTR_ |
| 544 | kEplObdPartUsr, |
| 545 | pObdEntry, Direction_p); |
| 546 | if (Ret != kEplSuccessful) { |
| 547 | goto Exit; |
| 548 | } |
| 549 | } |
| 550 | } |
| 551 | #endif |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 552 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 553 | // no access to an OD part was done? illegal OD part was specified! |
| 554 | if (fPartFount == FALSE) { |
| 555 | Ret = kEplObdIllegalPart; |
| 556 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 557 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 558 | Exit: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 559 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 560 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 561 | |
| 562 | } |
| 563 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 564 | //--------------------------------------------------------------------------- |
| 565 | // |
| 566 | // Function: EplObdDefineVar() |
| 567 | // |
| 568 | // Description: defines a variable in OD |
| 569 | // |
| 570 | // Parameters: pEplVarParam_p |
| 571 | // |
| 572 | // Return: tEplKernel |
| 573 | // |
| 574 | // State: |
| 575 | // |
| 576 | //--------------------------------------------------------------------------- |
| 577 | |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 578 | tEplKernel EplObdDefineVar(EPL_MCO_DECL_INSTANCE_PTR_ tEplVarParam *pVarParam_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 579 | { |
| 580 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 581 | tEplKernel Ret; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 582 | tEplObdVarEntry *pVarEntry; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 583 | tEplVarParamValid VarValid; |
| 584 | tEplObdSubEntryPtr pSubindexEntry; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 585 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 586 | // check for all API function if instance is valid |
| 587 | EPL_MCO_CHECK_INSTANCE_STATE(); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 588 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 589 | ASSERT(pVarParam_p != NULL); // is not allowed to be NULL |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 590 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 591 | // get address of subindex entry |
| 592 | Ret = EplObdGetEntry(EPL_MCO_INSTANCE_PTR_ |
| 593 | pVarParam_p->m_uiIndex, |
| 594 | pVarParam_p->m_uiSubindex, NULL, &pSubindexEntry); |
| 595 | if (Ret != kEplSuccessful) { |
| 596 | goto Exit; |
| 597 | } |
| 598 | // get var entry |
| 599 | Ret = EplObdGetVarEntry(pSubindexEntry, &pVarEntry); |
| 600 | if (Ret != kEplSuccessful) { |
| 601 | goto Exit; |
| 602 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 603 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 604 | VarValid = pVarParam_p->m_ValidFlag; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 605 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 606 | // copy only this values, which valid flag is set |
| 607 | if ((VarValid & kVarValidSize) != 0) { |
| 608 | if (pSubindexEntry->m_Type != kEplObdTypDomain) { |
| 609 | tEplObdSize DataSize; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 610 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 611 | // check passed size parameter |
| 612 | DataSize = EplObdGetObjectSize(pSubindexEntry); |
| 613 | if (DataSize != pVarParam_p->m_Size) { // size of variable does not match |
| 614 | Ret = kEplObdValueLengthError; |
| 615 | goto Exit; |
| 616 | } |
| 617 | } else { // size can be set only for objects of type DOMAIN |
| 618 | pVarEntry->m_Size = pVarParam_p->m_Size; |
| 619 | } |
| 620 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 621 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 622 | if ((VarValid & kVarValidData) != 0) { |
| 623 | pVarEntry->m_pData = pVarParam_p->m_pData; |
| 624 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 625 | /* |
| 626 | #if (EPL_PDO_USE_STATIC_MAPPING == FALSE) |
| 627 | { |
| 628 | if ((VarValid & kVarValidCallback) != 0) |
| 629 | { |
| 630 | pVarEntry->m_fpCallback = pVarParam_p->m_fpCallback; |
| 631 | } |
| 632 | |
| 633 | if ((VarValid & kVarValidArg) != 0) |
| 634 | { |
| 635 | pVarEntry->m_pArg = pVarParam_p->m_pArg; |
| 636 | } |
| 637 | } |
| 638 | #endif |
| 639 | */ |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 640 | // Ret is already set to kEplSuccessful from ObdGetVarIntern() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 641 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 642 | Exit: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 643 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 644 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 645 | |
| 646 | } |
| 647 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 648 | //--------------------------------------------------------------------------- |
| 649 | // |
| 650 | // Function: EplObdGetObjectDataPtr() |
| 651 | // |
| 652 | // Description: It returnes the current data pointer. But if object is an |
| 653 | // constant object it returnes the default pointer. |
| 654 | // |
| 655 | // Parameters: uiIndex_p = Index of the entry |
| 656 | // uiSubindex_p = Subindex of the entry |
| 657 | // |
| 658 | // Return: void * = pointer to object data |
| 659 | // |
| 660 | // State: |
| 661 | // |
| 662 | //--------------------------------------------------------------------------- |
| 663 | |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 664 | void *EplObdGetObjectDataPtr(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p, |
| 665 | unsigned int uiSubIndex_p) |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 666 | { |
| 667 | tEplKernel Ret; |
| 668 | void *pData; |
| 669 | tEplObdEntryPtr pObdEntry; |
| 670 | tEplObdSubEntryPtr pObdSubEntry; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 671 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 672 | // get pointer to index structure |
| 673 | Ret = EplObdGetIndexIntern(&EPL_MCO_GLB_VAR(m_ObdInitParam), |
| 674 | uiIndex_p, &pObdEntry); |
| 675 | if (Ret != kEplSuccessful) { |
| 676 | pData = NULL; |
| 677 | goto Exit; |
| 678 | } |
| 679 | // get pointer to subindex structure |
| 680 | Ret = EplObdGetSubindexIntern(pObdEntry, uiSubIndex_p, &pObdSubEntry); |
| 681 | if (Ret != kEplSuccessful) { |
| 682 | pData = NULL; |
| 683 | goto Exit; |
| 684 | } |
| 685 | // get Datapointer |
| 686 | pData = EplObdGetObjectDataPtrIntern(pObdSubEntry); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 687 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 688 | Exit: |
| 689 | return pData; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 690 | |
| 691 | } |
| 692 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 693 | #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE)) |
| 694 | |
| 695 | //--------------------------------------------------------------------------- |
| 696 | // |
| 697 | // Function: EplObdRegisterUserOd() |
| 698 | // |
| 699 | // Description: function registers the user OD |
| 700 | // |
| 701 | // Parameters: pUserOd_p =pointer to user ODd |
| 702 | // |
| 703 | // Return: tEplKernel = errorcode |
| 704 | // |
| 705 | // State: |
| 706 | // |
| 707 | //--------------------------------------------------------------------------- |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 708 | tEplKernel EplObdRegisterUserOd(EPL_MCO_DECL_INSTANCE_PTR_ tEplObdEntryPtr pUserOd_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 709 | { |
| 710 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 711 | EPL_MCO_CHECK_INSTANCE_STATE(); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 712 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 713 | EPL_MCO_GLB_VAR(m_ObdInitParam.m_pUserPart) = pUserOd_p; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 714 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 715 | return kEplSuccessful; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 716 | |
| 717 | } |
| 718 | |
| 719 | #endif |
| 720 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 721 | //--------------------------------------------------------------------------- |
| 722 | // |
| 723 | // Function: EplObdInitVarEntry() |
| 724 | // |
| 725 | // Description: function to initialize VarEntry dependened on object type |
| 726 | // |
| 727 | // Parameters: pVarEntry_p = pointer to var entry structure |
| 728 | // Type_p = object type |
| 729 | // ObdSize_p = size of object data |
| 730 | // |
| 731 | // Returns: none |
| 732 | // |
| 733 | // State: |
| 734 | // |
| 735 | //--------------------------------------------------------------------------- |
| 736 | |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 737 | void EplObdInitVarEntry(EPL_MCO_DECL_INSTANCE_PTR_ tEplObdVarEntry *pVarEntry_p, |
| 738 | tEplObdType Type_p, tEplObdSize ObdSize_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 739 | { |
| 740 | /* |
| 741 | #if (EPL_PDO_USE_STATIC_MAPPING == FALSE) |
| 742 | { |
| 743 | // reset pointer to VAR callback and argument |
| 744 | pVarEntry_p->m_fpCallback = NULL; |
| 745 | pVarEntry_p->m_pArg = NULL; |
| 746 | } |
| 747 | #endif |
| 748 | */ |
| 749 | |
| 750 | // 10-dec-2004 r.d.: this function will not be used for strings |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 751 | if ((Type_p == kEplObdTypDomain)) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 752 | // (bType_p == kEplObdTypVString) /* || |
| 753 | // (bType_p == kEplObdTypOString) || |
| 754 | // (bType_p == kEplObdTypUString) */ ) |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 755 | { |
| 756 | // variables which are defined as DOMAIN or VSTRING should not point to |
| 757 | // trash object, because this trash object contains only 8 bytes. DOMAINS or |
| 758 | // STRINGS can be longer. |
| 759 | pVarEntry_p->m_pData = NULL; |
| 760 | pVarEntry_p->m_Size = 0; |
| 761 | } else { |
| 762 | // set address to variable data to trash object |
| 763 | // This prevents an access violation if user forgets to call EplObdDefineVar() |
| 764 | // for this variable but mappes it in a PDO. |
| 765 | pVarEntry_p->m_pData = &abEplObdTrashObject_g[0]; |
| 766 | pVarEntry_p->m_Size = ObdSize_p; |
| 767 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 768 | |
| 769 | } |
| 770 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 771 | //--------------------------------------------------------------------------- |
| 772 | // |
| 773 | // Function: EplObdGetDataSize() |
| 774 | // |
| 775 | // Description: function to initialize VarEntry dependened on object type |
| 776 | // |
| 777 | // gets the data size of an object |
| 778 | // for string objects it returnes the string length |
| 779 | // |
| 780 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ = Instancepointer |
| 781 | // uiIndex_p = Index |
| 782 | // uiSubIndex_p= Subindex |
| 783 | // |
| 784 | // Return: tEplObdSize |
| 785 | // |
| 786 | // State: |
| 787 | // |
| 788 | //--------------------------------------------------------------------------- |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 789 | tEplObdSize EplObdGetDataSize(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p, |
| 790 | unsigned int uiSubIndex_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 791 | { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 792 | tEplKernel Ret; |
| 793 | tEplObdSize ObdSize; |
| 794 | tEplObdEntryPtr pObdEntry; |
| 795 | tEplObdSubEntryPtr pObdSubEntry; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 796 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 797 | // get pointer to index structure |
| 798 | Ret = EplObdGetIndexIntern(&EPL_MCO_GLB_VAR(m_ObdInitParam), |
| 799 | uiIndex_p, &pObdEntry); |
| 800 | if (Ret != kEplSuccessful) { |
| 801 | ObdSize = 0; |
| 802 | goto Exit; |
| 803 | } |
| 804 | // get pointer to subindex structure |
| 805 | Ret = EplObdGetSubindexIntern(pObdEntry, uiSubIndex_p, &pObdSubEntry); |
| 806 | if (Ret != kEplSuccessful) { |
| 807 | ObdSize = 0; |
| 808 | goto Exit; |
| 809 | } |
| 810 | // get size |
| 811 | ObdSize = EplObdGetDataSizeIntern(pObdSubEntry); |
| 812 | Exit: |
| 813 | return ObdSize; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 814 | } |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 815 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 816 | //--------------------------------------------------------------------------- |
| 817 | // |
| 818 | // Function: EplObdGetNodeId() |
| 819 | // |
| 820 | // Description: function returns nodeid from entry 0x1F93 |
| 821 | // |
| 822 | // |
| 823 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR = Instancepointer |
| 824 | // |
| 825 | // Return: unsigned int = Node Id |
| 826 | // |
| 827 | // State: |
| 828 | // |
| 829 | //--------------------------------------------------------------------------- |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 830 | unsigned int EplObdGetNodeId(EPL_MCO_DECL_INSTANCE_PTR) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 831 | { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 832 | tEplKernel Ret; |
| 833 | tEplObdSize ObdSize; |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 834 | u8 bNodeId; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 835 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 836 | bNodeId = 0; |
| 837 | ObdSize = sizeof(bNodeId); |
| 838 | Ret = EplObdReadEntry(EPL_MCO_PTR_INSTANCE_PTR_ |
| 839 | EPL_OBD_NODE_ID_INDEX, |
| 840 | EPL_OBD_NODE_ID_SUBINDEX, &bNodeId, &ObdSize); |
| 841 | if (Ret != kEplSuccessful) { |
| 842 | bNodeId = EPL_C_ADR_INVALID; |
| 843 | goto Exit; |
| 844 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 845 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 846 | Exit: |
| 847 | return (unsigned int)bNodeId; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 848 | |
| 849 | } |
| 850 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 851 | //--------------------------------------------------------------------------- |
| 852 | // |
| 853 | // Function: EplObdSetNodeId() |
| 854 | // |
| 855 | // Description: function sets nodeid in entry 0x1F93 |
| 856 | // |
| 857 | // |
| 858 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ = Instancepointer |
| 859 | // uiNodeId_p = Node Id to set |
| 860 | // NodeIdType_p= Type on which way the Node Id was set |
| 861 | // |
| 862 | // Return: tEplKernel = Errorcode |
| 863 | // |
| 864 | // State: |
| 865 | // |
| 866 | //--------------------------------------------------------------------------- |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 867 | tEplKernel EplObdSetNodeId(EPL_MCO_DECL_PTR_INSTANCE_PTR_ unsigned int uiNodeId_p, |
| 868 | tEplObdNodeIdType NodeIdType_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 869 | { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 870 | tEplKernel Ret; |
| 871 | tEplObdSize ObdSize; |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 872 | u8 fHwBool; |
| 873 | u8 bNodeId; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 874 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 875 | // check Node Id |
| 876 | if (uiNodeId_p == EPL_C_ADR_INVALID) { |
| 877 | Ret = kEplInvalidNodeId; |
| 878 | goto Exit; |
| 879 | } |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 880 | bNodeId = (u8) uiNodeId_p; |
| 881 | ObdSize = sizeof(u8); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 882 | // write NodeId to OD entry |
| 883 | Ret = EplObdWriteEntry(EPL_MCO_PTR_INSTANCE_PTR_ |
| 884 | EPL_OBD_NODE_ID_INDEX, |
| 885 | EPL_OBD_NODE_ID_SUBINDEX, &bNodeId, ObdSize); |
| 886 | if (Ret != kEplSuccessful) { |
| 887 | goto Exit; |
| 888 | } |
| 889 | // set HWBOOL-Flag in Subindex EPL_OBD_NODE_ID_HWBOOL_SUBINDEX |
| 890 | switch (NodeIdType_p) { |
| 891 | // type unknown |
| 892 | case kEplObdNodeIdUnknown: |
| 893 | { |
| 894 | fHwBool = OBD_FALSE; |
| 895 | break; |
| 896 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 897 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 898 | case kEplObdNodeIdSoftware: |
| 899 | { |
| 900 | fHwBool = OBD_FALSE; |
| 901 | break; |
| 902 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 903 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 904 | case kEplObdNodeIdHardware: |
| 905 | { |
| 906 | fHwBool = OBD_TRUE; |
| 907 | break; |
| 908 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 909 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 910 | default: |
| 911 | { |
| 912 | fHwBool = OBD_FALSE; |
| 913 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 914 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 915 | } // end of switch (NodeIdType_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 916 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 917 | // write flag |
| 918 | ObdSize = sizeof(fHwBool); |
| 919 | Ret = EplObdWriteEntry(EPL_MCO_PTR_INSTANCE_PTR |
| 920 | EPL_OBD_NODE_ID_INDEX, |
| 921 | EPL_OBD_NODE_ID_HWBOOL_SUBINDEX, |
| 922 | &fHwBool, ObdSize); |
| 923 | if (Ret != kEplSuccessful) { |
| 924 | goto Exit; |
| 925 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 926 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 927 | Exit: |
| 928 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | //--------------------------------------------------------------------------- |
| 932 | // |
| 933 | // Function: EplObdIsNumerical() |
| 934 | // |
| 935 | // Description: function checks if a entry is numerical or not |
| 936 | // |
| 937 | // |
| 938 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ = Instancepointer |
| 939 | // uiIndex_p = Index |
| 940 | // uiSubIndex_p = Subindex |
| 941 | // pfEntryNumerical_p = pointer to BOOL for returnvalue |
| 942 | // -> TRUE if entry a numerical value |
| 943 | // -> FALSE if entry not a numerical value |
| 944 | // |
| 945 | // Return: tEplKernel = Errorcode |
| 946 | // |
| 947 | // State: |
| 948 | // |
| 949 | //--------------------------------------------------------------------------- |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 950 | tEplKernel EplObdIsNumerical(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p, |
| 951 | unsigned int uiSubIndex_p, |
| 952 | BOOL *pfEntryNumerical_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 953 | { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 954 | tEplKernel Ret; |
| 955 | tEplObdEntryPtr pObdEntry; |
| 956 | tEplObdSubEntryPtr pObdSubEntry; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 957 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 958 | // get pointer to index structure |
| 959 | Ret = EplObdGetIndexIntern(&EPL_MCO_GLB_VAR(m_ObdInitParam), |
| 960 | uiIndex_p, &pObdEntry); |
| 961 | if (Ret != kEplSuccessful) { |
| 962 | goto Exit; |
| 963 | } |
| 964 | // get pointer to subindex structure |
| 965 | Ret = EplObdGetSubindexIntern(pObdEntry, uiSubIndex_p, &pObdSubEntry); |
| 966 | if (Ret != kEplSuccessful) { |
| 967 | goto Exit; |
| 968 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 969 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 970 | Ret = EplObdIsNumericalIntern(pObdSubEntry, pfEntryNumerical_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 971 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 972 | Exit: |
| 973 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 974 | |
| 975 | } |
| 976 | |
| 977 | //--------------------------------------------------------------------------- |
| 978 | // |
| 979 | // Function: EplObdReadEntryToLe() |
| 980 | // |
| 981 | // Description: The function reads an object entry from the byteoder |
| 982 | // of the system to the little endian byteorder for numerical values. |
| 983 | // For other types a normal read will be processed. This is usefull for |
| 984 | // the PDO and SDO module. The application |
| 985 | // can always read the data even if attrib kEplObdAccRead |
| 986 | // is not set. The attrib is only checked up for SDO transfer. |
| 987 | // |
| 988 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ |
| 989 | // uiIndex_p = Index of the OD entry to read |
| 990 | // uiSubIndex_p = Subindex to read |
| 991 | // pDstData_p = pointer to the buffer for data |
| 992 | // Offset_p = offset in data for read access |
| 993 | // pSize_p = IN: Size of the buffer |
| 994 | // OUT: number of readed Bytes |
| 995 | // |
| 996 | // Return: tEplKernel |
| 997 | // |
| 998 | // State: |
| 999 | // |
| 1000 | //--------------------------------------------------------------------------- |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 1001 | tEplKernel EplObdReadEntryToLe(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p, |
| 1002 | unsigned int uiSubIndex_p, |
| 1003 | void *pDstData_p, tEplObdSize *pSize_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1004 | { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1005 | tEplKernel Ret; |
| 1006 | tEplObdEntryPtr pObdEntry; |
| 1007 | tEplObdSubEntryPtr pSubEntry; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1008 | tEplObdCbParam CbParam; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1009 | void *pSrcData; |
| 1010 | tEplObdSize ObdSize; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1011 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1012 | // check for all API function if instance is valid |
| 1013 | EPL_MCO_CHECK_INSTANCE_STATE(); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1014 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1015 | ASSERT(pDstData_p != NULL); |
| 1016 | ASSERT(pSize_p != NULL); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1017 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1018 | // get address of index and subindex entry |
| 1019 | Ret = EplObdGetEntry(EPL_MCO_INSTANCE_PTR_ |
| 1020 | uiIndex_p, uiSubIndex_p, &pObdEntry, &pSubEntry); |
| 1021 | if (Ret != kEplSuccessful) { |
| 1022 | goto Exit; |
| 1023 | } |
| 1024 | // get pointer to object data |
| 1025 | pSrcData = EplObdGetObjectDataPtrIntern(pSubEntry); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1026 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1027 | // check source pointer |
| 1028 | if (pSrcData == NULL) { |
| 1029 | Ret = kEplObdReadViolation; |
| 1030 | goto Exit; |
| 1031 | } |
| 1032 | //------------------------------------------------------------------------ |
| 1033 | // address of source data to structure of callback parameters |
| 1034 | // so callback function can change this data before reading |
| 1035 | CbParam.m_uiIndex = uiIndex_p; |
| 1036 | CbParam.m_uiSubIndex = uiSubIndex_p; |
| 1037 | CbParam.m_pArg = pSrcData; |
| 1038 | CbParam.m_ObdEvent = kEplObdEvPreRead; |
| 1039 | Ret = EplObdCallObjectCallback(EPL_MCO_INSTANCE_PTR_ |
| 1040 | pObdEntry->m_fpCallback, &CbParam); |
| 1041 | if (Ret != kEplSuccessful) { |
| 1042 | goto Exit; |
| 1043 | } |
| 1044 | // get size of data and check if application has reserved enough memory |
| 1045 | ObdSize = EplObdGetDataSizeIntern(pSubEntry); |
| 1046 | // check if offset given and calc correct number of bytes to read |
| 1047 | if (*pSize_p < ObdSize) { |
| 1048 | Ret = kEplObdValueLengthError; |
| 1049 | goto Exit; |
| 1050 | } |
| 1051 | // check if numerical type |
| 1052 | switch (pSubEntry->m_Type) { |
| 1053 | //----------------------------------------------- |
| 1054 | // types without ami |
| 1055 | case kEplObdTypVString: |
| 1056 | case kEplObdTypOString: |
| 1057 | case kEplObdTypDomain: |
| 1058 | default: |
| 1059 | { |
| 1060 | // read value from object |
| 1061 | EPL_MEMCPY(pDstData_p, pSrcData, ObdSize); |
| 1062 | break; |
| 1063 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1064 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1065 | //----------------------------------------------- |
| 1066 | // numerical type which needs ami-write |
| 1067 | // 8 bit or smaller values |
| 1068 | case kEplObdTypBool: |
| 1069 | case kEplObdTypInt8: |
| 1070 | case kEplObdTypUInt8: |
| 1071 | { |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 1072 | AmiSetByteToLe(pDstData_p, *((u8 *) pSrcData)); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1073 | break; |
| 1074 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1075 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1076 | // 16 bit values |
| 1077 | case kEplObdTypInt16: |
| 1078 | case kEplObdTypUInt16: |
| 1079 | { |
Greg Kroah-Hartman | dcf5371 | 2009-03-23 12:57:39 -0700 | [diff] [blame] | 1080 | AmiSetWordToLe(pDstData_p, *((u16 *) pSrcData)); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1081 | break; |
| 1082 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1083 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1084 | // 24 bit values |
| 1085 | case kEplObdTypInt24: |
| 1086 | case kEplObdTypUInt24: |
| 1087 | { |
Greg Kroah-Hartman | d539cfb | 2009-03-23 12:51:37 -0700 | [diff] [blame] | 1088 | AmiSetDword24ToLe(pDstData_p, *((u32 *) pSrcData)); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1089 | break; |
| 1090 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1091 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1092 | // 32 bit values |
| 1093 | case kEplObdTypInt32: |
| 1094 | case kEplObdTypUInt32: |
| 1095 | case kEplObdTypReal32: |
| 1096 | { |
Greg Kroah-Hartman | d539cfb | 2009-03-23 12:51:37 -0700 | [diff] [blame] | 1097 | AmiSetDwordToLe(pDstData_p, *((u32 *) pSrcData)); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1098 | break; |
| 1099 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1100 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1101 | // 40 bit values |
| 1102 | case kEplObdTypInt40: |
| 1103 | case kEplObdTypUInt40: |
| 1104 | { |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1105 | AmiSetQword40ToLe(pDstData_p, *((u64 *) pSrcData)); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1106 | break; |
| 1107 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1108 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1109 | // 48 bit values |
| 1110 | case kEplObdTypInt48: |
| 1111 | case kEplObdTypUInt48: |
| 1112 | { |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1113 | AmiSetQword48ToLe(pDstData_p, *((u64 *) pSrcData)); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1114 | break; |
| 1115 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1116 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1117 | // 56 bit values |
| 1118 | case kEplObdTypInt56: |
| 1119 | case kEplObdTypUInt56: |
| 1120 | { |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1121 | AmiSetQword56ToLe(pDstData_p, *((u64 *) pSrcData)); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1122 | break; |
| 1123 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1124 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1125 | // 64 bit values |
| 1126 | case kEplObdTypInt64: |
| 1127 | case kEplObdTypUInt64: |
| 1128 | case kEplObdTypReal64: |
| 1129 | { |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1130 | AmiSetQword64ToLe(pDstData_p, *((u64 *) pSrcData)); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1131 | break; |
| 1132 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1133 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1134 | // time of day |
| 1135 | case kEplObdTypTimeOfDay: |
| 1136 | case kEplObdTypTimeDiff: |
| 1137 | { |
| 1138 | AmiSetTimeOfDay(pDstData_p, ((tTimeOfDay *) pSrcData)); |
| 1139 | break; |
| 1140 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1141 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1142 | } // end of switch(pSubEntry->m_Type) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1143 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1144 | *pSize_p = ObdSize; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1145 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1146 | // write address of destination data to structure of callback parameters |
| 1147 | // so callback function can change this data after reading |
| 1148 | CbParam.m_pArg = pDstData_p; |
| 1149 | CbParam.m_ObdEvent = kEplObdEvPostRead; |
| 1150 | Ret = EplObdCallObjectCallback(EPL_MCO_INSTANCE_PTR_ |
| 1151 | pObdEntry->m_fpCallback, &CbParam); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1152 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1153 | Exit: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1154 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1155 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1156 | |
| 1157 | } |
| 1158 | |
| 1159 | //--------------------------------------------------------------------------- |
| 1160 | // |
| 1161 | // Function: EplObdWriteEntryFromLe() |
| 1162 | // |
| 1163 | // Description: Function writes data to an OBD entry from a source with |
| 1164 | // little endian byteorder to the od with system specuific |
| 1165 | // byteorder. Not numerical values will only by copied. Strings |
| 1166 | // are stored with added '\0' character. |
| 1167 | // |
| 1168 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ |
| 1169 | // uiIndex_p = Index of the OD entry |
| 1170 | // uiSubIndex_p = Subindex of the OD Entry |
| 1171 | // pSrcData_p = Pointer to the data to write |
| 1172 | // Size_p = Size of the data in Byte |
| 1173 | // |
| 1174 | // Return: tEplKernel = Errorcode |
| 1175 | // |
| 1176 | // |
| 1177 | // State: |
| 1178 | // |
| 1179 | //--------------------------------------------------------------------------- |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 1180 | tEplKernel EplObdWriteEntryFromLe(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p, |
| 1181 | unsigned int uiSubIndex_p, |
| 1182 | void *pSrcData_p, tEplObdSize Size_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1183 | { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1184 | tEplKernel Ret; |
| 1185 | tEplObdEntryPtr pObdEntry; |
| 1186 | tEplObdSubEntryPtr pSubEntry; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1187 | tEplObdCbParam CbParam; |
| 1188 | void *pDstData; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1189 | tEplObdSize ObdSize; |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1190 | u64 qwBuffer; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1191 | void *pBuffer = &qwBuffer; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1192 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1193 | Ret = EplObdWriteEntryPre(EPL_MCO_INSTANCE_PTR_ |
| 1194 | uiIndex_p, |
| 1195 | uiSubIndex_p, |
| 1196 | pSrcData_p, |
| 1197 | &pDstData, |
| 1198 | Size_p, |
| 1199 | &pObdEntry, &pSubEntry, &CbParam, &ObdSize); |
| 1200 | if (Ret != kEplSuccessful) { |
| 1201 | goto Exit; |
| 1202 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1203 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1204 | // check if numerical type |
| 1205 | switch (pSubEntry->m_Type) { |
| 1206 | //----------------------------------------------- |
| 1207 | // types without ami |
| 1208 | default: |
| 1209 | { // do nothing, i.e. use the given source pointer |
| 1210 | pBuffer = pSrcData_p; |
| 1211 | break; |
| 1212 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1213 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1214 | //----------------------------------------------- |
| 1215 | // numerical type which needs ami-write |
| 1216 | // 8 bit or smaller values |
| 1217 | case kEplObdTypBool: |
| 1218 | case kEplObdTypInt8: |
| 1219 | case kEplObdTypUInt8: |
| 1220 | { |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 1221 | *((u8 *) pBuffer) = AmiGetByteFromLe(pSrcData_p); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1222 | break; |
| 1223 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1224 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1225 | // 16 bit values |
| 1226 | case kEplObdTypInt16: |
| 1227 | case kEplObdTypUInt16: |
| 1228 | { |
Greg Kroah-Hartman | dcf5371 | 2009-03-23 12:57:39 -0700 | [diff] [blame] | 1229 | *((u16 *) pBuffer) = AmiGetWordFromLe(pSrcData_p); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1230 | break; |
| 1231 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1232 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1233 | // 24 bit values |
| 1234 | case kEplObdTypInt24: |
| 1235 | case kEplObdTypUInt24: |
| 1236 | { |
Greg Kroah-Hartman | d539cfb | 2009-03-23 12:51:37 -0700 | [diff] [blame] | 1237 | *((u32 *) pBuffer) = AmiGetDword24FromLe(pSrcData_p); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1238 | break; |
| 1239 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1240 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1241 | // 32 bit values |
| 1242 | case kEplObdTypInt32: |
| 1243 | case kEplObdTypUInt32: |
| 1244 | case kEplObdTypReal32: |
| 1245 | { |
Greg Kroah-Hartman | d539cfb | 2009-03-23 12:51:37 -0700 | [diff] [blame] | 1246 | *((u32 *) pBuffer) = AmiGetDwordFromLe(pSrcData_p); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1247 | break; |
| 1248 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1249 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1250 | // 40 bit values |
| 1251 | case kEplObdTypInt40: |
| 1252 | case kEplObdTypUInt40: |
| 1253 | { |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1254 | *((u64 *) pBuffer) = AmiGetQword40FromLe(pSrcData_p); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1255 | break; |
| 1256 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1257 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1258 | // 48 bit values |
| 1259 | case kEplObdTypInt48: |
| 1260 | case kEplObdTypUInt48: |
| 1261 | { |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1262 | *((u64 *) pBuffer) = AmiGetQword48FromLe(pSrcData_p); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1263 | break; |
| 1264 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1265 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1266 | // 56 bit values |
| 1267 | case kEplObdTypInt56: |
| 1268 | case kEplObdTypUInt56: |
| 1269 | { |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1270 | *((u64 *) pBuffer) = AmiGetQword56FromLe(pSrcData_p); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1271 | break; |
| 1272 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1273 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1274 | // 64 bit values |
| 1275 | case kEplObdTypInt64: |
| 1276 | case kEplObdTypUInt64: |
| 1277 | case kEplObdTypReal64: |
| 1278 | { |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1279 | *((u64 *) pBuffer) = AmiGetQword64FromLe(pSrcData_p); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1280 | break; |
| 1281 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1282 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1283 | // time of day |
| 1284 | case kEplObdTypTimeOfDay: |
| 1285 | case kEplObdTypTimeDiff: |
| 1286 | { |
| 1287 | AmiGetTimeOfDay(pBuffer, ((tTimeOfDay *) pSrcData_p)); |
| 1288 | break; |
| 1289 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1290 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1291 | } // end of switch(pSubEntry->m_Type) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1292 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1293 | Ret = EplObdWriteEntryPost(EPL_MCO_INSTANCE_PTR_ |
| 1294 | pObdEntry, |
| 1295 | pSubEntry, |
| 1296 | &CbParam, pBuffer, pDstData, ObdSize); |
| 1297 | if (Ret != kEplSuccessful) { |
| 1298 | goto Exit; |
| 1299 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1300 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1301 | Exit: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1302 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1303 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1304 | |
| 1305 | } |
| 1306 | |
| 1307 | //--------------------------------------------------------------------------- |
| 1308 | // |
| 1309 | // Function: EplObdGetAccessType() |
| 1310 | // |
| 1311 | // Description: Function returns accesstype of the entry |
| 1312 | // |
| 1313 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ |
| 1314 | // uiIndex_p = Index of the OD entry |
| 1315 | // uiSubIndex_p = Subindex of the OD Entry |
| 1316 | // pAccessTyp_p = pointer to buffer to store accesstype |
| 1317 | // |
| 1318 | // Return: tEplKernel = errorcode |
| 1319 | // |
| 1320 | // |
| 1321 | // State: |
| 1322 | // |
| 1323 | //--------------------------------------------------------------------------- |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 1324 | tEplKernel EplObdGetAccessType(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p, |
| 1325 | unsigned int uiSubIndex_p, |
| 1326 | tEplObdAccess *pAccessTyp_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1327 | { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1328 | tEplKernel Ret; |
| 1329 | tEplObdEntryPtr pObdEntry; |
| 1330 | tEplObdSubEntryPtr pObdSubEntry; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1331 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1332 | // get pointer to index structure |
| 1333 | Ret = EplObdGetIndexIntern(&EPL_MCO_GLB_VAR(m_ObdInitParam), |
| 1334 | uiIndex_p, &pObdEntry); |
| 1335 | if (Ret != kEplSuccessful) { |
| 1336 | goto Exit; |
| 1337 | } |
| 1338 | // get pointer to subindex structure |
| 1339 | Ret = EplObdGetSubindexIntern(pObdEntry, uiSubIndex_p, &pObdSubEntry); |
| 1340 | if (Ret != kEplSuccessful) { |
| 1341 | goto Exit; |
| 1342 | } |
| 1343 | // get accessType |
| 1344 | *pAccessTyp_p = pObdSubEntry->m_Access; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1345 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1346 | Exit: |
| 1347 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1348 | } |
| 1349 | |
| 1350 | //--------------------------------------------------------------------------- |
| 1351 | // |
| 1352 | // Function: EplObdSearchVarEntry() |
| 1353 | // |
| 1354 | // Description: gets variable from OD |
| 1355 | // |
| 1356 | // Parameters: uiIndex_p = index of the var entry to search |
| 1357 | // uiSubindex_p = subindex of var entry to search |
| 1358 | // ppVarEntry_p = pointer to the pointer to the varentry |
| 1359 | // |
| 1360 | // Return: tEplKernel |
| 1361 | // |
| 1362 | // State: |
| 1363 | // |
| 1364 | //--------------------------------------------------------------------------- |
| 1365 | |
Greg Kroah-Hartman | d10f469 | 2009-03-23 10:45:12 -0700 | [diff] [blame] | 1366 | tEplKernel EplObdSearchVarEntry(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p, |
| 1367 | unsigned int uiSubindex_p, |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1368 | tEplObdVarEntry **ppVarEntry_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1369 | { |
| 1370 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1371 | tEplKernel Ret; |
| 1372 | tEplObdSubEntryPtr pSubindexEntry; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1373 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1374 | // check for all API function if instance is valid |
| 1375 | EPL_MCO_CHECK_INSTANCE_STATE(); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1376 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1377 | // get address of subindex entry |
| 1378 | Ret = EplObdGetEntry(EPL_MCO_INSTANCE_PTR_ |
| 1379 | uiIndex_p, uiSubindex_p, NULL, &pSubindexEntry); |
| 1380 | if (Ret == kEplSuccessful) { |
| 1381 | // get var entry |
| 1382 | Ret = EplObdGetVarEntry(pSubindexEntry, ppVarEntry_p); |
| 1383 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1384 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1385 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1386 | |
| 1387 | } |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1388 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1389 | //=========================================================================// |
| 1390 | // // |
| 1391 | // P R I V A T E D E F I N I T I O N S // |
| 1392 | // // |
| 1393 | //=========================================================================// |
| 1394 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1395 | EPL_MCO_DECL_INSTANCE_FCT() |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1396 | //--------------------------------------------------------------------------- |
| 1397 | // |
| 1398 | // Function: EplObdCallObjectCallback() |
| 1399 | // |
| 1400 | // Description: calls callback function of an object or of a variable |
| 1401 | // |
| 1402 | // Parameters: fpCallback_p |
| 1403 | // pCbParam_p |
| 1404 | // |
| 1405 | // Return: tEplKernel |
| 1406 | // |
| 1407 | // State: |
| 1408 | // |
| 1409 | //--------------------------------------------------------------------------- |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1410 | static tEplKernel EplObdCallObjectCallback(EPL_MCO_DECL_INSTANCE_PTR_ |
| 1411 | tEplObdCallback fpCallback_p, |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1412 | tEplObdCbParam *pCbParam_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1413 | { |
| 1414 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1415 | tEplKernel Ret; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1416 | tEplObdCallback fpCallback; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1417 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1418 | // check for all API function if instance is valid |
| 1419 | EPL_MCO_CHECK_INSTANCE_STATE(); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1420 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1421 | ASSERT(pCbParam_p != NULL); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1422 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1423 | Ret = kEplSuccessful; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1424 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1425 | // check address of callback function before calling it |
| 1426 | if (fpCallback_p != NULL) { |
| 1427 | // KEIL C51 V6.01 has a bug. |
| 1428 | // Therefore the parameter fpCallback_p has to be copied in local variable fpCallback. |
| 1429 | fpCallback = fpCallback_p; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1430 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1431 | // call callback function for this object |
| 1432 | Ret = fpCallback(EPL_MCO_INSTANCE_PARAM_IDX_() |
| 1433 | pCbParam_p); |
| 1434 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1435 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1436 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1437 | } |
| 1438 | |
| 1439 | //--------------------------------------------------------------------------- |
| 1440 | // |
| 1441 | // Function: EplObdGetDataSizeIntern() |
| 1442 | // |
| 1443 | // Description: gets the data size of an object |
| 1444 | // for string objects it returnes the string length |
| 1445 | // |
| 1446 | // Parameters: pSubIndexEntry_p |
| 1447 | // |
| 1448 | // Return: tEplObdSize |
| 1449 | // |
| 1450 | // State: |
| 1451 | // |
| 1452 | //--------------------------------------------------------------------------- |
| 1453 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1454 | static tEplObdSize EplObdGetDataSizeIntern(tEplObdSubEntryPtr pSubIndexEntry_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1455 | { |
| 1456 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1457 | tEplObdSize DataSize; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1458 | void *pData; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1459 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1460 | // If OD entry is defined by macro EPL_OBD_SUBINDEX_ROM_VSTRING |
| 1461 | // then the current pointer is always NULL. The function |
| 1462 | // returns the length of default string. |
| 1463 | DataSize = EplObdGetObjectSize(pSubIndexEntry_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1464 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1465 | if (pSubIndexEntry_p->m_Type == kEplObdTypVString) { |
| 1466 | // The pointer to current value can be received from EplObdGetObjectCurrentPtr() |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1467 | pData = ((void *)EplObdGetObjectCurrentPtr(pSubIndexEntry_p)); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1468 | if (pData != NULL) { |
| 1469 | DataSize = |
| 1470 | EplObdGetStrLen((void *)pData, DataSize, |
| 1471 | pSubIndexEntry_p->m_Type); |
| 1472 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1473 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1474 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1475 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1476 | return DataSize; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1477 | |
| 1478 | } |
| 1479 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1480 | //--------------------------------------------------------------------------- |
| 1481 | // |
| 1482 | // Function: EplObdGetStrLen() |
| 1483 | // |
| 1484 | // Description: The function calculates the length of string. The '\0' |
| 1485 | // character is included!! |
| 1486 | // |
| 1487 | // Parameters: pObjData_p = pointer to string |
| 1488 | // ObjLen_p = max. length of objectr entry |
| 1489 | // bObjType_p = object type (VSTRING, ...) |
| 1490 | // |
| 1491 | // Returns: string length + 1 |
| 1492 | // |
| 1493 | // State: |
| 1494 | // |
| 1495 | //--------------------------------------------------------------------------- |
| 1496 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1497 | static tEplObdSize EplObdGetStrLen(void *pObjData_p, |
| 1498 | tEplObdSize ObjLen_p, tEplObdType ObjType_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1499 | { |
| 1500 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1501 | tEplObdSize StrLen = 0; |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 1502 | u8 *pbString; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1503 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1504 | if (pObjData_p == NULL) { |
| 1505 | goto Exit; |
| 1506 | } |
| 1507 | //---------------------------------------- |
| 1508 | // Visible String: data format byte |
| 1509 | if (ObjType_p == kEplObdTypVString) { |
| 1510 | pbString = pObjData_p; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1511 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1512 | for (StrLen = 0; StrLen < ObjLen_p; StrLen++) { |
| 1513 | if (*pbString == '\0') { |
| 1514 | StrLen++; |
| 1515 | break; |
| 1516 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1517 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1518 | pbString++; |
| 1519 | } |
| 1520 | } |
| 1521 | //---------------------------------------- |
| 1522 | // other string types ... |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1523 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1524 | Exit: |
| 1525 | return (StrLen); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1526 | |
| 1527 | } |
| 1528 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1529 | #if (EPL_OBD_CHECK_OBJECT_RANGE != FALSE) |
| 1530 | |
| 1531 | //--------------------------------------------------------------------------- |
| 1532 | // |
| 1533 | // Function: EplObdCheckObjectRange() |
| 1534 | // |
| 1535 | // Description: function to check value range of object data |
| 1536 | // |
| 1537 | // NOTICE: The pointer of data (pData_p) must point out to an even address, |
| 1538 | // if ObjType is unequal to kEplObdTypInt8 or kEplObdTypUInt8! But it is |
| 1539 | // always realiced because pointer m_pDefault points always to an |
| 1540 | // array of the SPECIFIED type. |
| 1541 | // |
| 1542 | // Parameters: pSubindexEntry_p |
| 1543 | // pData_p |
| 1544 | // |
| 1545 | // Return: tEplKernel |
| 1546 | // |
| 1547 | // State: |
| 1548 | // |
| 1549 | //--------------------------------------------------------------------------- |
| 1550 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1551 | static tEplKernel EplObdCheckObjectRange(tEplObdSubEntryPtr pSubindexEntry_p, |
| 1552 | void *pData_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1553 | { |
| 1554 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1555 | tEplKernel Ret; |
| 1556 | void *pRangeData; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1557 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1558 | ASSERTMSG(pSubindexEntry_p != NULL, |
| 1559 | "EplObdCheckObjectRange(): no address to subindex struct!\n"); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1560 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1561 | Ret = kEplSuccessful; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1562 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1563 | // check if data range has to be checked |
| 1564 | if ((pSubindexEntry_p->m_Access & kEplObdAccRange) == 0) { |
| 1565 | goto Exit; |
| 1566 | } |
| 1567 | // get address of default data |
| 1568 | pRangeData = pSubindexEntry_p->m_pDefault; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1569 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1570 | // jump to called object type |
| 1571 | switch ((tEplObdType) pSubindexEntry_p->m_Type) { |
| 1572 | // ----------------------------------------------------------------- |
| 1573 | // ObdType kEplObdTypBool will not be checked because there are only |
| 1574 | // two possible values 0 or 1. |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1575 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1576 | // ----------------------------------------------------------------- |
| 1577 | // ObdTypes which has to be check up because numerical values |
| 1578 | case kEplObdTypInt8: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1579 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1580 | // switch to lower limit |
| 1581 | pRangeData = ((tEplObdInteger8 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1582 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1583 | // check if value is to low |
| 1584 | if (*((tEplObdInteger8 *) pData_p) < |
| 1585 | *((tEplObdInteger8 *) pRangeData)) { |
| 1586 | Ret = kEplObdValueTooLow; |
| 1587 | break; |
| 1588 | } |
| 1589 | // switch to higher limit |
| 1590 | pRangeData = ((tEplObdInteger8 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1591 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1592 | // check if value is to high |
| 1593 | if (*((tEplObdInteger8 *) pData_p) > |
| 1594 | *((tEplObdInteger8 *) pRangeData)) { |
| 1595 | Ret = kEplObdValueTooHigh; |
| 1596 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1597 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1598 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1599 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1600 | case kEplObdTypUInt8: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1601 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1602 | // switch to lower limit |
| 1603 | pRangeData = ((tEplObdUnsigned8 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1604 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1605 | // check if value is to low |
| 1606 | if (*((tEplObdUnsigned8 *) pData_p) < |
| 1607 | *((tEplObdUnsigned8 *) pRangeData)) { |
| 1608 | Ret = kEplObdValueTooLow; |
| 1609 | break; |
| 1610 | } |
| 1611 | // switch to higher limit |
| 1612 | pRangeData = ((tEplObdUnsigned8 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1613 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1614 | // check if value is to high |
| 1615 | if (*((tEplObdUnsigned8 *) pData_p) > |
| 1616 | *((tEplObdUnsigned8 *) pRangeData)) { |
| 1617 | Ret = kEplObdValueTooHigh; |
| 1618 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1619 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1620 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1621 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1622 | case kEplObdTypInt16: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1623 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1624 | // switch to lower limit |
| 1625 | pRangeData = ((tEplObdInteger16 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1626 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1627 | // check if value is to low |
| 1628 | if (*((tEplObdInteger16 *) pData_p) < |
| 1629 | *((tEplObdInteger16 *) pRangeData)) { |
| 1630 | Ret = kEplObdValueTooLow; |
| 1631 | break; |
| 1632 | } |
| 1633 | // switch to higher limit |
| 1634 | pRangeData = ((tEplObdInteger16 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1635 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1636 | // check if value is to high |
| 1637 | if (*((tEplObdInteger16 *) pData_p) > |
| 1638 | *((tEplObdInteger16 *) pRangeData)) { |
| 1639 | Ret = kEplObdValueTooHigh; |
| 1640 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1641 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1642 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1643 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1644 | case kEplObdTypUInt16: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1645 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1646 | // switch to lower limit |
| 1647 | pRangeData = ((tEplObdUnsigned16 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1648 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1649 | // check if value is to low |
| 1650 | if (*((tEplObdUnsigned16 *) pData_p) < |
| 1651 | *((tEplObdUnsigned16 *) pRangeData)) { |
| 1652 | Ret = kEplObdValueTooLow; |
| 1653 | break; |
| 1654 | } |
| 1655 | // switch to higher limit |
| 1656 | pRangeData = ((tEplObdUnsigned16 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1657 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1658 | // check if value is to high |
| 1659 | if (*((tEplObdUnsigned16 *) pData_p) > |
| 1660 | *((tEplObdUnsigned16 *) pRangeData)) { |
| 1661 | Ret = kEplObdValueTooHigh; |
| 1662 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1663 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1664 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1665 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1666 | case kEplObdTypInt32: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1667 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1668 | // switch to lower limit |
| 1669 | pRangeData = ((tEplObdInteger32 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1670 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1671 | // check if value is to low |
| 1672 | if (*((tEplObdInteger32 *) pData_p) < |
| 1673 | *((tEplObdInteger32 *) pRangeData)) { |
| 1674 | Ret = kEplObdValueTooLow; |
| 1675 | break; |
| 1676 | } |
| 1677 | // switch to higher limit |
| 1678 | pRangeData = ((tEplObdInteger32 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1679 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1680 | // check if value is to high |
| 1681 | if (*((tEplObdInteger32 *) pData_p) > |
| 1682 | *((tEplObdInteger32 *) pRangeData)) { |
| 1683 | Ret = kEplObdValueTooHigh; |
| 1684 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1685 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1686 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1687 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1688 | case kEplObdTypUInt32: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1689 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1690 | // switch to lower limit |
| 1691 | pRangeData = ((tEplObdUnsigned32 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1692 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1693 | // check if value is to low |
| 1694 | if (*((tEplObdUnsigned32 *) pData_p) < |
| 1695 | *((tEplObdUnsigned32 *) pRangeData)) { |
| 1696 | Ret = kEplObdValueTooLow; |
| 1697 | break; |
| 1698 | } |
| 1699 | // switch to higher limit |
| 1700 | pRangeData = ((tEplObdUnsigned32 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1701 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1702 | // check if value is to high |
| 1703 | if (*((tEplObdUnsigned32 *) pData_p) > |
| 1704 | *((tEplObdUnsigned32 *) pRangeData)) { |
| 1705 | Ret = kEplObdValueTooHigh; |
| 1706 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1707 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1708 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1709 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1710 | case kEplObdTypReal32: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1711 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1712 | // switch to lower limit |
| 1713 | pRangeData = ((tEplObdReal32 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1714 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1715 | // check if value is to low |
| 1716 | if (*((tEplObdReal32 *) pData_p) < |
| 1717 | *((tEplObdReal32 *) pRangeData)) { |
| 1718 | Ret = kEplObdValueTooLow; |
| 1719 | break; |
| 1720 | } |
| 1721 | // switch to higher limit |
| 1722 | pRangeData = ((tEplObdReal32 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1723 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1724 | // check if value is to high |
| 1725 | if (*((tEplObdReal32 *) pData_p) > |
| 1726 | *((tEplObdReal32 *) pRangeData)) { |
| 1727 | Ret = kEplObdValueTooHigh; |
| 1728 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1729 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1730 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1731 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1732 | // ----------------------------------------------------------------- |
| 1733 | case kEplObdTypInt40: |
| 1734 | case kEplObdTypInt48: |
| 1735 | case kEplObdTypInt56: |
| 1736 | case kEplObdTypInt64: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1737 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1738 | // switch to lower limit |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1739 | pRangeData = ((signed u64 *)pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1740 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1741 | // check if value is to low |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1742 | if (*((signed u64 *)pData_p) < *((signed u64 *)pRangeData)) { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1743 | Ret = kEplObdValueTooLow; |
| 1744 | break; |
| 1745 | } |
| 1746 | // switch to higher limit |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1747 | pRangeData = ((signed u64 *)pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1748 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1749 | // check if value is to high |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1750 | if (*((signed u64 *)pData_p) > *((signed u64 *)pRangeData)) { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1751 | Ret = kEplObdValueTooHigh; |
| 1752 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1753 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1754 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1755 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1756 | // ----------------------------------------------------------------- |
| 1757 | case kEplObdTypUInt40: |
| 1758 | case kEplObdTypUInt48: |
| 1759 | case kEplObdTypUInt56: |
| 1760 | case kEplObdTypUInt64: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1761 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1762 | // switch to lower limit |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1763 | pRangeData = ((unsigned u64 *)pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1764 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1765 | // check if value is to low |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1766 | if (*((unsigned u64 *)pData_p) < |
| 1767 | *((unsigned u64 *)pRangeData)) { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1768 | Ret = kEplObdValueTooLow; |
| 1769 | break; |
| 1770 | } |
| 1771 | // switch to higher limit |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1772 | pRangeData = ((unsigned u64 *)pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1773 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1774 | // check if value is to high |
Greg Kroah-Hartman | a5c30d9 | 2009-03-23 12:43:05 -0700 | [diff] [blame] | 1775 | if (*((unsigned u64 *)pData_p) > |
| 1776 | *((unsigned u64 *)pRangeData)) { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1777 | Ret = kEplObdValueTooHigh; |
| 1778 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1779 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1780 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1781 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1782 | // ----------------------------------------------------------------- |
| 1783 | case kEplObdTypReal64: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1784 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1785 | // switch to lower limit |
| 1786 | pRangeData = ((tEplObdReal64 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1787 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1788 | // check if value is to low |
| 1789 | if (*((tEplObdReal64 *) pData_p) < |
| 1790 | *((tEplObdReal64 *) pRangeData)) { |
| 1791 | Ret = kEplObdValueTooLow; |
| 1792 | break; |
| 1793 | } |
| 1794 | // switch to higher limit |
| 1795 | pRangeData = ((tEplObdReal64 *) pRangeData) + 1; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1796 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1797 | // check if value is to high |
| 1798 | if (*((tEplObdReal64 *) pData_p) > |
| 1799 | *((tEplObdReal64 *) pRangeData)) { |
| 1800 | Ret = kEplObdValueTooHigh; |
| 1801 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1802 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1803 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1804 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1805 | // ----------------------------------------------------------------- |
| 1806 | case kEplObdTypTimeOfDay: |
| 1807 | case kEplObdTypTimeDiff: |
| 1808 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1809 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1810 | // ----------------------------------------------------------------- |
| 1811 | // ObdTypes kEplObdTypXString and kEplObdTypDomain can not be checkt because |
| 1812 | // they have no numerical value. |
| 1813 | default: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1814 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1815 | Ret = kEplObdUnknownObjectType; |
| 1816 | break; |
| 1817 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1818 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1819 | Exit: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1820 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1821 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1822 | |
| 1823 | } |
| 1824 | #endif // (EPL_OBD_CHECK_OBJECT_RANGE != FALSE) |
| 1825 | |
| 1826 | //--------------------------------------------------------------------------- |
| 1827 | // |
| 1828 | // Function: EplObdWriteEntryPre() |
| 1829 | // |
| 1830 | // Description: Function prepares write of data to an OBD entry. Strings |
| 1831 | // are stored with added '\0' character. |
| 1832 | // |
| 1833 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ |
| 1834 | // uiIndex_p = Index of the OD entry |
| 1835 | // uiSubIndex_p = Subindex of the OD Entry |
| 1836 | // pSrcData_p = Pointer to the data to write |
| 1837 | // Size_p = Size of the data in Byte |
| 1838 | // |
| 1839 | // Return: tEplKernel = Errorcode |
| 1840 | // |
| 1841 | // |
| 1842 | // State: |
| 1843 | // |
| 1844 | //--------------------------------------------------------------------------- |
| 1845 | |
Greg Kroah-Hartman | d10f469 | 2009-03-23 10:45:12 -0700 | [diff] [blame] | 1846 | static tEplKernel EplObdWriteEntryPre(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p, |
| 1847 | unsigned int uiSubIndex_p, |
| 1848 | void *pSrcData_p, |
| 1849 | void **ppDstData_p, |
| 1850 | tEplObdSize Size_p, |
| 1851 | tEplObdEntryPtr *ppObdEntry_p, |
| 1852 | tEplObdSubEntryPtr *ppSubEntry_p, |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1853 | tEplObdCbParam *pCbParam_p, |
Greg Kroah-Hartman | d10f469 | 2009-03-23 10:45:12 -0700 | [diff] [blame] | 1854 | tEplObdSize *pObdSize_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1855 | { |
| 1856 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1857 | tEplKernel Ret; |
| 1858 | tEplObdEntryPtr pObdEntry; |
| 1859 | tEplObdSubEntryPtr pSubEntry; |
| 1860 | tEplObdAccess Access; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1861 | void *pDstData; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1862 | tEplObdSize ObdSize; |
| 1863 | BOOL fEntryNumerical; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1864 | |
| 1865 | #if (EPL_OBD_USE_STRING_DOMAIN_IN_RAM != FALSE) |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1866 | tEplObdVStringDomain MemVStringDomain; |
| 1867 | void *pCurrData; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1868 | #endif |
| 1869 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1870 | // check for all API function if instance is valid |
| 1871 | EPL_MCO_CHECK_INSTANCE_STATE(); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1872 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1873 | ASSERT(pSrcData_p != NULL); // should never be NULL |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1874 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1875 | //------------------------------------------------------------------------ |
| 1876 | // get address of index and subindex entry |
| 1877 | Ret = EplObdGetEntry(EPL_MCO_INSTANCE_PTR_ |
| 1878 | uiIndex_p, uiSubIndex_p, &pObdEntry, &pSubEntry); |
| 1879 | if (Ret != kEplSuccessful) { |
| 1880 | goto Exit; |
| 1881 | } |
| 1882 | // get pointer to object data |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1883 | pDstData = (void *)EplObdGetObjectDataPtrIntern(pSubEntry); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1884 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1885 | Access = (tEplObdAccess) pSubEntry->m_Access; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1886 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1887 | // check access for write |
| 1888 | // access violation if adress to current value is NULL |
| 1889 | if (((Access & kEplObdAccConst) != 0) || (pDstData == NULL)) { |
| 1890 | Ret = kEplObdAccessViolation; |
| 1891 | goto Exit; |
| 1892 | } |
| 1893 | //------------------------------------------------------------------------ |
| 1894 | // get size of object |
| 1895 | // -as ObdSize = ObdGetObjectSize (pSubEntry); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1896 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1897 | //------------------------------------------------------------------------ |
| 1898 | // To use the same callback function for ObdWriteEntry as well as for |
| 1899 | // an SDO download call at first (kEplObdEvPre...) the callback function |
| 1900 | // with the argument pointer to object size. |
| 1901 | pCbParam_p->m_uiIndex = uiIndex_p; |
| 1902 | pCbParam_p->m_uiSubIndex = uiSubIndex_p; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1903 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1904 | // Because object size and object pointer are |
| 1905 | // adapted by user callback function, re-read |
| 1906 | // this values. |
| 1907 | ObdSize = EplObdGetObjectSize(pSubEntry); |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1908 | pDstData = (void *)EplObdGetObjectDataPtrIntern(pSubEntry); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1909 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1910 | // 09-dec-2004 r.d.: |
| 1911 | // Function EplObdWriteEntry() calls new event kEplObdEvWrStringDomain |
| 1912 | // for String or Domain which lets called module directly change |
| 1913 | // the data pointer or size. This prevents a recursive call to |
| 1914 | // the callback function if it calls EplObdGetEntry(). |
| 1915 | #if (EPL_OBD_USE_STRING_DOMAIN_IN_RAM != FALSE) |
| 1916 | if ((pSubEntry->m_Type == kEplObdTypVString) || |
| 1917 | (pSubEntry->m_Type == kEplObdTypDomain) || |
| 1918 | (pSubEntry->m_Type == kEplObdTypOString)) { |
| 1919 | if (pSubEntry->m_Type == kEplObdTypVString) { |
| 1920 | // reserve one byte for 0-termination |
| 1921 | // -as ObdSize -= 1; |
| 1922 | Size_p += 1; |
| 1923 | } |
| 1924 | // fill out new arg-struct |
| 1925 | MemVStringDomain.m_DownloadSize = Size_p; |
| 1926 | MemVStringDomain.m_ObjSize = ObdSize; |
| 1927 | MemVStringDomain.m_pData = pDstData; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1928 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1929 | pCbParam_p->m_ObdEvent = kEplObdEvWrStringDomain; |
| 1930 | pCbParam_p->m_pArg = &MemVStringDomain; |
| 1931 | // call user callback |
| 1932 | Ret = EplObdCallObjectCallback(EPL_MCO_INSTANCE_PTR_ |
| 1933 | pObdEntry->m_fpCallback, |
| 1934 | pCbParam_p); |
| 1935 | if (Ret != kEplSuccessful) { |
| 1936 | goto Exit; |
| 1937 | } |
| 1938 | // write back new settings |
| 1939 | pCurrData = pSubEntry->m_pCurrent; |
| 1940 | if ((pSubEntry->m_Type == kEplObdTypVString) |
| 1941 | || (pSubEntry->m_Type == kEplObdTypOString)) { |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1942 | ((tEplObdVString *)pCurrData)->m_Size = MemVStringDomain.m_ObjSize; |
| 1943 | ((tEplObdVString *)pCurrData)->m_pString = MemVStringDomain.m_pData; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1944 | } else // if (pSdosTableEntry_p->m_bObjType == kEplObdTypDomain) |
| 1945 | { |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1946 | ((tEplObdVarEntry *)pCurrData)->m_Size = MemVStringDomain.m_ObjSize; |
| 1947 | ((tEplObdVarEntry *)pCurrData)->m_pData = (void *)MemVStringDomain.m_pData; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1948 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1949 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1950 | // Because object size and object pointer are |
| 1951 | // adapted by user callback function, re-read |
| 1952 | // this values. |
| 1953 | ObdSize = MemVStringDomain.m_ObjSize; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1954 | pDstData = (void *)MemVStringDomain.m_pData; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1955 | } |
| 1956 | #endif //#if (OBD_USE_STRING_DOMAIN_IN_RAM != FALSE) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1957 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1958 | // 07-dec-2004 r.d.: size from application is needed because callback function can change the object size |
| 1959 | // -as 16.11.04 CbParam.m_pArg = &ObdSize; |
| 1960 | // 09-dec-2004 r.d.: CbParam.m_pArg = &Size_p; |
| 1961 | pCbParam_p->m_pArg = &ObdSize; |
| 1962 | pCbParam_p->m_ObdEvent = kEplObdEvInitWrite; |
| 1963 | Ret = EplObdCallObjectCallback(EPL_MCO_INSTANCE_PTR_ |
| 1964 | pObdEntry->m_fpCallback, pCbParam_p); |
| 1965 | if (Ret != kEplSuccessful) { |
| 1966 | goto Exit; |
| 1967 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1968 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1969 | if (Size_p > ObdSize) { |
| 1970 | Ret = kEplObdValueLengthError; |
| 1971 | goto Exit; |
| 1972 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1973 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1974 | if (pSubEntry->m_Type == kEplObdTypVString) { |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 1975 | if (((char *)pSrcData_p)[Size_p - 1] == '\0') { // last byte of source string contains null character |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1976 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1977 | // reserve one byte in destination for 0-termination |
| 1978 | Size_p -= 1; |
| 1979 | } else if (Size_p >= ObdSize) { // source string is not 0-terminated |
| 1980 | // and destination buffer is too short |
| 1981 | Ret = kEplObdValueLengthError; |
| 1982 | goto Exit; |
| 1983 | } |
| 1984 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1985 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1986 | Ret = EplObdIsNumericalIntern(pSubEntry, &fEntryNumerical); |
| 1987 | if (Ret != kEplSuccessful) { |
| 1988 | goto Exit; |
| 1989 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1990 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 1991 | if ((fEntryNumerical != FALSE) |
| 1992 | && (Size_p != ObdSize)) { |
| 1993 | // type is numerical, therefor size has to fit, but it does not. |
| 1994 | Ret = kEplObdValueLengthError; |
| 1995 | goto Exit; |
| 1996 | } |
| 1997 | // use given size, because non-numerical objects can be written with shorter values |
| 1998 | ObdSize = Size_p; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 1999 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2000 | // set output parameters |
| 2001 | *pObdSize_p = ObdSize; |
| 2002 | *ppObdEntry_p = pObdEntry; |
| 2003 | *ppSubEntry_p = pSubEntry; |
| 2004 | *ppDstData_p = pDstData; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2005 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2006 | // all checks are done |
| 2007 | // the caller may now convert the numerial source value to platform byte order in a temporary buffer |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2008 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2009 | Exit: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2010 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2011 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2012 | |
| 2013 | } |
| 2014 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2015 | //--------------------------------------------------------------------------- |
| 2016 | // |
| 2017 | // Function: EplObdWriteEntryPost() |
| 2018 | // |
| 2019 | // Description: Function finishes write of data to an OBD entry. Strings |
| 2020 | // are stored with added '\0' character. |
| 2021 | // |
| 2022 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ |
| 2023 | // uiIndex_p = Index of the OD entry |
| 2024 | // uiSubIndex_p = Subindex of the OD Entry |
| 2025 | // pSrcData_p = Pointer to the data to write |
| 2026 | // Size_p = Size of the data in Byte |
| 2027 | // |
| 2028 | // Return: tEplKernel = Errorcode |
| 2029 | // |
| 2030 | // |
| 2031 | // State: |
| 2032 | // |
| 2033 | //--------------------------------------------------------------------------- |
| 2034 | |
Greg Kroah-Hartman | d10f469 | 2009-03-23 10:45:12 -0700 | [diff] [blame] | 2035 | static tEplKernel EplObdWriteEntryPost(EPL_MCO_DECL_INSTANCE_PTR_ tEplObdEntryPtr pObdEntry_p, |
| 2036 | tEplObdSubEntryPtr pSubEntry_p, |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2037 | tEplObdCbParam *pCbParam_p, |
Greg Kroah-Hartman | d10f469 | 2009-03-23 10:45:12 -0700 | [diff] [blame] | 2038 | void *pSrcData_p, |
| 2039 | void *pDstData_p, |
| 2040 | tEplObdSize ObdSize_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2041 | { |
| 2042 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2043 | tEplKernel Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2044 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2045 | // caller converted the source value to platform byte order |
| 2046 | // now the range of the value may be checked |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2047 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2048 | #if (EPL_OBD_CHECK_OBJECT_RANGE != FALSE) |
| 2049 | { |
| 2050 | // check data range |
| 2051 | Ret = EplObdCheckObjectRange(pSubEntry_p, pSrcData_p); |
| 2052 | if (Ret != kEplSuccessful) { |
| 2053 | goto Exit; |
| 2054 | } |
| 2055 | } |
| 2056 | #endif |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2057 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2058 | // now call user callback function to check value |
| 2059 | // write address of source data to structure of callback parameters |
| 2060 | // so callback function can check this data |
| 2061 | pCbParam_p->m_pArg = pSrcData_p; |
| 2062 | pCbParam_p->m_ObdEvent = kEplObdEvPreWrite; |
| 2063 | Ret = EplObdCallObjectCallback(EPL_MCO_INSTANCE_PTR_ |
| 2064 | pObdEntry_p->m_fpCallback, pCbParam_p); |
| 2065 | if (Ret != kEplSuccessful) { |
| 2066 | goto Exit; |
| 2067 | } |
| 2068 | // copy object data to OBD |
| 2069 | EPL_MEMCPY(pDstData_p, pSrcData_p, ObdSize_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2070 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2071 | // terminate string with 0 |
| 2072 | if (pSubEntry_p->m_Type == kEplObdTypVString) { |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2073 | ((char *)pDstData_p)[ObdSize_p] = '\0'; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2074 | } |
| 2075 | // write address of destination to structure of callback parameters |
| 2076 | // so callback function can change data subsequently |
| 2077 | pCbParam_p->m_pArg = pDstData_p; |
| 2078 | pCbParam_p->m_ObdEvent = kEplObdEvPostWrite; |
| 2079 | Ret = EplObdCallObjectCallback(EPL_MCO_INSTANCE_PTR_ |
| 2080 | pObdEntry_p->m_fpCallback, pCbParam_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2081 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2082 | Exit: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2083 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2084 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2085 | |
| 2086 | } |
| 2087 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2088 | //--------------------------------------------------------------------------- |
| 2089 | // |
| 2090 | // Function: EplObdGetObjectSize() |
| 2091 | // |
| 2092 | // Description: function to get size of object |
Greg Kroah-Hartman | dcf5371 | 2009-03-23 12:57:39 -0700 | [diff] [blame] | 2093 | // The function determines if an object type an fixed data type (u8, u16, ...) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2094 | // or non fixed object (string, domain). This information is used to decide |
| 2095 | // if download data are stored temporary or not. For objects with fixed data length |
| 2096 | // and types a value range checking can process. |
| 2097 | // For strings the function returns the whole object size not the |
| 2098 | // length of string. |
| 2099 | // |
| 2100 | // Parameters: pSubIndexEntry_p |
| 2101 | // |
| 2102 | // Return: tEplObdSize |
| 2103 | // |
| 2104 | // State: |
| 2105 | // |
| 2106 | //--------------------------------------------------------------------------- |
| 2107 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2108 | static tEplObdSize EplObdGetObjectSize(tEplObdSubEntryPtr pSubIndexEntry_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2109 | { |
| 2110 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2111 | tEplObdSize DataSize = 0; |
| 2112 | void *pData; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2113 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2114 | switch (pSubIndexEntry_p->m_Type) { |
| 2115 | // ----------------------------------------------------------------- |
| 2116 | case kEplObdTypBool: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2117 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2118 | DataSize = 1; |
| 2119 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2120 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2121 | // ----------------------------------------------------------------- |
| 2122 | // ObdTypes which has to be check because numerical values |
| 2123 | case kEplObdTypInt8: |
| 2124 | DataSize = sizeof(tEplObdInteger8); |
| 2125 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2126 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2127 | // ----------------------------------------------------------------- |
| 2128 | case kEplObdTypUInt8: |
| 2129 | DataSize = sizeof(tEplObdUnsigned8); |
| 2130 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2131 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2132 | // ----------------------------------------------------------------- |
| 2133 | case kEplObdTypInt16: |
| 2134 | DataSize = sizeof(tEplObdInteger16); |
| 2135 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2136 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2137 | // ----------------------------------------------------------------- |
| 2138 | case kEplObdTypUInt16: |
| 2139 | DataSize = sizeof(tEplObdUnsigned16); |
| 2140 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2141 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2142 | // ----------------------------------------------------------------- |
| 2143 | case kEplObdTypInt32: |
| 2144 | DataSize = sizeof(tEplObdInteger32); |
| 2145 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2146 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2147 | // ----------------------------------------------------------------- |
| 2148 | case kEplObdTypUInt32: |
| 2149 | DataSize = sizeof(tEplObdUnsigned32); |
| 2150 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2151 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2152 | // ----------------------------------------------------------------- |
| 2153 | case kEplObdTypReal32: |
| 2154 | DataSize = sizeof(tEplObdReal32); |
| 2155 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2156 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2157 | // ----------------------------------------------------------------- |
| 2158 | // ObdTypes which has to be not checked because not NUM values |
| 2159 | case kEplObdTypDomain: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2160 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2161 | pData = (void *)pSubIndexEntry_p->m_pCurrent; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2162 | if ((void *)pData != (void *)NULL) { |
| 2163 | DataSize = ((tEplObdVarEntry *) pData)->m_Size; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2164 | } |
| 2165 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2166 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2167 | // ----------------------------------------------------------------- |
| 2168 | case kEplObdTypVString: |
| 2169 | //case kEplObdTypUString: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2170 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2171 | // If OD entry is defined by macro EPL_OBD_SUBINDEX_ROM_VSTRING |
| 2172 | // then the current pointer is always NULL. The function |
| 2173 | // returns the length of default string. |
| 2174 | pData = (void *)pSubIndexEntry_p->m_pCurrent; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2175 | if ((void *)pData != (void *)NULL) { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2176 | // The max. size of strings defined by STRING-Macro is stored in |
| 2177 | // tEplObdVString of current value. |
| 2178 | // (types tEplObdVString, tEplObdOString and tEplObdUString has the same members) |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2179 | DataSize = ((tEplObdVString *) pData)->m_Size; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2180 | } else { |
| 2181 | // The current position is not decleared. The string |
| 2182 | // is located in ROM, therefor use default pointer. |
| 2183 | pData = (void *)pSubIndexEntry_p->m_pDefault; |
Greg Kroah-Hartman | 5d9d5eb | 2009-03-23 12:24:46 -0700 | [diff] [blame] | 2184 | if ((const void *)pData != (const void *)NULL) { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2185 | // The max. size of strings defined by STRING-Macro is stored in |
| 2186 | // tEplObdVString of default value. |
Greg Kroah-Hartman | 5d9d5eb | 2009-03-23 12:24:46 -0700 | [diff] [blame] | 2187 | DataSize = ((const tEplObdVString *)pData)->m_Size; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2188 | } |
| 2189 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2190 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2191 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2192 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2193 | // ----------------------------------------------------------------- |
| 2194 | case kEplObdTypOString: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2195 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2196 | pData = (void *)pSubIndexEntry_p->m_pCurrent; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2197 | if ((void *)pData != (void *)NULL) { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2198 | // The max. size of strings defined by STRING-Macro is stored in |
| 2199 | // tEplObdVString of current value. |
| 2200 | // (types tEplObdVString, tEplObdOString and tEplObdUString has the same members) |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2201 | DataSize = ((tEplObdOString *) pData)->m_Size; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2202 | } else { |
| 2203 | // The current position is not decleared. The string |
| 2204 | // is located in ROM, therefor use default pointer. |
| 2205 | pData = (void *)pSubIndexEntry_p->m_pDefault; |
Greg Kroah-Hartman | 5d9d5eb | 2009-03-23 12:24:46 -0700 | [diff] [blame] | 2206 | if ((const void *)pData != (const void *)NULL) { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2207 | // The max. size of strings defined by STRING-Macro is stored in |
| 2208 | // tEplObdVString of default value. |
Greg Kroah-Hartman | 5d9d5eb | 2009-03-23 12:24:46 -0700 | [diff] [blame] | 2209 | DataSize = ((const tEplObdOString *)pData)->m_Size; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2210 | } |
| 2211 | } |
| 2212 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2213 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2214 | // ----------------------------------------------------------------- |
| 2215 | case kEplObdTypInt24: |
| 2216 | case kEplObdTypUInt24: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2217 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2218 | DataSize = 3; |
| 2219 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2220 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2221 | // ----------------------------------------------------------------- |
| 2222 | case kEplObdTypInt40: |
| 2223 | case kEplObdTypUInt40: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2224 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2225 | DataSize = 5; |
| 2226 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2227 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2228 | // ----------------------------------------------------------------- |
| 2229 | case kEplObdTypInt48: |
| 2230 | case kEplObdTypUInt48: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2231 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2232 | DataSize = 6; |
| 2233 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2234 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2235 | // ----------------------------------------------------------------- |
| 2236 | case kEplObdTypInt56: |
| 2237 | case kEplObdTypUInt56: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2238 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2239 | DataSize = 7; |
| 2240 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2241 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2242 | // ----------------------------------------------------------------- |
| 2243 | case kEplObdTypInt64: |
| 2244 | case kEplObdTypUInt64: |
| 2245 | case kEplObdTypReal64: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2246 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2247 | DataSize = 8; |
| 2248 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2249 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2250 | // ----------------------------------------------------------------- |
| 2251 | case kEplObdTypTimeOfDay: |
| 2252 | case kEplObdTypTimeDiff: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2253 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2254 | DataSize = 6; |
| 2255 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2256 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2257 | // ----------------------------------------------------------------- |
| 2258 | default: |
| 2259 | break; |
| 2260 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2261 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2262 | return DataSize; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2263 | } |
| 2264 | |
| 2265 | //--------------------------------------------------------------------------- |
| 2266 | // |
| 2267 | // Function: EplObdGetObjectDefaultPtr() |
| 2268 | // |
| 2269 | // Description: function to get the default pointer (type specific) |
| 2270 | // |
| 2271 | // Parameters: pSubIndexEntry_p = pointer to subindex structure |
| 2272 | // |
| 2273 | // Returns: (void *) = pointer to default value |
| 2274 | // |
| 2275 | // State: |
| 2276 | // |
| 2277 | //--------------------------------------------------------------------------- |
| 2278 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2279 | static void *EplObdGetObjectDefaultPtr(tEplObdSubEntryPtr pSubIndexEntry_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2280 | { |
| 2281 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2282 | void *pDefault; |
| 2283 | tEplObdType Type; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2284 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2285 | ASSERTMSG(pSubIndexEntry_p != NULL, |
| 2286 | "EplObdGetObjectDefaultPtr(): pointer to SubEntry not valid!\n"); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2287 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2288 | // get address to default data from default pointer |
| 2289 | pDefault = pSubIndexEntry_p->m_pDefault; |
| 2290 | if (pDefault != NULL) { |
| 2291 | // there are some special types, whose default pointer always is NULL or has to get from other structure |
| 2292 | // get type from subindex structure |
| 2293 | Type = pSubIndexEntry_p->m_Type; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2294 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2295 | // check if object type is a string value |
| 2296 | if ((Type == kEplObdTypVString) /* || |
| 2297 | (Type == kEplObdTypUString) */ ) { |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2298 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2299 | // EPL_OBD_SUBINDEX_RAM_VSTRING |
| 2300 | // tEplObdSize m_Size; --> size of default string |
| 2301 | // char * m_pDefString; --> pointer to default string |
| 2302 | // char * m_pString; --> pointer to string in RAM |
| 2303 | // |
| 2304 | pDefault = |
| 2305 | (void *)((tEplObdVString *) pDefault)->m_pString; |
| 2306 | } else if (Type == kEplObdTypOString) { |
| 2307 | pDefault = |
| 2308 | (void *)((tEplObdOString *) pDefault)->m_pString; |
| 2309 | } |
| 2310 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2311 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2312 | return pDefault; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2313 | |
| 2314 | } |
| 2315 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2316 | //--------------------------------------------------------------------------- |
| 2317 | // |
| 2318 | // Function: EplObdGetVarEntry() |
| 2319 | // |
| 2320 | // Description: gets a variable entry of an object |
| 2321 | // |
| 2322 | // Parameters: pSubindexEntry_p |
| 2323 | // ppVarEntry_p |
| 2324 | // |
| 2325 | // Return: tCopKernel |
| 2326 | // |
| 2327 | // State: |
| 2328 | // |
| 2329 | //--------------------------------------------------------------------------- |
| 2330 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2331 | static tEplKernel EplObdGetVarEntry(tEplObdSubEntryPtr pSubindexEntry_p, |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2332 | tEplObdVarEntry **ppVarEntry_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2333 | { |
| 2334 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2335 | tEplKernel Ret = kEplObdVarEntryNotExist; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2336 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2337 | ASSERT(ppVarEntry_p != NULL); // is not allowed to be NULL |
| 2338 | ASSERT(pSubindexEntry_p != NULL); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2339 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2340 | // check VAR-Flag - only this object points to variables |
| 2341 | if ((pSubindexEntry_p->m_Access & kEplObdAccVar) != 0) { |
| 2342 | // check if object is an array |
| 2343 | if ((pSubindexEntry_p->m_Access & kEplObdAccArray) != 0) { |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2344 | *ppVarEntry_p = &((tEplObdVarEntry *)pSubindexEntry_p->m_pCurrent)[pSubindexEntry_p->m_uiSubIndex - 1]; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2345 | } else { |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2346 | *ppVarEntry_p = (tEplObdVarEntry *)pSubindexEntry_p->m_pCurrent; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2347 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2348 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2349 | Ret = kEplSuccessful; |
| 2350 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2351 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2352 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2353 | |
| 2354 | } |
| 2355 | |
| 2356 | //--------------------------------------------------------------------------- |
| 2357 | // |
| 2358 | // Function: EplObdGetEntry() |
| 2359 | // |
| 2360 | // Description: gets a index entry from OD |
| 2361 | // |
| 2362 | // Parameters: uiIndex_p = Index number |
| 2363 | // uiSubindex_p = Subindex number |
| 2364 | // ppObdEntry_p = pointer to the pointer to the entry |
| 2365 | // ppObdSubEntry_p = pointer to the pointer to the subentry |
| 2366 | // |
| 2367 | // Return: tEplKernel |
| 2368 | |
| 2369 | // |
| 2370 | // State: |
| 2371 | // |
| 2372 | //--------------------------------------------------------------------------- |
| 2373 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2374 | static tEplKernel EplObdGetEntry(EPL_MCO_DECL_INSTANCE_PTR_ |
| 2375 | unsigned int uiIndex_p, |
| 2376 | unsigned int uiSubindex_p, |
| 2377 | tEplObdEntryPtr * ppObdEntry_p, |
| 2378 | tEplObdSubEntryPtr * ppObdSubEntry_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2379 | { |
| 2380 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2381 | tEplObdEntryPtr pObdEntry; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2382 | tEplObdCbParam CbParam; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2383 | tEplKernel Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2384 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2385 | // check for all API function if instance is valid |
| 2386 | EPL_MCO_CHECK_INSTANCE_STATE(); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2387 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2388 | //------------------------------------------------------------------------ |
| 2389 | // get address of entry of index |
| 2390 | Ret = |
| 2391 | EplObdGetIndexIntern(&EPL_MCO_GLB_VAR(m_ObdInitParam), uiIndex_p, |
| 2392 | &pObdEntry); |
| 2393 | if (Ret != kEplSuccessful) { |
| 2394 | goto Exit; |
| 2395 | } |
| 2396 | //------------------------------------------------------------------------ |
| 2397 | // get address of entry of subindex |
| 2398 | Ret = EplObdGetSubindexIntern(pObdEntry, uiSubindex_p, ppObdSubEntry_p); |
| 2399 | if (Ret != kEplSuccessful) { |
| 2400 | goto Exit; |
| 2401 | } |
| 2402 | //------------------------------------------------------------------------ |
| 2403 | // call callback function to inform user/stack that an object will be searched |
| 2404 | // if the called module returnes an error then we abort the searching with kEplObdIndexNotExist |
| 2405 | CbParam.m_uiIndex = uiIndex_p; |
| 2406 | CbParam.m_uiSubIndex = uiSubindex_p; |
| 2407 | CbParam.m_pArg = NULL; |
| 2408 | CbParam.m_ObdEvent = kEplObdEvCheckExist; |
| 2409 | Ret = EplObdCallObjectCallback(EPL_MCO_INSTANCE_PTR_ |
| 2410 | pObdEntry->m_fpCallback, &CbParam); |
| 2411 | if (Ret != kEplSuccessful) { |
| 2412 | Ret = kEplObdIndexNotExist; |
| 2413 | goto Exit; |
| 2414 | } |
| 2415 | //------------------------------------------------------------------------ |
| 2416 | // it is allowed to set ppObdEntry_p to NULL |
| 2417 | // if so, no address will be written to calling function |
| 2418 | if (ppObdEntry_p != NULL) { |
| 2419 | *ppObdEntry_p = pObdEntry; |
| 2420 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2421 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2422 | Exit: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2423 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2424 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2425 | |
| 2426 | } |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2427 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2428 | //--------------------------------------------------------------------------- |
| 2429 | // |
| 2430 | // Function: EplObdGetObjectCurrentPtr() |
| 2431 | // |
| 2432 | // Description: function to get Current pointer (type specific) |
| 2433 | // |
| 2434 | // Parameters: pSubIndexEntry_p |
| 2435 | // |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2436 | // Return: void * |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2437 | // |
| 2438 | // State: |
| 2439 | // |
| 2440 | //--------------------------------------------------------------------------- |
| 2441 | |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2442 | static void *EplObdGetObjectCurrentPtr(tEplObdSubEntryPtr pSubIndexEntry_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2443 | { |
| 2444 | |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2445 | void *pData; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2446 | unsigned int uiArrayIndex; |
| 2447 | tEplObdSize Size; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2448 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2449 | pData = pSubIndexEntry_p->m_pCurrent; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2450 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2451 | // check if constant object |
| 2452 | if (pData != NULL) { |
| 2453 | // check if object is an array |
| 2454 | if ((pSubIndexEntry_p->m_Access & kEplObdAccArray) != 0) { |
| 2455 | // calculate correct data pointer |
| 2456 | uiArrayIndex = pSubIndexEntry_p->m_uiSubIndex - 1; |
| 2457 | if ((pSubIndexEntry_p->m_Access & kEplObdAccVar) != 0) { |
| 2458 | Size = sizeof(tEplObdVarEntry); |
| 2459 | } else { |
| 2460 | Size = EplObdGetObjectSize(pSubIndexEntry_p); |
| 2461 | } |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 2462 | pData = ((u8 *) pData) + (Size * uiArrayIndex); |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2463 | } |
| 2464 | // check if VarEntry |
| 2465 | if ((pSubIndexEntry_p->m_Access & kEplObdAccVar) != 0) { |
| 2466 | // The data pointer is stored in VarEntry->pData |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2467 | pData = ((tEplObdVarEntry *) pData)->m_pData; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2468 | } |
| 2469 | // the default pointer is stored for strings in tEplObdVString |
| 2470 | else if ((pSubIndexEntry_p->m_Type == kEplObdTypVString) /* || |
| 2471 | (pSubIndexEntry_p->m_Type == kEplObdTypUString) */ |
| 2472 | ) { |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2473 | pData = (void *)((tEplObdVString *)pData)->m_pString; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2474 | } else if (pSubIndexEntry_p->m_Type == kEplObdTypOString) { |
| 2475 | pData = |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2476 | (void *)((tEplObdOString *)pData)->m_pString; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2477 | } |
| 2478 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2479 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2480 | return pData; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2481 | |
| 2482 | } |
| 2483 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2484 | //--------------------------------------------------------------------------- |
| 2485 | // |
| 2486 | // Function: EplObdGetIndexIntern() |
| 2487 | // |
| 2488 | // Description: gets a index entry from OD |
| 2489 | // |
| 2490 | // Parameters: pInitParam_p |
| 2491 | // uiIndex_p |
| 2492 | // ppObdEntry_p |
| 2493 | // |
| 2494 | // Return: tEplKernel |
| 2495 | // |
| 2496 | // State: |
| 2497 | // |
| 2498 | //--------------------------------------------------------------------------- |
| 2499 | |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2500 | static tEplKernel EplObdGetIndexIntern(tEplObdInitParam *pInitParam_p, |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2501 | unsigned int uiIndex_p, |
| 2502 | tEplObdEntryPtr * ppObdEntry_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2503 | { |
| 2504 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2505 | tEplObdEntryPtr pObdEntry; |
| 2506 | tEplKernel Ret; |
| 2507 | unsigned int uiIndex; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2508 | |
| 2509 | #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE)) |
| 2510 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2511 | unsigned int nLoop; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2512 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2513 | // if user OD is used then objekts also has to be searched in user OD |
| 2514 | // there is less code need if we do this in a loop |
| 2515 | nLoop = 2; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2516 | |
| 2517 | #endif |
| 2518 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2519 | ASSERTMSG(ppObdEntry_p != NULL, |
| 2520 | "EplObdGetIndexIntern(): pointer to index entry is NULL!\n"); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2521 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2522 | Ret = kEplObdIndexNotExist; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2523 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2524 | // get start address of OD part |
| 2525 | // start address depends on object index because |
| 2526 | // object dictionary is divided in 3 parts |
| 2527 | if ((uiIndex_p >= 0x1000) && (uiIndex_p < 0x2000)) { |
| 2528 | pObdEntry = pInitParam_p->m_pPart; |
| 2529 | } else if ((uiIndex_p >= 0x2000) && (uiIndex_p < 0x6000)) { |
| 2530 | pObdEntry = pInitParam_p->m_pManufacturerPart; |
| 2531 | } |
| 2532 | // index range 0xA000 to 0xFFFF is reserved for DSP-405 |
| 2533 | // DS-301 defines that range 0x6000 to 0x9FFF (!!!) is stored if "store" was written to 0x1010/3. |
| 2534 | // Therefore default configuration is OBD_INCLUDE_A000_TO_DEVICE_PART = FALSE. |
| 2535 | // But a CANopen Application which does not implement dynamic OD or user-OD but wants to use static objets 0xA000... |
| 2536 | // should set OBD_INCLUDE_A000_TO_DEVICE_PART to TRUE. |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2537 | |
| 2538 | #if (EPL_OBD_INCLUDE_A000_TO_DEVICE_PART == FALSE) |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2539 | else if ((uiIndex_p >= 0x6000) && (uiIndex_p < 0x9FFF)) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2540 | #else |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2541 | else if ((uiIndex_p >= 0x6000) && (uiIndex_p < 0xFFFF)) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2542 | #endif |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2543 | { |
| 2544 | pObdEntry = pInitParam_p->m_pDevicePart; |
| 2545 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2546 | |
| 2547 | #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE)) |
| 2548 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2549 | // if index does not match in static OD then index only has to be searched in user OD |
| 2550 | else { |
| 2551 | // begin from first entry of user OD part |
| 2552 | pObdEntry = pInitParam_p->m_pUserPart; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2553 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2554 | // no user OD is available |
| 2555 | if (pObdEntry == NULL) { |
| 2556 | goto Exit; |
| 2557 | } |
| 2558 | // loop must only run once |
| 2559 | nLoop = 1; |
| 2560 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2561 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2562 | do { |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2563 | |
| 2564 | #else |
| 2565 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2566 | // no user OD is available |
| 2567 | // so other object can be found in OD |
| 2568 | else { |
| 2569 | Ret = kEplObdIllegalPart; |
| 2570 | goto Exit; |
| 2571 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2572 | |
| 2573 | #endif |
| 2574 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2575 | // note: |
| 2576 | // The end of Index table is marked with m_uiIndex = 0xFFFF. |
| 2577 | // If this function will be called with wIndex_p = 0xFFFF, entry |
| 2578 | // should not be found. Therefor it is important to use |
| 2579 | // while{} instead of do{}while !!! |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2580 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2581 | // get first index of index table |
| 2582 | uiIndex = pObdEntry->m_uiIndex; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2583 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2584 | // search Index in OD part |
| 2585 | while (uiIndex != EPL_OBD_TABLE_INDEX_END) { |
| 2586 | // go to the end of this function if index is found |
| 2587 | if (uiIndex_p == uiIndex) { |
| 2588 | // write address of OD entry to calling function |
| 2589 | *ppObdEntry_p = pObdEntry; |
| 2590 | Ret = kEplSuccessful; |
| 2591 | goto Exit; |
| 2592 | } |
| 2593 | // objects are sorted in OD |
| 2594 | // if the current index in OD is greater than the index which is to search then break loop |
| 2595 | // in this case user OD has to be search too |
| 2596 | if (uiIndex_p < uiIndex) { |
| 2597 | break; |
| 2598 | } |
| 2599 | // next entry in index table |
| 2600 | pObdEntry++; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2601 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2602 | // get next index of index table |
| 2603 | uiIndex = pObdEntry->m_uiIndex; |
| 2604 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2605 | |
| 2606 | #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE)) |
| 2607 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2608 | // begin from first entry of user OD part |
| 2609 | pObdEntry = pInitParam_p->m_pUserPart; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2610 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2611 | // no user OD is available |
| 2612 | if (pObdEntry == NULL) { |
| 2613 | goto Exit; |
| 2614 | } |
| 2615 | // switch next loop for user OD |
| 2616 | nLoop--; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2617 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2618 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2619 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2620 | while (nLoop > 0) ; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2621 | |
| 2622 | #endif |
| 2623 | |
| 2624 | // in this line Index was not found |
| 2625 | |
| 2626 | Exit: |
| 2627 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2628 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2629 | |
| 2630 | } |
| 2631 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2632 | //--------------------------------------------------------------------------- |
| 2633 | // |
| 2634 | // Function: EplObdGetSubindexIntern() |
| 2635 | // |
| 2636 | // Description: gets a subindex entry from a index entry |
| 2637 | // |
| 2638 | // Parameters: pObdEntry_p |
| 2639 | // bSubIndex_p |
| 2640 | // ppObdSubEntry_p |
| 2641 | // |
| 2642 | // Return: tEplKernel |
| 2643 | // |
| 2644 | // State: |
| 2645 | // |
| 2646 | //--------------------------------------------------------------------------- |
| 2647 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2648 | static tEplKernel EplObdGetSubindexIntern(tEplObdEntryPtr pObdEntry_p, |
| 2649 | unsigned int uiSubIndex_p, |
| 2650 | tEplObdSubEntryPtr * ppObdSubEntry_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2651 | { |
| 2652 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2653 | tEplObdSubEntryPtr pSubEntry; |
| 2654 | unsigned int nSubIndexCount; |
| 2655 | tEplKernel Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2656 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2657 | ASSERTMSG(pObdEntry_p != NULL, |
| 2658 | "EplObdGetSubindexIntern(): pointer to index is NULL!\n"); |
| 2659 | ASSERTMSG(ppObdSubEntry_p != NULL, |
| 2660 | "EplObdGetSubindexIntern(): pointer to subindex is NULL!\n"); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2661 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2662 | Ret = kEplObdSubindexNotExist; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2663 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2664 | // get start address of subindex table and count of subindices |
| 2665 | pSubEntry = pObdEntry_p->m_pSubIndex; |
| 2666 | nSubIndexCount = pObdEntry_p->m_uiCount; |
| 2667 | ASSERTMSG((pSubEntry != NULL) && (nSubIndexCount > 0), "ObdGetSubindexIntern(): invalid subindex table within index table!\n"); // should never be NULL |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2668 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2669 | // search subindex in subindex table |
| 2670 | while (nSubIndexCount > 0) { |
| 2671 | // check if array is found |
| 2672 | if ((pSubEntry->m_Access & kEplObdAccArray) != 0) { |
| 2673 | // check if subindex is in range |
| 2674 | if (uiSubIndex_p < pObdEntry_p->m_uiCount) { |
| 2675 | // update subindex number (subindex entry of an array is always in RAM !!!) |
| 2676 | pSubEntry->m_uiSubIndex = uiSubIndex_p; |
| 2677 | *ppObdSubEntry_p = pSubEntry; |
| 2678 | Ret = kEplSuccessful; |
| 2679 | goto Exit; |
| 2680 | } |
| 2681 | } |
| 2682 | // go to the end of this function if subindex is found |
| 2683 | else if (uiSubIndex_p == pSubEntry->m_uiSubIndex) { |
| 2684 | *ppObdSubEntry_p = pSubEntry; |
| 2685 | Ret = kEplSuccessful; |
| 2686 | goto Exit; |
| 2687 | } |
| 2688 | // objects are sorted in OD |
| 2689 | // if the current subindex in OD is greater than the subindex which is to search then break loop |
| 2690 | // in this case user OD has to be search too |
| 2691 | if (uiSubIndex_p < pSubEntry->m_uiSubIndex) { |
| 2692 | break; |
| 2693 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2694 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2695 | pSubEntry++; |
| 2696 | nSubIndexCount--; |
| 2697 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2698 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2699 | // in this line SubIndex was not fount |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2700 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2701 | Exit: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2702 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2703 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2704 | |
| 2705 | } |
| 2706 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2707 | //--------------------------------------------------------------------------- |
| 2708 | // |
| 2709 | // Function: EplObdSetStoreLoadObjCallback() |
| 2710 | // |
| 2711 | // Description: function set address to callbackfunction for command Store and Load |
| 2712 | // |
| 2713 | // Parameters: fpCallback_p |
| 2714 | // |
| 2715 | // Return: tEplKernel |
| 2716 | // |
| 2717 | // State: |
| 2718 | // |
| 2719 | //--------------------------------------------------------------------------- |
| 2720 | #if (EPL_OBD_USE_STORE_RESTORE != FALSE) |
Greg Kroah-Hartman | d9068d6 | 2009-03-23 13:26:29 -0700 | [diff] [blame] | 2721 | tEplKernel EplObdSetStoreLoadObjCallback(EPL_MCO_DECL_INSTANCE_PTR_ tEplObdStoreLoadObjCallback fpCallback_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2722 | { |
| 2723 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2724 | EPL_MCO_CHECK_INSTANCE_STATE(); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2725 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2726 | // set new address of callback function |
| 2727 | EPL_MCO_GLB_VAR(m_fpStoreLoadObjCallback) = fpCallback_p; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2728 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2729 | return kEplSuccessful; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2730 | |
| 2731 | } |
| 2732 | #endif // (EPL_OBD_USE_STORE_RESTORE != FALSE) |
| 2733 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2734 | //--------------------------------------------------------------------------- |
| 2735 | // |
| 2736 | // Function: EplObdAccessOdPartIntern() |
| 2737 | // |
| 2738 | // Description: runs through OD and executes a job |
| 2739 | // |
| 2740 | // Parameters: CurrentOdPart_p |
| 2741 | // pObdEnty_p |
| 2742 | // Direction_p = what is to do (load values from flash or EEPROM, store, ...) |
| 2743 | // |
| 2744 | // Return: tEplKernel |
| 2745 | // |
| 2746 | // State: |
| 2747 | // |
| 2748 | //--------------------------------------------------------------------------- |
| 2749 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2750 | static tEplKernel EplObdAccessOdPartIntern(EPL_MCO_DECL_INSTANCE_PTR_ |
| 2751 | tEplObdPart CurrentOdPart_p, |
| 2752 | tEplObdEntryPtr pObdEnty_p, |
| 2753 | tEplObdDir Direction_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2754 | { |
| 2755 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2756 | tEplObdSubEntryPtr pSubIndex; |
| 2757 | unsigned int nSubIndexCount; |
| 2758 | tEplObdAccess Access; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2759 | void *pDstData; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2760 | void *pDefault; |
| 2761 | tEplObdSize ObjSize; |
| 2762 | tEplKernel Ret; |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2763 | tEplObdCbStoreParam CbStore; |
| 2764 | tEplObdVarEntry *pVarEntry; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2765 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2766 | ASSERT(pObdEnty_p != NULL); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2767 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2768 | Ret = kEplSuccessful; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2769 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2770 | // prepare structure for STORE RESTORE callback function |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 2771 | CbStore.m_bCurrentOdPart = (u8) CurrentOdPart_p; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2772 | CbStore.m_pData = NULL; |
| 2773 | CbStore.m_ObjSize = 0; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2774 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2775 | // command of first action depends on direction to access |
| 2776 | #if (EPL_OBD_USE_STORE_RESTORE != FALSE) |
| 2777 | if (Direction_p == kEplObdDirLoad) { |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 2778 | CbStore.m_bCommand = (u8) kEplObdCommOpenRead; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2779 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2780 | // call callback function for previous command |
| 2781 | Ret = EplObdCallStoreCallback(EPL_MCO_INSTANCE_PTR_ & CbStore); |
| 2782 | if (Ret != kEplSuccessful) { |
| 2783 | goto Exit; |
| 2784 | } |
| 2785 | // set command for index and subindex loop |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 2786 | CbStore.m_bCommand = (u8) kEplObdCommReadObj; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2787 | } else if (Direction_p == kEplObdDirStore) { |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 2788 | CbStore.m_bCommand = (u8) kEplObdCommOpenWrite; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2789 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2790 | // call callback function for previous command |
| 2791 | Ret = EplObdCallStoreCallback(EPL_MCO_INSTANCE_PTR_ & CbStore); |
| 2792 | if (Ret != kEplSuccessful) { |
| 2793 | goto Exit; |
| 2794 | } |
| 2795 | // set command for index and subindex loop |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 2796 | CbStore.m_bCommand = (u8) kEplObdCommWriteObj; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2797 | } |
| 2798 | #endif // (EPL_OBD_USE_STORE_RESTORE != FALSE) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2799 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2800 | // we should not restore the OD values here |
| 2801 | // the next NMT command "Reset Node" or "Reset Communication" resets the OD data |
| 2802 | if (Direction_p != kEplObdDirRestore) { |
| 2803 | // walk through OD part till end is found |
| 2804 | while (pObdEnty_p->m_uiIndex != EPL_OBD_TABLE_INDEX_END) { |
| 2805 | // get address to subindex table and count of subindices |
| 2806 | pSubIndex = pObdEnty_p->m_pSubIndex; |
| 2807 | nSubIndexCount = pObdEnty_p->m_uiCount; |
| 2808 | ASSERT((pSubIndex != NULL) && (nSubIndexCount > 0)); // should never be NULL |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2809 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2810 | // walk through subindex table till all subinices were restored |
| 2811 | while (nSubIndexCount != 0) { |
| 2812 | Access = (tEplObdAccess) pSubIndex->m_Access; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2813 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2814 | // get pointer to current and default data |
| 2815 | pDefault = EplObdGetObjectDefaultPtr(pSubIndex); |
| 2816 | pDstData = EplObdGetObjectCurrentPtr(pSubIndex); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2817 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2818 | // NOTE (for kEplObdTypVString): |
| 2819 | // The function returnes the max. number of bytes for a |
| 2820 | // current string. |
| 2821 | // r.d.: For stings the default-size will be read in other lines following (kEplObdDirInit). |
| 2822 | ObjSize = EplObdGetObjectSize(pSubIndex); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2823 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2824 | // switch direction of OD access |
| 2825 | switch (Direction_p) { |
| 2826 | // -------------------------------------------------------------------------- |
| 2827 | // VarEntry structures has to be initialized |
| 2828 | case kEplObdDirInit: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2829 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2830 | // If VAR-Flag is set, m_pCurrent means not address of data |
| 2831 | // but address of tEplObdVarEntry. Address of data has to be get from |
| 2832 | // this structure. |
| 2833 | if ((Access & kEplObdAccVar) != 0) { |
| 2834 | EplObdGetVarEntry(pSubIndex, |
| 2835 | &pVarEntry); |
| 2836 | EplObdInitVarEntry(pVarEntry, |
| 2837 | pSubIndex-> |
| 2838 | m_Type, |
| 2839 | ObjSize); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2840 | /* |
| 2841 | if ((Access & kEplObdAccArray) == 0) |
| 2842 | { |
| 2843 | EplObdInitVarEntry (pSubIndex->m_pCurrent, pSubIndex->m_Type, ObjSize); |
| 2844 | } |
| 2845 | else |
| 2846 | { |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 2847 | EplObdInitVarEntry ((tEplObdVarEntry *) (((u8 *) pSubIndex->m_pCurrent) + (sizeof (tEplObdVarEntry) * pSubIndex->m_uiSubIndex)), |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2848 | pSubIndex->m_Type, ObjSize); |
| 2849 | } |
| 2850 | */ |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2851 | // at this time no application variable is defined !!! |
| 2852 | // therefore data can not be copied. |
| 2853 | break; |
| 2854 | } else if (pSubIndex->m_Type == |
| 2855 | kEplObdTypVString) { |
| 2856 | // If pointer m_pCurrent is not equal to NULL then the |
| 2857 | // string was defined with EPL_OBD_SUBINDEX_RAM_VSTRING. The current |
| 2858 | // pointer points to struct tEplObdVString located in MEM. |
| 2859 | // The element size includes the max. number of |
| 2860 | // bytes. The element m_pString includes the pointer |
| 2861 | // to string in MEM. The memory location of default string |
| 2862 | // must be copied to memory location of current string. |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2863 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2864 | pDstData = |
| 2865 | pSubIndex->m_pCurrent; |
| 2866 | if (pDstData != NULL) { |
| 2867 | // 08-dec-2004: code optimization !!! |
Greg Kroah-Hartman | 5318487 | 2009-03-23 11:48:19 -0700 | [diff] [blame] | 2868 | // entries ((tEplObdVStringDef*) pSubIndex->m_pDefault)->m_pString |
| 2869 | // and ((tEplObdVStringDef*) pSubIndex->m_pDefault)->m_Size were read |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2870 | // twice. thats not necessary! |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2871 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2872 | // For copying data we have to set the destination pointer to the real RAM string. This |
| 2873 | // pointer to RAM string is located in default string info structure. (translated r.d.) |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2874 | pDstData = (void *)((tEplObdVStringDef*) pSubIndex->m_pDefault)->m_pString; |
Greg Kroah-Hartman | 5318487 | 2009-03-23 11:48:19 -0700 | [diff] [blame] | 2875 | ObjSize = ((tEplObdVStringDef *)pSubIndex->m_pDefault)->m_Size; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2876 | |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2877 | ((tEplObdVString *)pSubIndex->m_pCurrent)->m_pString = pDstData; |
| 2878 | ((tEplObdVString *)pSubIndex->m_pCurrent)->m_Size = ObjSize; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2879 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2880 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2881 | } else if (pSubIndex->m_Type == |
| 2882 | kEplObdTypOString) { |
| 2883 | pDstData = |
| 2884 | pSubIndex->m_pCurrent; |
| 2885 | if (pDstData != NULL) { |
| 2886 | // 08-dec-2004: code optimization !!! |
Greg Kroah-Hartman | 5318487 | 2009-03-23 11:48:19 -0700 | [diff] [blame] | 2887 | // entries ((tEplObdOStringDef*) pSubIndex->m_pDefault)->m_pString |
| 2888 | // and ((tEplObdOStringDef*) pSubIndex->m_pDefault)->m_Size were read |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2889 | // twice. thats not necessary! |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2890 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2891 | // For copying data we have to set the destination pointer to the real RAM string. This |
| 2892 | // pointer to RAM string is located in default string info structure. (translated r.d.) |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2893 | pDstData = (void *)((tEplObdOStringDef *) pSubIndex->m_pDefault)->m_pString; |
Greg Kroah-Hartman | 5318487 | 2009-03-23 11:48:19 -0700 | [diff] [blame] | 2894 | ObjSize = ((tEplObdOStringDef *)pSubIndex->m_pDefault)->m_Size; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2895 | |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 2896 | ((tEplObdOString *)pSubIndex->m_pCurrent)->m_pString = pDstData; |
| 2897 | ((tEplObdOString *)pSubIndex->m_pCurrent)->m_Size = ObjSize; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2898 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2899 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2900 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2901 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2902 | // no break !! because copy of data has to done too. |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2903 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2904 | // -------------------------------------------------------------------------- |
| 2905 | // all objects has to be restored with default values |
| 2906 | case kEplObdDirRestore: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2907 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2908 | // 09-dec-2004 r.d.: optimization! the same code for kEplObdDirRestore and kEplObdDirLoad |
| 2909 | // is replaced to function ObdCopyObjectData() with a new parameter. |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2910 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2911 | // restore object data for init phase |
| 2912 | EplObdCopyObjectData(pDstData, pDefault, |
| 2913 | ObjSize, |
| 2914 | pSubIndex->m_Type); |
| 2915 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2916 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2917 | // -------------------------------------------------------------------------- |
| 2918 | // objects with attribute kEplObdAccStore has to be load from EEPROM or from a file |
| 2919 | case kEplObdDirLoad: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2920 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2921 | // restore object data for init phase |
| 2922 | EplObdCopyObjectData(pDstData, pDefault, |
| 2923 | ObjSize, |
| 2924 | pSubIndex->m_Type); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2925 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2926 | // no break !! because callback function has to be called too. |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2927 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2928 | // -------------------------------------------------------------------------- |
| 2929 | // objects with attribute kEplObdAccStore has to be stored in EEPROM or in a file |
| 2930 | case kEplObdDirStore: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2931 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2932 | // when attribute kEplObdAccStore is set, then call callback function |
| 2933 | #if (EPL_OBD_USE_STORE_RESTORE != FALSE) |
| 2934 | if ((Access & kEplObdAccStore) != 0) { |
| 2935 | // fill out data pointer and size of data |
| 2936 | CbStore.m_pData = pDstData; |
| 2937 | CbStore.m_ObjSize = ObjSize; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2938 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2939 | // call callback function for read or write object |
| 2940 | Ret = |
| 2941 | ObdCallStoreCallback |
| 2942 | (EPL_MCO_INSTANCE_PTR_ & |
| 2943 | CbStore); |
| 2944 | if (Ret != kEplSuccessful) { |
| 2945 | goto Exit; |
| 2946 | } |
| 2947 | } |
| 2948 | #endif // (EPL_OBD_USE_STORE_RESTORE != FALSE) |
| 2949 | break; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2950 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2951 | // -------------------------------------------------------------------------- |
| 2952 | // if OD Builder key has to be checked no access to subindex and data should be made |
| 2953 | case kEplObdDirOBKCheck: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2954 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2955 | // no break !! because we want to break the second loop too. |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2956 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2957 | // -------------------------------------------------------------------------- |
| 2958 | // unknown Direction |
| 2959 | default: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2960 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2961 | // so we can break the second loop earler |
| 2962 | nSubIndexCount = 1; |
| 2963 | break; |
| 2964 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2965 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2966 | nSubIndexCount--; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2967 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2968 | // next subindex entry |
| 2969 | if ((Access & kEplObdAccArray) == 0) { |
| 2970 | pSubIndex++; |
| 2971 | if ((nSubIndexCount > 0) |
| 2972 | && |
| 2973 | ((pSubIndex-> |
| 2974 | m_Access & kEplObdAccArray) != |
| 2975 | 0)) { |
| 2976 | // next subindex points to an array |
| 2977 | // reset subindex number |
| 2978 | pSubIndex->m_uiSubIndex = 1; |
| 2979 | } |
| 2980 | } else { |
| 2981 | if (nSubIndexCount > 0) { |
| 2982 | // next subindex points to an array |
| 2983 | // increment subindex number |
| 2984 | pSubIndex->m_uiSubIndex++; |
| 2985 | } |
| 2986 | } |
| 2987 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2988 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2989 | // next index entry |
| 2990 | pObdEnty_p++; |
| 2991 | } |
| 2992 | } |
| 2993 | // ----------------------------------------------------------------------------------------- |
| 2994 | // command of last action depends on direction to access |
| 2995 | if (Direction_p == kEplObdDirOBKCheck) { |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 2996 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 2997 | goto Exit; |
| 2998 | } |
| 2999 | #if (EPL_OBD_USE_STORE_RESTORE != FALSE) |
| 3000 | else { |
| 3001 | if (Direction_p == kEplObdDirLoad) { |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 3002 | CbStore.m_bCommand = (u8) kEplObdCommCloseRead; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3003 | } else if (Direction_p == kEplObdDirStore) { |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 3004 | CbStore.m_bCommand = (u8) kEplObdCommCloseWrite; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3005 | } else if (Direction_p == kEplObdDirRestore) { |
Greg Kroah-Hartman | 2ed53cf | 2009-03-23 12:36:38 -0700 | [diff] [blame] | 3006 | CbStore.m_bCommand = (u8) kEplObdCommClear; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3007 | } else { |
| 3008 | goto Exit; |
| 3009 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3010 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3011 | // call callback function for last command |
| 3012 | Ret = EplObdCallStoreCallback(EPL_MCO_INSTANCE_PTR_ & CbStore); |
| 3013 | } |
| 3014 | #endif // (EPL_OBD_USE_STORE_RESTORE != FALSE) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3015 | |
| 3016 | // goto Exit; |
| 3017 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3018 | Exit: |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3019 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3020 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3021 | |
| 3022 | } |
| 3023 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3024 | // ---------------------------------------------------------------------------- |
| 3025 | // Function: EplObdCopyObjectData() |
| 3026 | // |
| 3027 | // Description: checks pointers to object data and copy them from source to destination |
| 3028 | // |
| 3029 | // Parameters: pDstData_p = destination pointer |
| 3030 | // pSrcData_p = source pointer |
| 3031 | // ObjSize_p = size of object |
| 3032 | // ObjType_p = |
| 3033 | // |
| 3034 | // Returns: tEplKernel = error code |
| 3035 | // ---------------------------------------------------------------------------- |
| 3036 | |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 3037 | static void EplObdCopyObjectData(void *pDstData_p, |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3038 | void *pSrcData_p, |
| 3039 | tEplObdSize ObjSize_p, tEplObdType ObjType_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3040 | { |
| 3041 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3042 | tEplObdSize StrSize = 0; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3043 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3044 | // it is allowed to set default and current address to NULL (nothing to copy) |
| 3045 | if (pDstData_p != NULL) { |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3046 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3047 | if (ObjType_p == kEplObdTypVString) { |
| 3048 | // The function calculates the really number of characters of string. The |
| 3049 | // object entry size can be bigger as string size of default string. |
| 3050 | // The '\0'-termination is included. A string with no characters has a |
| 3051 | // size of 1. |
| 3052 | StrSize = |
| 3053 | EplObdGetStrLen((void *)pSrcData_p, ObjSize_p, |
| 3054 | kEplObdTypVString); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3055 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3056 | // If the string length is greater than or equal to the entry size in OD then only copy |
| 3057 | // entry size - 1 and always set the '\0'-termination. |
| 3058 | if (StrSize >= ObjSize_p) { |
| 3059 | StrSize = ObjSize_p - 1; |
| 3060 | } |
| 3061 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3062 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3063 | if (pSrcData_p != NULL) { |
| 3064 | // copy data |
| 3065 | EPL_MEMCPY(pDstData_p, pSrcData_p, ObjSize_p); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3066 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3067 | if (ObjType_p == kEplObdTypVString) { |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 3068 | ((char *)pDstData_p)[StrSize] = '\0'; |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3069 | } |
| 3070 | } |
| 3071 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3072 | |
| 3073 | } |
| 3074 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3075 | //--------------------------------------------------------------------------- |
| 3076 | // |
| 3077 | // Function: EplObdIsNumericalIntern() |
| 3078 | // |
| 3079 | // Description: function checks if a entry is numerical or not |
| 3080 | // |
| 3081 | // |
| 3082 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ = Instancepointer |
| 3083 | // uiIndex_p = Index |
| 3084 | // uiSubIndex_p = Subindex |
| 3085 | // pfEntryNumerical_p = pointer to BOOL for returnvalue |
| 3086 | // -> TRUE if entry a numerical value |
| 3087 | // -> FALSE if entry not a numerical value |
| 3088 | // |
| 3089 | // Return: tEplKernel = Errorcode |
| 3090 | // |
| 3091 | // State: |
| 3092 | // |
| 3093 | //--------------------------------------------------------------------------- |
| 3094 | static tEplKernel EplObdIsNumericalIntern(tEplObdSubEntryPtr pObdSubEntry_p, |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3095 | BOOL * pfEntryNumerical_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3096 | { |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3097 | tEplKernel Ret = kEplSuccessful; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3098 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3099 | // get Type |
| 3100 | if ((pObdSubEntry_p->m_Type == kEplObdTypVString) |
| 3101 | || (pObdSubEntry_p->m_Type == kEplObdTypOString) |
| 3102 | || (pObdSubEntry_p->m_Type == kEplObdTypDomain)) { // not numerical types |
| 3103 | *pfEntryNumerical_p = FALSE; |
| 3104 | } else { // numerical types |
| 3105 | *pfEntryNumerical_p = TRUE; |
| 3106 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3107 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3108 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3109 | |
| 3110 | } |
| 3111 | |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3112 | // ------------------------------------------------------------------------- |
| 3113 | // function to classify object type (fixed/non fixed) |
| 3114 | // ------------------------------------------------------------------------- |
| 3115 | |
| 3116 | // ---------------------------------------------------------------------------- |
| 3117 | // Function: EplObdCallStoreCallback() |
| 3118 | // |
| 3119 | // Description: checks address to callback function and calles it when unequal |
| 3120 | // to NULL |
| 3121 | // |
| 3122 | // Parameters: EPL_MCO_DECL_INSTANCE_PTR_ = (instance pointer) |
| 3123 | // pCbStoreParam_p = address to callback parameters |
| 3124 | // |
| 3125 | // Returns: tEplKernel = error code |
| 3126 | // ---------------------------------------------------------------------------- |
| 3127 | #if (EPL_OBD_USE_STORE_RESTORE != FALSE) |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3128 | static tEplKernel EplObdCallStoreCallback(EPL_MCO_DECL_INSTANCE_PTR_ |
Greg Kroah-Hartman | 5e9f6bc | 2009-03-23 12:09:26 -0700 | [diff] [blame] | 3129 | tEplObdCbStoreParam * |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3130 | pCbStoreParam_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3131 | { |
| 3132 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3133 | tEplKernel Ret = kEplSuccessful; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3134 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3135 | ASSERT(pCbStoreParam_p != NULL); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3136 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3137 | // check if function pointer is NULL - if so, no callback should be called |
| 3138 | if (EPL_MCO_GLB_VAR(m_fpStoreLoadObjCallback) != NULL) { |
| 3139 | Ret = |
| 3140 | EPL_MCO_GLB_VAR(m_fpStoreLoadObjCallback) |
| 3141 | (EPL_MCO_INSTANCE_PARAM_IDX_() |
| 3142 | pCbStoreParam_p); |
| 3143 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3144 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3145 | return Ret; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3146 | |
| 3147 | } |
| 3148 | #endif // (EPL_OBD_USE_STORE_RESTORE != FALSE) |
| 3149 | //--------------------------------------------------------------------------- |
| 3150 | // |
| 3151 | // Function: EplObdGetObjectDataPtrIntern() |
| 3152 | // |
| 3153 | // Description: Function gets the data pointer of an object. |
| 3154 | // It returnes the current data pointer. But if object is an |
| 3155 | // constant object it returnes the default pointer. |
| 3156 | // |
| 3157 | // Parameters: pSubindexEntry_p = pointer to subindex entry |
| 3158 | // |
| 3159 | // Return: void * = pointer to object data |
| 3160 | // |
| 3161 | // State: |
| 3162 | // |
| 3163 | //--------------------------------------------------------------------------- |
| 3164 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3165 | void *EplObdGetObjectDataPtrIntern(tEplObdSubEntryPtr pSubindexEntry_p) |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3166 | { |
| 3167 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3168 | void *pData; |
| 3169 | tEplObdAccess Access; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3170 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3171 | ASSERTMSG(pSubindexEntry_p != NULL, |
| 3172 | "EplObdGetObjectDataPtrIntern(): pointer to SubEntry not valid!\n"); |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3173 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3174 | // there are are some objects whose data pointer has to get from other structure |
| 3175 | // get access type for this object |
| 3176 | Access = pSubindexEntry_p->m_Access; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3177 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3178 | // If object has access type = const, |
| 3179 | // for data only exists default values. |
| 3180 | if ((Access & kEplObdAccConst) != 0) { |
| 3181 | // The pointer to defualt value can be received from ObdGetObjectDefaultPtr() |
| 3182 | pData = ((void *)EplObdGetObjectDefaultPtr(pSubindexEntry_p)); |
| 3183 | } else { |
| 3184 | // The pointer to current value can be received from ObdGetObjectCurrentPtr() |
| 3185 | pData = ((void *)EplObdGetObjectCurrentPtr(pSubindexEntry_p)); |
| 3186 | } |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3187 | |
Greg Kroah-Hartman | 833dfbe | 2008-12-19 17:11:52 -0800 | [diff] [blame] | 3188 | return pData; |
Daniel Krueger | 9d7164c | 2008-12-19 11:41:57 -0800 | [diff] [blame] | 3189 | |
| 3190 | } |
| 3191 | #endif // end of #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0) |
| 3192 | // EOF |