Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
epl.c
00001 /******************************************************************************* 00002 ******************************************************************************** 00003 ** ** 00004 ** ABCC Starter Kit version 2.01.01 (2015-12-14) ** 00005 ** ** 00006 ** Delivered with: ** 00007 ** ABCC Driver 4.01.01 (2015-12-14) ** 00008 ** ABP 7.16.01 (2015-10-14) ** 00009 ** */ 00010 /******************************************************************************* 00011 ******************************************************************************** 00012 ** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** 00013 ** ** 00014 ** This code is the property of HMS Industrial Networks AB. ** 00015 ** The source code may not be reproduced, distributed, or used without ** 00016 ** permission. When used together with a product from HMS, permission is ** 00017 ** granted to modify, reproduce and distribute the code in binary form ** 00018 ** without any restrictions. ** 00019 ** ** 00020 ** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** 00021 ** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** 00022 ** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** 00023 ** THAT DEFECTS IN IT CAN BE CORRECTED. ** 00024 ******************************************************************************** 00025 ******************************************************************************** 00026 ** Source file for the Ethernet POWERLINK ABCC Object. 00027 ******************************************************************************** 00028 ******************************************************************************** 00029 */ 00030 00031 #include "abcc_td.h" 00032 #include "abcc.h" 00033 #include "abcc_sys_adapt.h" 00034 #include "abcc_obj_cfg.h" 00035 #include "epl.h" 00036 #include "abp.h" 00037 #include "abp_epl.h" 00038 #include "string.h" 00039 #include "appl_abcc_handler.h" 00040 #include "abcc_port.h" 00041 00042 #if EPL_OBJ_ENABLE 00043 00044 /******************************************************************************* 00045 ** Defines 00046 ******************************************************************************** 00047 */ 00048 00049 /******************************************************************************* 00050 ** Defines 00051 ******************************************************************************** 00052 */ 00053 00054 /*------------------------------------------------------------------------------ 00055 ** Object attribute values 00056 **------------------------------------------------------------------------------ 00057 */ 00058 #define EPL_OA_NAME_VALUE "POWERLINK" 00059 #define EPL_OA_REV_VALUE 1 00060 #define EPL_OA_NUM_INST_VALUE 1 00061 #define EPL_OA_HIGHEST_INST_VALUE 1 00062 00063 /******************************************************************************* 00064 ** Typedefs 00065 ******************************************************************************** 00066 */ 00067 00068 /*------------------------------------------------------------------------------ 00069 ** Structure describing a Powerlink Object. 00070 **------------------------------------------------------------------------------ 00071 */ 00072 typedef struct epl_Object 00073 { 00074 const char* pcName; 00075 UINT8 bRevision; 00076 UINT16 iNumberOfInstances; 00077 UINT16 iHighestInstanceNo; 00078 } 00079 epl_ObjectType; 00080 00081 /******************************************************************************* 00082 ** Private Globals 00083 ******************************************************************************** 00084 */ 00085 00086 static const epl_ObjectType epl_sObject = 00087 { 00088 EPL_OA_NAME_VALUE, /* Name. */ 00089 EPL_OA_REV_VALUE, /* Revision. */ 00090 EPL_OA_NUM_INST_VALUE, /* Number of instances. */ 00091 EPL_OA_HIGHEST_INST_VALUE /* Highest instance number. */ 00092 }; 00093 00094 /******************************************************************************* 00095 ** Private Services 00096 ******************************************************************************** 00097 */ 00098 00099 /*------------------------------------------------------------------------------ 00100 ** Processes commands to EPL Instances 00101 **------------------------------------------------------------------------------ 00102 ** Arguments: 00103 ** psNewMessage - Pointer to a ABP_MsgType message. 00104 ** 00105 ** Returns: 00106 ** None 00107 **------------------------------------------------------------------------------ 00108 */ 00109 void InstanceCommand( ABP_MsgType* psNewMessage ) 00110 { 00111 /* 00112 ** This function processes commands to the Ethernet POWERLINK Instance. 00113 */ 00114 if( ABCC_GetMsgInstance( psNewMessage ) != 1 ) 00115 { 00116 /* 00117 ** The Instance does not exist. 00118 */ 00119 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST ); 00120 00121 return; 00122 } 00123 00124 switch( ABCC_GetMsgCmdBits( psNewMessage ) ) 00125 { 00126 case ABP_CMD_GET_ATTR: 00127 { 00128 switch( ABCC_GetMsgCmdExt0( psNewMessage ) ) 00129 { 00130 #if EPL_IA_VENDOR_ID_ENABLE 00131 case ABP_EPL_IA_VENDOR_ID: 00132 00133 /* 00134 ** Copy the 1st Instance 1 attribute (Vendor ID) to the message. 00135 */ 00136 ABCC_SetMsgData32( psNewMessage, EPL_IA_VENDOR_ID_VALUE, 0 ); 00137 ABP_SetMsgResponse( psNewMessage, ABP_EPL_IA_VENDOR_ID_DS ); 00138 break; 00139 #endif 00140 #if EPL_IA_PRODUCT_CODE_ENABLE 00141 case ABP_EPL_IA_PRODUCT_CODE: 00142 00143 /* 00144 ** Copy the 2nd Instance 1 attribute (Product code) to the message. 00145 */ 00146 ABCC_SetMsgData32( psNewMessage, EPL_IA_PRODUCT_CODE_VALUE, 0 ); 00147 ABP_SetMsgResponse( psNewMessage, ABP_EPL_IA_PRODUCT_CODE_DS ); 00148 break; 00149 #endif 00150 #if EPL_IA_REVISION_HW_ENABLE 00151 case ABP_EPL_IA_MAJOR_REV: 00152 00153 /* 00154 ** Copy the 3rd Instance 1 attribute (Revision high word) to the 00155 ** message. 00156 */ 00157 ABCC_SetMsgData16( psNewMessage, EPL_IA_REVISION_HW_VALUE, 0 ); 00158 ABP_SetMsgResponse( psNewMessage, ABP_EPL_IA_MAJOR_REV_DS ); 00159 break; 00160 #endif 00161 #if EPL_IA_REVISION_LW_ENABLE 00162 case ABP_EPL_IA_MINOR_REV: 00163 00164 /* 00165 ** Copy the 4th Instance 1 attribute (Revision low word) to the message. 00166 */ 00167 ABCC_SetMsgData16( psNewMessage, EPL_IA_REVISION_LW_VALUE, 0 ); 00168 ABP_SetMsgResponse( psNewMessage, ABP_EPL_IA_MINOR_REV_DS ); 00169 break; 00170 #endif 00171 #if EPL_IA_SERIAL_NUMBER_ENABLE 00172 case ABP_EPL_IA_SERIAL_NUMBER: 00173 00174 /* 00175 ** Copy the 5th Instance 1 attribute (Serial number) to the message. 00176 */ 00177 ABCC_SetMsgData32( psNewMessage, EPL_IA_SERIAL_NUMBER_VALUE, 0 ); 00178 ABP_SetMsgResponse( psNewMessage, ABP_EPL_IA_SERIAL_NUMBER_DS ); 00179 break; 00180 #endif 00181 #if EPL_IA_MANF_DEVICE_NAME_ENABLE 00182 case ABP_EPL_IA_MANF_DEV_NAME: 00183 { 00184 UINT16 iStrLength; 00185 00186 iStrLength = (UINT16)strlen( EPL_IA_MANF_DEVICE_NAME_VALUE ); 00187 00188 /* 00189 ** Copy the 6th Instance 1 attribute (Manufacturer device name) to the 00190 ** message. 00191 */ 00192 ABCC_SetMsgString( psNewMessage, EPL_IA_MANF_DEVICE_NAME_VALUE, iStrLength, 0 ); 00193 ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength ); 00194 break; 00195 } 00196 #endif 00197 #if EPL_IA_MANF_HW_VERSION_ENABLE 00198 case ABP_EPL_IA_MANF_HW_VER: 00199 { 00200 UINT16 iStrLength; 00201 00202 iStrLength = (UINT16)strlen( EPL_IA_MANF_HW_VERSION_VALUE ); 00203 00204 00205 /* 00206 ** Copy the 7th Instance 1 attribute (Manufacturer hardware version) to 00207 ** the message. 00208 */ 00209 ABCC_SetMsgString( psNewMessage, EPL_IA_MANF_HW_VERSION_VALUE, iStrLength, 0 ); 00210 ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength ); 00211 } 00212 break; 00213 #endif 00214 #if EPL_IA_MANF_SW_VERSION_ENABLE 00215 case ABP_EPL_IA_MANF_SW_VER: 00216 { 00217 UINT16 iStrLength; 00218 00219 iStrLength = (UINT16)strlen( EPL_IA_MANF_SW_VERSION_VALUE ); 00220 00221 /* 00222 ** Copy the 8th Instance 1 attribute (Manufacturer software version) to 00223 ** the message. 00224 */ 00225 ABCC_SetMsgString( psNewMessage, EPL_IA_MANF_SW_VERSION_VALUE, iStrLength, 0 ); 00226 ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength ); 00227 } 00228 break; 00229 #endif 00230 #if EPL_IA_DEVICE_TYPE_ENABLE 00231 case ABP_EPL_IA_DEVICE_TYPE: 00232 00233 /* 00234 ** Copy the 10th Instance 1 attribute (Device type) to the message. 00235 */ 00236 ABCC_SetMsgData32( psNewMessage, EPL_IA_DEVICE_TYPE_VALUE, 0 ); 00237 ABP_SetMsgResponse( psNewMessage, ABP_EPL_IA_DEVICE_TYPE_DS ); 00238 break; 00239 #endif 00240 #if EPL_IA_MANF_NAME_ENABLE 00241 case ABP_EPL_IA_MANF_NAME: 00242 { 00243 UINT16 iStrLength; 00244 00245 iStrLength = (UINT16)strlen( EPL_IA_MANF_NAME_VALUE ); 00246 00247 /* 00248 ** Copy the 14th Instance 1 attribute (Manufacturer name) to the 00249 ** message. 00250 */ 00251 ABCC_SetMsgString( psNewMessage, EPL_IA_MANF_NAME_VALUE, iStrLength, 0 ); 00252 ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength ); 00253 break; 00254 } 00255 #endif 00256 default: 00257 00258 /* 00259 ** Unsupported attribute. 00260 */ 00261 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 ); 00262 break; 00263 } 00264 00265 break; 00266 } 00267 default: 00268 00269 /* 00270 ** Unsupported command. 00271 */ 00272 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD ); 00273 break; 00274 } 00275 } 00276 00277 /*------------------------------------------------------------------------------ 00278 ** Processes commands to the EPL Object (Instance 0) 00279 **------------------------------------------------------------------------------ 00280 ** Arguments: 00281 ** psNewMessage - Pointer to a ABP_MsgType message. 00282 ** 00283 ** Returns: 00284 ** None 00285 **------------------------------------------------------------------------------ 00286 */ 00287 void ObjectCommand( ABP_MsgType* psNewMessage ) 00288 { 00289 /* 00290 ** This function processes commands to the Ethernet POWERLINK Object 00291 ** (Instance 0). 00292 */ 00293 switch( ABCC_GetMsgCmdBits( psNewMessage ) ) 00294 { 00295 case ABP_CMD_GET_ATTR: 00296 00297 switch( ABCC_GetMsgCmdExt0( psNewMessage ) ) 00298 { 00299 case ABP_OA_NAME: 00300 { 00301 UINT16 iStrLength; 00302 00303 iStrLength = (UINT16)strlen( EPL_OA_NAME_VALUE ); 00304 00305 /* 00306 ** Copy the attribute to a message. 00307 */ 00308 ABCC_SetMsgString( psNewMessage, EPL_OA_NAME_VALUE, iStrLength, 0 ); 00309 ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength ); 00310 break; 00311 } 00312 case ABP_OA_REV: 00313 00314 /* 00315 ** Copy the attribute to a message. 00316 */ 00317 00318 ABCC_SetMsgData8( psNewMessage, epl_sObject.bRevision, 0 ); 00319 ABP_SetMsgResponse( psNewMessage, ABP_UINT8_SIZEOF ); 00320 break; 00321 00322 case ABP_OA_NUM_INST: 00323 00324 /* 00325 ** Copy the attribute to a message. 00326 */ 00327 ABCC_SetMsgData16( psNewMessage, epl_sObject.iNumberOfInstances, 0 ); 00328 ABP_SetMsgResponse( psNewMessage, ABP_UINT16_SIZEOF ); 00329 break; 00330 00331 case ABP_OA_HIGHEST_INST: 00332 00333 /* 00334 ** Copy the attribute to a message. 00335 */ 00336 ABCC_SetMsgData16( psNewMessage, epl_sObject.iHighestInstanceNo, 0 ); 00337 ABP_SetMsgResponse( psNewMessage, ABP_UINT16_SIZEOF ); 00338 break; 00339 00340 default: 00341 00342 /* 00343 ** Unsupported attribute. 00344 */ 00345 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 ); 00346 break; 00347 00348 } /* End of switch( Attribute number ) */ 00349 00350 break; 00351 00352 default: 00353 00354 /* 00355 ** Unsupported command. 00356 */ 00357 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD ); 00358 break; 00359 00360 } /* End of switch( Command number ) */ 00361 } 00362 00363 /******************************************************************************* 00364 ** Public Services 00365 ******************************************************************************** 00366 */ 00367 00368 void EPL_ProcessCmdMsg( ABP_MsgType* psNewMessage ) 00369 { 00370 /* 00371 ** This function processes commands to the Ethernet POWERLINK Object and 00372 ** its Instance. 00373 */ 00374 if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ ) 00375 { 00376 /* 00377 ** Ethernet POWERLINK object Command. 00378 */ 00379 ObjectCommand( psNewMessage ); 00380 } 00381 else 00382 { 00383 /* 00384 ** Ethernet POWERLINK instance Command. 00385 */ 00386 InstanceCommand( psNewMessage ); 00387 } 00388 00389 ABCC_SendRespMsg( psNewMessage ); 00390 } 00391 00392 #endif
Generated on Tue Jul 12 2022 15:51:57 by
