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.
etn_obj.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 Host object. 00027 ******************************************************************************** 00028 ******************************************************************************** 00029 */ 00030 00031 #include "abcc_td.h" 00032 #include "abcc_sys_adapt.h" 00033 #include "abcc_obj_cfg.h" 00034 #include "abcc.h" 00035 #include "etn_obj.h" 00036 #include "abp_etn.h" 00037 #include "string.h" 00038 #include "appl_abcc_handler.h" 00039 #include "abcc_port.h" 00040 00041 #if ETN_OBJ_ENABLE 00042 00043 /******************************************************************************* 00044 ** Defines 00045 ******************************************************************************** 00046 */ 00047 00048 /*------------------------------------------------------------------------------ 00049 ** Object attribute values 00050 **------------------------------------------------------------------------------ 00051 */ 00052 #define ETN_OA_NAME_VALUE "Ethernet" 00053 #define ETN_OA_REV_VALUE 2 00054 #define ETN_OA_NUM_INST_VALUE 1 00055 #define ETN_OA_HIGHEST_INST_VALUE 1 00056 00057 /******************************************************************************* 00058 ** Typedefs 00059 ******************************************************************************** 00060 */ 00061 00062 /*------------------------------------------------------------------------------ 00063 ** etn_ObjectType. 00064 ** Structure describing an Ethernet Object. 00065 **------------------------------------------------------------------------------ 00066 */ 00067 typedef struct etn_ObjectType 00068 { 00069 const char* pcName; 00070 UINT8 bRevision; 00071 UINT16 iNumberOfInstances; 00072 UINT16 iHighestInstanceNo; 00073 } 00074 etn_ObjectType; 00075 00076 /*------------------------------------------------------------------------------ 00077 ** Forward declarations 00078 **------------------------------------------------------------------------------ 00079 */ 00080 static void InstanceCommand( ABP_MsgType* psNewMessage ); 00081 static void ObjectCommand( ABP_MsgType* psNewMessage ); 00082 00083 /******************************************************************************* 00084 ** Private Globals 00085 ******************************************************************************** 00086 */ 00087 #if ETN_IA_NETWORK_STATUS_ENABLE 00088 static UINT16 etn_iNetworkStatus; 00089 #endif 00090 #if ETN_IA_IP_CONFIGURATION_ENABLE 00091 static ETN_IpConfigType etn_sIpConfig; 00092 #endif 00093 static const etn_ObjectType etn_sObject = 00094 { 00095 ETN_OA_NAME_VALUE, /* Name. */ 00096 ETN_OA_REV_VALUE, /* Revision. */ 00097 ETN_OA_NUM_INST_VALUE, /* Number of instances. */ 00098 ETN_OA_HIGHEST_INST_VALUE /* Highest instance number. */ 00099 }; 00100 00101 /******************************************************************************* 00102 ** Public Services 00103 ******************************************************************************** 00104 */ 00105 00106 void ETN_ProcessCmdMsg( ABP_MsgType* psNewMessage ) 00107 { 00108 /* 00109 ** This function processes commands to the Ethernet Object and it's Instance. 00110 */ 00111 if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ ) 00112 { 00113 /* 00114 ** Ethernet object Command 00115 */ 00116 ObjectCommand( psNewMessage ); 00117 } 00118 else 00119 { 00120 /* 00121 ** Ethernet instance Command 00122 */ 00123 InstanceCommand( psNewMessage ); 00124 } 00125 00126 ABCC_SendRespMsg( psNewMessage ); 00127 } 00128 00129 #if ETN_IA_IP_CONFIGURATION_ENABLE 00130 void ETN_GetIpConfig( ETN_IpConfigType* psIpConfig ) 00131 { 00132 ABCC_PORT_UseCritical(); 00133 00134 ABCC_PORT_EnterCritical(); 00135 { 00136 *psIpConfig = etn_sIpConfig; 00137 } 00138 ABCC_PORT_ExitCritical(); 00139 } 00140 #endif /* #if ETN_IA_NETWORK_STATUS_ENABLE */ 00141 00142 /******************************************************************************* 00143 ** Private Services 00144 ******************************************************************************** 00145 */ 00146 00147 /*------------------------------------------------------------------------------ 00148 ** Processes commands to ETN Instances 00149 **------------------------------------------------------------------------------ 00150 ** Arguments: 00151 ** psNewMessage - Pointer to a ABP_MsgType message. 00152 ** 00153 ** Returns: 00154 ** None 00155 **------------------------------------------------------------------------------ 00156 */ 00157 static void InstanceCommand( ABP_MsgType* psNewMessage ) 00158 { 00159 UINT16 iInstance; 00160 UINT8 bAttribute; 00161 00162 iInstance = ABCC_GetMsgInstance( psNewMessage ); 00163 bAttribute = ABCC_GetMsgCmdExt0( psNewMessage ); 00164 00165 /* 00166 ** This function processes commands to the Ethernet Instance. 00167 */ 00168 if( iInstance != 1 ) 00169 { 00170 /* 00171 ** The Instance does not exist. 00172 */ 00173 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST ); 00174 return; 00175 } 00176 00177 switch ( ABCC_GetMsgCmdBits( psNewMessage ) ) 00178 { 00179 case ABP_CMD_GET_ATTR: 00180 00181 switch( bAttribute ) 00182 { 00183 #if ETN_IA_MAC_ADDRESS_ENABLE 00184 case ABP_ETN_IA_MAC_ADDRESS: 00185 { 00186 UINT16 i; 00187 UINT8 abMac[ 6 ]; 00188 00189 /* 00190 ** Copy the 1st Instance 1 attribute (MAC Address) to the message. 00191 */ 00192 00193 ABCC_PORT_MemCpy( abMac, ETN_IA_MAC_ADDRESS_VALUE, ABP_ETN_IA_MAC_ADDRESS_DS ); 00194 00195 for( i = 0; i < ABP_ETN_IA_MAC_ADDRESS_DS; i++ ) 00196 { 00197 ABCC_SetMsgData8( psNewMessage, abMac[ i ], i ); 00198 } 00199 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_MAC_ADDRESS_DS ); 00200 break; 00201 } 00202 #endif 00203 #if ETN_IA_ENABLE_HICP_ENABLE 00204 case ABP_ETN_IA_ENABLE_HICP: 00205 00206 /* 00207 ** Copy the 2nd Instance 1 attribute (Enable HICP) to the message. 00208 */ 00209 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_HICP_VALUE, 0 ); 00210 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_HICP_DS ); 00211 break; 00212 #endif 00213 #if ETN_IA_ENABLE_WEB_ENABLE 00214 case ABP_ETN_IA_ENABLE_WEB: 00215 00216 /* 00217 ** Copy the 3rd Instance 1 attribute (Enable WEB) to the message. 00218 */ 00219 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_WEB_VALUE, 0 ); 00220 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_WEB_DS ); 00221 break; 00222 #endif 00223 #if ETN_IA_ENABLE_MOD_TCP_ENABLE 00224 case ABP_ETN_IA_ENABLE_MOD_TCP: 00225 00226 /* 00227 ** Copy the 4th Instance 1 attribute (Enable ModbusTCP) to the message. 00228 */ 00229 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_MOD_TCP_VALUE, 0 ); 00230 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_MOD_TCP_DS ); 00231 break; 00232 #endif 00233 #if ETN_IA_ENABLE_WEB_ADI_ACCESS_ENABLE 00234 case ABP_ETN_IA_ENABLE_WEB_ADI_ACCESS: 00235 00236 /* 00237 ** Copy the 5th Instance 1 attribute (Enable WEB ADI access) to the message. 00238 */ 00239 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_WEB_ADI_ACCESS_VALUE, 0 ); 00240 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_WEB_ADI_ACCESS_DS ); 00241 break; 00242 #endif 00243 #if ETN_IA_ENABLE_FTP_ENABLE 00244 case ABP_ETN_IA_ENABLE_FTP: 00245 00246 /* 00247 ** Copy the 6th Instance 1 attribute (Enable FTP) to the message. 00248 */ 00249 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_FTP_VALUE, 0 ); 00250 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_FTP_DS ); 00251 break; 00252 #endif 00253 #if ETN_IA_ENABLE_ADMIN_MODE_ENABLE 00254 case ABP_ETN_IA_ENABLE_ADMIN_MODE: 00255 00256 /* 00257 ** Copy the 7th Instance 1 attribute (Enable admin mode) to the message. 00258 */ 00259 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_ADMIN_MODE_VALUE, 0 ); 00260 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_ADMIN_MODE_DS ); 00261 break; 00262 #endif 00263 #if ETN_IA_NETWORK_STATUS_ENABLE 00264 case ABP_ETN_IA_NETWORK_STATUS: 00265 00266 /* 00267 ** Copy the 8th Instance 1 attribute (Network Status) to the message. 00268 */ 00269 ABCC_SetMsgData16( psNewMessage, etn_iNetworkStatus, 0 ); 00270 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_NETWORK_STATUS_DS ); 00271 break; 00272 #endif 00273 #if ETN_IA_PORT1_MAC_ADDRESS_ENABLE 00274 case ABP_ETN_IA_PORT1_MAC_ADDRESS: 00275 { 00276 UINT16 i; 00277 UINT8 abMac[ 6 ]; 00278 00279 /* 00280 ** Copy the 9th Instance 1 attribute (Port 1 MAC Address) to the message. 00281 */ 00282 00283 ABCC_PORT_MemCpy( abMac, ETN_IA_PORT1_MAC_ADDRESS_VALUE, ABP_ETN_IA_PORT1_MAC_ADDRESS_DS ); 00284 00285 for( i = 0; i < ABP_ETN_IA_PORT1_MAC_ADDRESS_DS; i++ ) 00286 { 00287 ABCC_SetMsgData8( psNewMessage, abMac[ i ], i ); 00288 } 00289 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_PORT1_MAC_ADDRESS_DS ); 00290 break; 00291 } 00292 #endif 00293 #if ETN_IA_PORT2_MAC_ADDRESS_ENABLE 00294 case ABP_ETN_IA_PORT2_MAC_ADDRESS: 00295 { 00296 UINT16 i; 00297 UINT8 abMac[ 6 ]; 00298 00299 /* 00300 ** Copy the 10th Instance 1 attribute (Port 2 MAC Address) to the message. 00301 */ 00302 00303 ABCC_PORT_MemCpy( abMac, ETN_IA_PORT2_MAC_ADDRESS_VALUE, ABP_ETN_IA_PORT2_MAC_ADDRESS_DS ); 00304 00305 for( i = 0; i < ABP_ETN_IA_PORT2_MAC_ADDRESS_DS; i++ ) 00306 { 00307 ABCC_SetMsgData8( psNewMessage, abMac[ i ], i ); 00308 } 00309 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_PORT2_MAC_ADDRESS_DS ); 00310 break; 00311 } 00312 #endif 00313 #if ETN_IA_ENABLE_ACD_ENABLE 00314 case ABP_ETN_IA_ENABLE_ACD: 00315 00316 /* 00317 ** Copy the 11th Instance 1 attribute (Enable ACD) to the message. 00318 */ 00319 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_ACD_VALUE, 0 ); 00320 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_ACD_DS ); 00321 break; 00322 #endif 00323 #if ETN_IA_PORT1_STATE_ENABLE 00324 case ABP_ETN_IA_PORT1_STATE: 00325 00326 /* 00327 ** Copy the 12th Instance 1 attribute (Port 1 state) to the message. 00328 */ 00329 ABCC_SetMsgData8( psNewMessage, ETN_IA_PORT1_STATE_VALUE, 0 ); 00330 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_PORT1_STATE_DS ); 00331 break; 00332 #endif 00333 #if ETN_IA_PORT2_STATE_ENABLE 00334 case ABP_ETN_IA_PORT2_STATE: 00335 00336 /* 00337 ** Copy the 13th Instance 1 attribute (Port 2 state) to the message. 00338 */ 00339 ABCC_SetMsgData8( psNewMessage, ETN_IA_PORT2_STATE_VALUE, 0 ); 00340 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_PORT2_STATE_DS ); 00341 break; 00342 #endif 00343 #if ETN_IA_ENABLE_WEB_UPDATE_ENABLE 00344 case ABP_ETN_IA_ENABLE_WEB_UPDATE: 00345 00346 /* 00347 ** Copy the 14th Instance 1 attribute (Enable web update) to the message. 00348 */ 00349 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_WEB_UPDATE_VALUE, 0 ); 00350 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_WEB_UPDATE_DS ); 00351 break; 00352 #endif 00353 #if ETN_IA_ENABLE_HICP_RESET_ENABLE 00354 case ABP_ETN_IA_ENABLE_HICP_RESET: 00355 00356 /* 00357 ** Copy the 15th Instance 1 attribute (Enable HICP reset) to the message. 00358 */ 00359 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_HICP_RESET_VALUE, 0 ); 00360 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_HICP_RESET_DS ); 00361 break; 00362 #endif 00363 #if ETN_IA_IP_CONFIGURATION_ENABLE 00364 case ABP_ETN_IA_IP_CONFIGURATION: 00365 { 00366 UINT16 i; 00367 00368 /* 00369 ** Copy the 16th Instance 1 attribute (IP configuration) to the message. 00370 */ 00371 00372 i = 0; 00373 while( i < ABP_ETN_IA_IP_CONFIGURATION_DS ) 00374 { 00375 ABCC_SetMsgData32( psNewMessage, etn_sIpConfig.alIpConfig[ ( i / ABP_UINT32_SIZEOF ) ], i ); 00376 i += ABP_UINT32_SIZEOF; 00377 } 00378 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_IP_CONFIGURATION_DS ); 00379 break; 00380 } 00381 #endif 00382 #if ETN_IA_IP_ADDRESS_BYTE_0_2_ENABLE 00383 case ABP_ETN_IA_IP_ADDRESS_BYTE_0_2: 00384 { 00385 UINT16 i; 00386 UINT8 abIp[ 3 ]; 00387 00388 /* 00389 ** Copy the 17th Instance 1 attribute (IP address byte 0 to 2) to the message. 00390 */ 00391 00392 ABCC_PORT_MemCpy( abIp, ETN_IA_IP_ADDRESS_BYTE_0_2_VALUE, ABP_ETN_IA_IP_ADDRESS_BYTE_0_2_DS ); 00393 00394 for( i = 0; i < ABP_ETN_IA_IP_ADDRESS_BYTE_0_2_DS; i++ ) 00395 { 00396 ABCC_SetMsgData8( psNewMessage, abIp[ i ], i ); 00397 } 00398 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_IP_ADDRESS_BYTE_0_2_DS ); 00399 break; 00400 } 00401 #endif 00402 default: 00403 00404 /* 00405 ** Unsupported attribute. 00406 */ 00407 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 ); 00408 break; 00409 } 00410 break; 00411 00412 case ABP_CMD_SET_ATTR: 00413 00414 switch( bAttribute ) 00415 { 00416 #if ETN_IA_MAC_ADDRESS_ENABLE 00417 case ABP_ETN_IA_MAC_ADDRESS: 00418 00419 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00420 break; 00421 #endif 00422 #if ETN_IA_ENABLE_HICP_ENABLE 00423 case ABP_ETN_IA_ENABLE_HICP: 00424 00425 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00426 break; 00427 #endif 00428 #if ETN_IA_ENABLE_WEB_ENABLE 00429 case ABP_ETN_IA_ENABLE_WEB: 00430 00431 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00432 break; 00433 #endif 00434 #if ETN_IA_ENABLE_MOD_TCP_ENABLE 00435 case ABP_ETN_IA_ENABLE_MOD_TCP: 00436 00437 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00438 break; 00439 #endif 00440 #if ETN_IA_ENABLE_WEB_ADI_ACCESS_ENABLE 00441 case ABP_ETN_IA_ENABLE_WEB_ADI_ACCESS: 00442 00443 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00444 break; 00445 #endif 00446 #if ETN_IA_ENABLE_FTP_ENABLE 00447 case ABP_ETN_IA_ENABLE_FTP: 00448 00449 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00450 break; 00451 #endif 00452 #if ETN_IA_ENABLE_ADMIN_MODE_ENABLE 00453 case ABP_ETN_IA_ENABLE_ADMIN_MODE: 00454 00455 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00456 break; 00457 #endif 00458 #if ETN_IA_NETWORK_STATUS_ENABLE 00459 case ABP_ETN_IA_NETWORK_STATUS: 00460 { 00461 /* 00462 ** Set the 8th Instance 1 attribute (Network Status) to the message. 00463 */ 00464 00465 if( ABCC_GetMsgDataSize( psNewMessage ) > ABP_ETN_IA_NETWORK_STATUS_DS ) 00466 { 00467 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_TOO_MUCH_DATA ); 00468 break; 00469 } 00470 else if( ABCC_GetMsgDataSize( psNewMessage ) < ABP_ETN_IA_NETWORK_STATUS_DS ) 00471 { 00472 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_NOT_ENOUGH_DATA ); 00473 break; 00474 } 00475 00476 ABCC_GetMsgData16( psNewMessage, &etn_iNetworkStatus, 0 ); 00477 #if ETN_OBJ_USE_SET_ATTR_SUCCESS_CALLBACK 00478 ETN_SetAttrSuccessCallback( iInstance, bAttribute ); 00479 #endif 00480 ABP_SetMsgResponse( psNewMessage, 0 ); 00481 break; 00482 } 00483 #endif 00484 #if ETN_IA_PORT1_MAC_ADDRESS_ENABLE 00485 case ABP_ETN_IA_PORT1_MAC_ADDRESS: 00486 00487 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00488 break; 00489 #endif 00490 #if ETN_IA_PORT2_MAC_ADDRESS_ENABLE 00491 case ABP_ETN_IA_PORT2_MAC_ADDRESS: 00492 00493 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00494 break; 00495 #endif 00496 #if ETN_IA_ENABLE_ACD_ENABLE 00497 case ABP_ETN_IA_ENABLE_ACD: 00498 00499 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00500 break; 00501 #endif 00502 #if ETN_IA_PORT1_STATE_ENABLE 00503 case ABP_ETN_IA_PORT1_STATE: 00504 00505 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00506 break; 00507 #endif 00508 #if ETN_IA_PORT2_STATE_ENABLE 00509 case ABP_ETN_IA_PORT2_STATE: 00510 00511 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00512 break; 00513 #endif 00514 #if ETN_IA_ENABLE_WEB_UPDATE_ENABLE 00515 case ABP_ETN_IA_ENABLE_WEB_UPDATE: 00516 00517 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00518 break; 00519 #endif 00520 #if ETN_IA_ENABLE_HICP_RESET_ENABLE 00521 case ABP_ETN_IA_ENABLE_HICP_RESET: 00522 00523 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00524 break; 00525 #endif 00526 #if ETN_IA_IP_CONFIGURATION_ENABLE 00527 case ABP_ETN_IA_IP_CONFIGURATION: 00528 { 00529 UINT16 i; 00530 00531 /* 00532 ** Set the 16th Instance 1 attribute (IP configuration) to the message. 00533 */ 00534 00535 if( ABCC_GetMsgDataSize( psNewMessage ) > ABP_ETN_IA_IP_CONFIGURATION_DS ) 00536 { 00537 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_TOO_MUCH_DATA ); 00538 break; 00539 } 00540 else if( ABCC_GetMsgDataSize( psNewMessage ) < ABP_ETN_IA_IP_CONFIGURATION_DS ) 00541 { 00542 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_NOT_ENOUGH_DATA ); 00543 break; 00544 } 00545 00546 i = 0; 00547 while( i < ABP_ETN_IA_IP_CONFIGURATION_DS ) 00548 { 00549 ABCC_GetMsgData32( psNewMessage, &etn_sIpConfig.alIpConfig[ ( i / ABP_UINT32_SIZEOF ) ], i ); 00550 i += ABP_UINT32_SIZEOF; 00551 } 00552 #if ETN_OBJ_USE_SET_ATTR_SUCCESS_CALLBACK 00553 ETN_SetAttrSuccessCallback( iInstance, bAttribute ); 00554 #endif 00555 ABP_SetMsgResponse( psNewMessage, 0 ); 00556 break; 00557 } 00558 #endif 00559 #if ETN_IA_IP_ADDRESS_BYTE_0_2_ENABLE 00560 case ABP_ETN_IA_IP_ADDRESS_BYTE_0_2: 00561 00562 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE ); 00563 break; 00564 #endif 00565 00566 default: 00567 00568 /* 00569 ** Unsupported attribute. 00570 */ 00571 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 ); 00572 break; 00573 } 00574 break; 00575 00576 default: 00577 00578 /* 00579 ** Unsupported command. 00580 */ 00581 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD ); 00582 break; 00583 } 00584 } 00585 00586 /*------------------------------------------------------------------------------ 00587 ** Processes commands to the ETN Object (Instance 0) 00588 **------------------------------------------------------------------------------ 00589 ** Arguments: 00590 ** psNewMessage - Pointer to a ABP_MsgType message. 00591 ** 00592 ** Returns: 00593 ** None 00594 **------------------------------------------------------------------------------ 00595 */ 00596 static void ObjectCommand( ABP_MsgType* psNewMessage ) 00597 { 00598 /* 00599 ** This function processes commands to the Ethernet Object (Instance 0). 00600 */ 00601 switch ( ABCC_GetMsgCmdBits( psNewMessage ) ) 00602 { 00603 case ABP_CMD_GET_ATTR: 00604 { 00605 switch( ABCC_GetMsgCmdExt0( psNewMessage ) ) 00606 { 00607 case ABP_OA_NAME: 00608 { 00609 UINT16 iStrLength; 00610 00611 /* 00612 ** Copy the attribute to a message. 00613 */ 00614 iStrLength = (UINT16)strlen( etn_sObject.pcName ); 00615 ABCC_SetMsgString( psNewMessage, etn_sObject.pcName, iStrLength, 0 ); 00616 ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength ); 00617 break; 00618 } 00619 00620 case ABP_OA_REV: 00621 00622 /* 00623 ** Copy the attribute to a message. 00624 */ 00625 ABCC_SetMsgData8( psNewMessage, etn_sObject.bRevision, 0 ); 00626 ABP_SetMsgResponse( psNewMessage, ABP_OA_REV_DS ); 00627 break; 00628 00629 case ABP_OA_NUM_INST: 00630 00631 /* 00632 ** Copy the attribute to a message. 00633 */ 00634 ABCC_SetMsgData16( psNewMessage, etn_sObject.iNumberOfInstances, 0 ); 00635 ABP_SetMsgResponse( psNewMessage, ABP_OA_NUM_INST_DS ); 00636 break; 00637 00638 case ABP_OA_HIGHEST_INST: 00639 00640 /* 00641 ** Copy the attribute to a message. 00642 */ 00643 ABCC_SetMsgData16( psNewMessage, etn_sObject.iHighestInstanceNo, 0 ); 00644 ABP_SetMsgResponse( psNewMessage, ABP_OA_HIGHEST_INST_DS ); 00645 break; 00646 00647 default: 00648 00649 /* 00650 ** Unsupported attribute. 00651 */ 00652 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 ); 00653 break; 00654 } 00655 break; 00656 } 00657 00658 default: 00659 00660 /* 00661 ** Unsupported command. 00662 */ 00663 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD ); 00664 break; 00665 00666 } /* End of switch( Command number ) */ 00667 } 00668 00669 #endif /* ETN_OBJ_ENABLE */
Generated on Tue Jul 12 2022 15:51:57 by
