William Kane / Generic

Dependents:   LaserioLib

Committer:
wkane
Date:
Thu May 12 19:04:45 2016 +0000
Revision:
0:9509fece98da
ver1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wkane 0:9509fece98da 1 /*******************************************************************************
wkane 0:9509fece98da 2 ********************************************************************************
wkane 0:9509fece98da 3 ** **
wkane 0:9509fece98da 4 ** ABCC Starter Kit version 2.01.01 (2015-12-14) **
wkane 0:9509fece98da 5 ** **
wkane 0:9509fece98da 6 ** Delivered with: **
wkane 0:9509fece98da 7 ** ABCC Driver 4.01.01 (2015-12-14) **
wkane 0:9509fece98da 8 ** ABP 7.16.01 (2015-10-14) **
wkane 0:9509fece98da 9 ** */
wkane 0:9509fece98da 10 /*******************************************************************************
wkane 0:9509fece98da 11 ********************************************************************************
wkane 0:9509fece98da 12 ** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
wkane 0:9509fece98da 13 ** **
wkane 0:9509fece98da 14 ** This code is the property of HMS Industrial Networks AB. **
wkane 0:9509fece98da 15 ** The source code may not be reproduced, distributed, or used without **
wkane 0:9509fece98da 16 ** permission. When used together with a product from HMS, permission is **
wkane 0:9509fece98da 17 ** granted to modify, reproduce and distribute the code in binary form **
wkane 0:9509fece98da 18 ** without any restrictions. **
wkane 0:9509fece98da 19 ** **
wkane 0:9509fece98da 20 ** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
wkane 0:9509fece98da 21 ** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
wkane 0:9509fece98da 22 ** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
wkane 0:9509fece98da 23 ** THAT DEFECTS IN IT CAN BE CORRECTED. **
wkane 0:9509fece98da 24 ********************************************************************************
wkane 0:9509fece98da 25 ********************************************************************************
wkane 0:9509fece98da 26 ** Source file for the Ethernet Host object.
wkane 0:9509fece98da 27 ********************************************************************************
wkane 0:9509fece98da 28 ********************************************************************************
wkane 0:9509fece98da 29 */
wkane 0:9509fece98da 30
wkane 0:9509fece98da 31 #include "abcc_td.h"
wkane 0:9509fece98da 32 #include "abcc_sys_adapt.h"
wkane 0:9509fece98da 33 #include "abcc_obj_cfg.h"
wkane 0:9509fece98da 34 #include "abcc.h"
wkane 0:9509fece98da 35 #include "etn_obj.h"
wkane 0:9509fece98da 36 #include "abp_etn.h"
wkane 0:9509fece98da 37 #include "string.h"
wkane 0:9509fece98da 38 #include "appl_abcc_handler.h"
wkane 0:9509fece98da 39 #include "abcc_port.h"
wkane 0:9509fece98da 40
wkane 0:9509fece98da 41 #if ETN_OBJ_ENABLE
wkane 0:9509fece98da 42
wkane 0:9509fece98da 43 /*******************************************************************************
wkane 0:9509fece98da 44 ** Defines
wkane 0:9509fece98da 45 ********************************************************************************
wkane 0:9509fece98da 46 */
wkane 0:9509fece98da 47
wkane 0:9509fece98da 48 /*------------------------------------------------------------------------------
wkane 0:9509fece98da 49 ** Object attribute values
wkane 0:9509fece98da 50 **------------------------------------------------------------------------------
wkane 0:9509fece98da 51 */
wkane 0:9509fece98da 52 #define ETN_OA_NAME_VALUE "Ethernet"
wkane 0:9509fece98da 53 #define ETN_OA_REV_VALUE 2
wkane 0:9509fece98da 54 #define ETN_OA_NUM_INST_VALUE 1
wkane 0:9509fece98da 55 #define ETN_OA_HIGHEST_INST_VALUE 1
wkane 0:9509fece98da 56
wkane 0:9509fece98da 57 /*******************************************************************************
wkane 0:9509fece98da 58 ** Typedefs
wkane 0:9509fece98da 59 ********************************************************************************
wkane 0:9509fece98da 60 */
wkane 0:9509fece98da 61
wkane 0:9509fece98da 62 /*------------------------------------------------------------------------------
wkane 0:9509fece98da 63 ** etn_ObjectType.
wkane 0:9509fece98da 64 ** Structure describing an Ethernet Object.
wkane 0:9509fece98da 65 **------------------------------------------------------------------------------
wkane 0:9509fece98da 66 */
wkane 0:9509fece98da 67 typedef struct etn_ObjectType
wkane 0:9509fece98da 68 {
wkane 0:9509fece98da 69 const char* pcName;
wkane 0:9509fece98da 70 UINT8 bRevision;
wkane 0:9509fece98da 71 UINT16 iNumberOfInstances;
wkane 0:9509fece98da 72 UINT16 iHighestInstanceNo;
wkane 0:9509fece98da 73 }
wkane 0:9509fece98da 74 etn_ObjectType;
wkane 0:9509fece98da 75
wkane 0:9509fece98da 76 /*------------------------------------------------------------------------------
wkane 0:9509fece98da 77 ** Forward declarations
wkane 0:9509fece98da 78 **------------------------------------------------------------------------------
wkane 0:9509fece98da 79 */
wkane 0:9509fece98da 80 static void InstanceCommand( ABP_MsgType* psNewMessage );
wkane 0:9509fece98da 81 static void ObjectCommand( ABP_MsgType* psNewMessage );
wkane 0:9509fece98da 82
wkane 0:9509fece98da 83 /*******************************************************************************
wkane 0:9509fece98da 84 ** Private Globals
wkane 0:9509fece98da 85 ********************************************************************************
wkane 0:9509fece98da 86 */
wkane 0:9509fece98da 87 #if ETN_IA_NETWORK_STATUS_ENABLE
wkane 0:9509fece98da 88 static UINT16 etn_iNetworkStatus;
wkane 0:9509fece98da 89 #endif
wkane 0:9509fece98da 90 #if ETN_IA_IP_CONFIGURATION_ENABLE
wkane 0:9509fece98da 91 static ETN_IpConfigType etn_sIpConfig;
wkane 0:9509fece98da 92 #endif
wkane 0:9509fece98da 93 static const etn_ObjectType etn_sObject =
wkane 0:9509fece98da 94 {
wkane 0:9509fece98da 95 ETN_OA_NAME_VALUE, /* Name. */
wkane 0:9509fece98da 96 ETN_OA_REV_VALUE, /* Revision. */
wkane 0:9509fece98da 97 ETN_OA_NUM_INST_VALUE, /* Number of instances. */
wkane 0:9509fece98da 98 ETN_OA_HIGHEST_INST_VALUE /* Highest instance number. */
wkane 0:9509fece98da 99 };
wkane 0:9509fece98da 100
wkane 0:9509fece98da 101 /*******************************************************************************
wkane 0:9509fece98da 102 ** Public Services
wkane 0:9509fece98da 103 ********************************************************************************
wkane 0:9509fece98da 104 */
wkane 0:9509fece98da 105
wkane 0:9509fece98da 106 void ETN_ProcessCmdMsg( ABP_MsgType* psNewMessage )
wkane 0:9509fece98da 107 {
wkane 0:9509fece98da 108 /*
wkane 0:9509fece98da 109 ** This function processes commands to the Ethernet Object and it's Instance.
wkane 0:9509fece98da 110 */
wkane 0:9509fece98da 111 if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ )
wkane 0:9509fece98da 112 {
wkane 0:9509fece98da 113 /*
wkane 0:9509fece98da 114 ** Ethernet object Command
wkane 0:9509fece98da 115 */
wkane 0:9509fece98da 116 ObjectCommand( psNewMessage );
wkane 0:9509fece98da 117 }
wkane 0:9509fece98da 118 else
wkane 0:9509fece98da 119 {
wkane 0:9509fece98da 120 /*
wkane 0:9509fece98da 121 ** Ethernet instance Command
wkane 0:9509fece98da 122 */
wkane 0:9509fece98da 123 InstanceCommand( psNewMessage );
wkane 0:9509fece98da 124 }
wkane 0:9509fece98da 125
wkane 0:9509fece98da 126 ABCC_SendRespMsg( psNewMessage );
wkane 0:9509fece98da 127 }
wkane 0:9509fece98da 128
wkane 0:9509fece98da 129 #if ETN_IA_IP_CONFIGURATION_ENABLE
wkane 0:9509fece98da 130 void ETN_GetIpConfig( ETN_IpConfigType* psIpConfig )
wkane 0:9509fece98da 131 {
wkane 0:9509fece98da 132 ABCC_PORT_UseCritical();
wkane 0:9509fece98da 133
wkane 0:9509fece98da 134 ABCC_PORT_EnterCritical();
wkane 0:9509fece98da 135 {
wkane 0:9509fece98da 136 *psIpConfig = etn_sIpConfig;
wkane 0:9509fece98da 137 }
wkane 0:9509fece98da 138 ABCC_PORT_ExitCritical();
wkane 0:9509fece98da 139 }
wkane 0:9509fece98da 140 #endif /* #if ETN_IA_NETWORK_STATUS_ENABLE */
wkane 0:9509fece98da 141
wkane 0:9509fece98da 142 /*******************************************************************************
wkane 0:9509fece98da 143 ** Private Services
wkane 0:9509fece98da 144 ********************************************************************************
wkane 0:9509fece98da 145 */
wkane 0:9509fece98da 146
wkane 0:9509fece98da 147 /*------------------------------------------------------------------------------
wkane 0:9509fece98da 148 ** Processes commands to ETN Instances
wkane 0:9509fece98da 149 **------------------------------------------------------------------------------
wkane 0:9509fece98da 150 ** Arguments:
wkane 0:9509fece98da 151 ** psNewMessage - Pointer to a ABP_MsgType message.
wkane 0:9509fece98da 152 **
wkane 0:9509fece98da 153 ** Returns:
wkane 0:9509fece98da 154 ** None
wkane 0:9509fece98da 155 **------------------------------------------------------------------------------
wkane 0:9509fece98da 156 */
wkane 0:9509fece98da 157 static void InstanceCommand( ABP_MsgType* psNewMessage )
wkane 0:9509fece98da 158 {
wkane 0:9509fece98da 159 UINT16 iInstance;
wkane 0:9509fece98da 160 UINT8 bAttribute;
wkane 0:9509fece98da 161
wkane 0:9509fece98da 162 iInstance = ABCC_GetMsgInstance( psNewMessage );
wkane 0:9509fece98da 163 bAttribute = ABCC_GetMsgCmdExt0( psNewMessage );
wkane 0:9509fece98da 164
wkane 0:9509fece98da 165 /*
wkane 0:9509fece98da 166 ** This function processes commands to the Ethernet Instance.
wkane 0:9509fece98da 167 */
wkane 0:9509fece98da 168 if( iInstance != 1 )
wkane 0:9509fece98da 169 {
wkane 0:9509fece98da 170 /*
wkane 0:9509fece98da 171 ** The Instance does not exist.
wkane 0:9509fece98da 172 */
wkane 0:9509fece98da 173 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST );
wkane 0:9509fece98da 174 return;
wkane 0:9509fece98da 175 }
wkane 0:9509fece98da 176
wkane 0:9509fece98da 177 switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
wkane 0:9509fece98da 178 {
wkane 0:9509fece98da 179 case ABP_CMD_GET_ATTR:
wkane 0:9509fece98da 180
wkane 0:9509fece98da 181 switch( bAttribute )
wkane 0:9509fece98da 182 {
wkane 0:9509fece98da 183 #if ETN_IA_MAC_ADDRESS_ENABLE
wkane 0:9509fece98da 184 case ABP_ETN_IA_MAC_ADDRESS:
wkane 0:9509fece98da 185 {
wkane 0:9509fece98da 186 UINT16 i;
wkane 0:9509fece98da 187 UINT8 abMac[ 6 ];
wkane 0:9509fece98da 188
wkane 0:9509fece98da 189 /*
wkane 0:9509fece98da 190 ** Copy the 1st Instance 1 attribute (MAC Address) to the message.
wkane 0:9509fece98da 191 */
wkane 0:9509fece98da 192
wkane 0:9509fece98da 193 ABCC_PORT_MemCpy( abMac, ETN_IA_MAC_ADDRESS_VALUE, ABP_ETN_IA_MAC_ADDRESS_DS );
wkane 0:9509fece98da 194
wkane 0:9509fece98da 195 for( i = 0; i < ABP_ETN_IA_MAC_ADDRESS_DS; i++ )
wkane 0:9509fece98da 196 {
wkane 0:9509fece98da 197 ABCC_SetMsgData8( psNewMessage, abMac[ i ], i );
wkane 0:9509fece98da 198 }
wkane 0:9509fece98da 199 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_MAC_ADDRESS_DS );
wkane 0:9509fece98da 200 break;
wkane 0:9509fece98da 201 }
wkane 0:9509fece98da 202 #endif
wkane 0:9509fece98da 203 #if ETN_IA_ENABLE_HICP_ENABLE
wkane 0:9509fece98da 204 case ABP_ETN_IA_ENABLE_HICP:
wkane 0:9509fece98da 205
wkane 0:9509fece98da 206 /*
wkane 0:9509fece98da 207 ** Copy the 2nd Instance 1 attribute (Enable HICP) to the message.
wkane 0:9509fece98da 208 */
wkane 0:9509fece98da 209 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_HICP_VALUE, 0 );
wkane 0:9509fece98da 210 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_HICP_DS );
wkane 0:9509fece98da 211 break;
wkane 0:9509fece98da 212 #endif
wkane 0:9509fece98da 213 #if ETN_IA_ENABLE_WEB_ENABLE
wkane 0:9509fece98da 214 case ABP_ETN_IA_ENABLE_WEB:
wkane 0:9509fece98da 215
wkane 0:9509fece98da 216 /*
wkane 0:9509fece98da 217 ** Copy the 3rd Instance 1 attribute (Enable WEB) to the message.
wkane 0:9509fece98da 218 */
wkane 0:9509fece98da 219 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_WEB_VALUE, 0 );
wkane 0:9509fece98da 220 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_WEB_DS );
wkane 0:9509fece98da 221 break;
wkane 0:9509fece98da 222 #endif
wkane 0:9509fece98da 223 #if ETN_IA_ENABLE_MOD_TCP_ENABLE
wkane 0:9509fece98da 224 case ABP_ETN_IA_ENABLE_MOD_TCP:
wkane 0:9509fece98da 225
wkane 0:9509fece98da 226 /*
wkane 0:9509fece98da 227 ** Copy the 4th Instance 1 attribute (Enable ModbusTCP) to the message.
wkane 0:9509fece98da 228 */
wkane 0:9509fece98da 229 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_MOD_TCP_VALUE, 0 );
wkane 0:9509fece98da 230 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_MOD_TCP_DS );
wkane 0:9509fece98da 231 break;
wkane 0:9509fece98da 232 #endif
wkane 0:9509fece98da 233 #if ETN_IA_ENABLE_WEB_ADI_ACCESS_ENABLE
wkane 0:9509fece98da 234 case ABP_ETN_IA_ENABLE_WEB_ADI_ACCESS:
wkane 0:9509fece98da 235
wkane 0:9509fece98da 236 /*
wkane 0:9509fece98da 237 ** Copy the 5th Instance 1 attribute (Enable WEB ADI access) to the message.
wkane 0:9509fece98da 238 */
wkane 0:9509fece98da 239 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_WEB_ADI_ACCESS_VALUE, 0 );
wkane 0:9509fece98da 240 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_WEB_ADI_ACCESS_DS );
wkane 0:9509fece98da 241 break;
wkane 0:9509fece98da 242 #endif
wkane 0:9509fece98da 243 #if ETN_IA_ENABLE_FTP_ENABLE
wkane 0:9509fece98da 244 case ABP_ETN_IA_ENABLE_FTP:
wkane 0:9509fece98da 245
wkane 0:9509fece98da 246 /*
wkane 0:9509fece98da 247 ** Copy the 6th Instance 1 attribute (Enable FTP) to the message.
wkane 0:9509fece98da 248 */
wkane 0:9509fece98da 249 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_FTP_VALUE, 0 );
wkane 0:9509fece98da 250 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_FTP_DS );
wkane 0:9509fece98da 251 break;
wkane 0:9509fece98da 252 #endif
wkane 0:9509fece98da 253 #if ETN_IA_ENABLE_ADMIN_MODE_ENABLE
wkane 0:9509fece98da 254 case ABP_ETN_IA_ENABLE_ADMIN_MODE:
wkane 0:9509fece98da 255
wkane 0:9509fece98da 256 /*
wkane 0:9509fece98da 257 ** Copy the 7th Instance 1 attribute (Enable admin mode) to the message.
wkane 0:9509fece98da 258 */
wkane 0:9509fece98da 259 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_ADMIN_MODE_VALUE, 0 );
wkane 0:9509fece98da 260 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_ADMIN_MODE_DS );
wkane 0:9509fece98da 261 break;
wkane 0:9509fece98da 262 #endif
wkane 0:9509fece98da 263 #if ETN_IA_NETWORK_STATUS_ENABLE
wkane 0:9509fece98da 264 case ABP_ETN_IA_NETWORK_STATUS:
wkane 0:9509fece98da 265
wkane 0:9509fece98da 266 /*
wkane 0:9509fece98da 267 ** Copy the 8th Instance 1 attribute (Network Status) to the message.
wkane 0:9509fece98da 268 */
wkane 0:9509fece98da 269 ABCC_SetMsgData16( psNewMessage, etn_iNetworkStatus, 0 );
wkane 0:9509fece98da 270 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_NETWORK_STATUS_DS );
wkane 0:9509fece98da 271 break;
wkane 0:9509fece98da 272 #endif
wkane 0:9509fece98da 273 #if ETN_IA_PORT1_MAC_ADDRESS_ENABLE
wkane 0:9509fece98da 274 case ABP_ETN_IA_PORT1_MAC_ADDRESS:
wkane 0:9509fece98da 275 {
wkane 0:9509fece98da 276 UINT16 i;
wkane 0:9509fece98da 277 UINT8 abMac[ 6 ];
wkane 0:9509fece98da 278
wkane 0:9509fece98da 279 /*
wkane 0:9509fece98da 280 ** Copy the 9th Instance 1 attribute (Port 1 MAC Address) to the message.
wkane 0:9509fece98da 281 */
wkane 0:9509fece98da 282
wkane 0:9509fece98da 283 ABCC_PORT_MemCpy( abMac, ETN_IA_PORT1_MAC_ADDRESS_VALUE, ABP_ETN_IA_PORT1_MAC_ADDRESS_DS );
wkane 0:9509fece98da 284
wkane 0:9509fece98da 285 for( i = 0; i < ABP_ETN_IA_PORT1_MAC_ADDRESS_DS; i++ )
wkane 0:9509fece98da 286 {
wkane 0:9509fece98da 287 ABCC_SetMsgData8( psNewMessage, abMac[ i ], i );
wkane 0:9509fece98da 288 }
wkane 0:9509fece98da 289 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_PORT1_MAC_ADDRESS_DS );
wkane 0:9509fece98da 290 break;
wkane 0:9509fece98da 291 }
wkane 0:9509fece98da 292 #endif
wkane 0:9509fece98da 293 #if ETN_IA_PORT2_MAC_ADDRESS_ENABLE
wkane 0:9509fece98da 294 case ABP_ETN_IA_PORT2_MAC_ADDRESS:
wkane 0:9509fece98da 295 {
wkane 0:9509fece98da 296 UINT16 i;
wkane 0:9509fece98da 297 UINT8 abMac[ 6 ];
wkane 0:9509fece98da 298
wkane 0:9509fece98da 299 /*
wkane 0:9509fece98da 300 ** Copy the 10th Instance 1 attribute (Port 2 MAC Address) to the message.
wkane 0:9509fece98da 301 */
wkane 0:9509fece98da 302
wkane 0:9509fece98da 303 ABCC_PORT_MemCpy( abMac, ETN_IA_PORT2_MAC_ADDRESS_VALUE, ABP_ETN_IA_PORT2_MAC_ADDRESS_DS );
wkane 0:9509fece98da 304
wkane 0:9509fece98da 305 for( i = 0; i < ABP_ETN_IA_PORT2_MAC_ADDRESS_DS; i++ )
wkane 0:9509fece98da 306 {
wkane 0:9509fece98da 307 ABCC_SetMsgData8( psNewMessage, abMac[ i ], i );
wkane 0:9509fece98da 308 }
wkane 0:9509fece98da 309 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_PORT2_MAC_ADDRESS_DS );
wkane 0:9509fece98da 310 break;
wkane 0:9509fece98da 311 }
wkane 0:9509fece98da 312 #endif
wkane 0:9509fece98da 313 #if ETN_IA_ENABLE_ACD_ENABLE
wkane 0:9509fece98da 314 case ABP_ETN_IA_ENABLE_ACD:
wkane 0:9509fece98da 315
wkane 0:9509fece98da 316 /*
wkane 0:9509fece98da 317 ** Copy the 11th Instance 1 attribute (Enable ACD) to the message.
wkane 0:9509fece98da 318 */
wkane 0:9509fece98da 319 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_ACD_VALUE, 0 );
wkane 0:9509fece98da 320 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_ACD_DS );
wkane 0:9509fece98da 321 break;
wkane 0:9509fece98da 322 #endif
wkane 0:9509fece98da 323 #if ETN_IA_PORT1_STATE_ENABLE
wkane 0:9509fece98da 324 case ABP_ETN_IA_PORT1_STATE:
wkane 0:9509fece98da 325
wkane 0:9509fece98da 326 /*
wkane 0:9509fece98da 327 ** Copy the 12th Instance 1 attribute (Port 1 state) to the message.
wkane 0:9509fece98da 328 */
wkane 0:9509fece98da 329 ABCC_SetMsgData8( psNewMessage, ETN_IA_PORT1_STATE_VALUE, 0 );
wkane 0:9509fece98da 330 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_PORT1_STATE_DS );
wkane 0:9509fece98da 331 break;
wkane 0:9509fece98da 332 #endif
wkane 0:9509fece98da 333 #if ETN_IA_PORT2_STATE_ENABLE
wkane 0:9509fece98da 334 case ABP_ETN_IA_PORT2_STATE:
wkane 0:9509fece98da 335
wkane 0:9509fece98da 336 /*
wkane 0:9509fece98da 337 ** Copy the 13th Instance 1 attribute (Port 2 state) to the message.
wkane 0:9509fece98da 338 */
wkane 0:9509fece98da 339 ABCC_SetMsgData8( psNewMessage, ETN_IA_PORT2_STATE_VALUE, 0 );
wkane 0:9509fece98da 340 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_PORT2_STATE_DS );
wkane 0:9509fece98da 341 break;
wkane 0:9509fece98da 342 #endif
wkane 0:9509fece98da 343 #if ETN_IA_ENABLE_WEB_UPDATE_ENABLE
wkane 0:9509fece98da 344 case ABP_ETN_IA_ENABLE_WEB_UPDATE:
wkane 0:9509fece98da 345
wkane 0:9509fece98da 346 /*
wkane 0:9509fece98da 347 ** Copy the 14th Instance 1 attribute (Enable web update) to the message.
wkane 0:9509fece98da 348 */
wkane 0:9509fece98da 349 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_WEB_UPDATE_VALUE, 0 );
wkane 0:9509fece98da 350 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_WEB_UPDATE_DS );
wkane 0:9509fece98da 351 break;
wkane 0:9509fece98da 352 #endif
wkane 0:9509fece98da 353 #if ETN_IA_ENABLE_HICP_RESET_ENABLE
wkane 0:9509fece98da 354 case ABP_ETN_IA_ENABLE_HICP_RESET:
wkane 0:9509fece98da 355
wkane 0:9509fece98da 356 /*
wkane 0:9509fece98da 357 ** Copy the 15th Instance 1 attribute (Enable HICP reset) to the message.
wkane 0:9509fece98da 358 */
wkane 0:9509fece98da 359 ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_HICP_RESET_VALUE, 0 );
wkane 0:9509fece98da 360 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_HICP_RESET_DS );
wkane 0:9509fece98da 361 break;
wkane 0:9509fece98da 362 #endif
wkane 0:9509fece98da 363 #if ETN_IA_IP_CONFIGURATION_ENABLE
wkane 0:9509fece98da 364 case ABP_ETN_IA_IP_CONFIGURATION:
wkane 0:9509fece98da 365 {
wkane 0:9509fece98da 366 UINT16 i;
wkane 0:9509fece98da 367
wkane 0:9509fece98da 368 /*
wkane 0:9509fece98da 369 ** Copy the 16th Instance 1 attribute (IP configuration) to the message.
wkane 0:9509fece98da 370 */
wkane 0:9509fece98da 371
wkane 0:9509fece98da 372 i = 0;
wkane 0:9509fece98da 373 while( i < ABP_ETN_IA_IP_CONFIGURATION_DS )
wkane 0:9509fece98da 374 {
wkane 0:9509fece98da 375 ABCC_SetMsgData32( psNewMessage, etn_sIpConfig.alIpConfig[ ( i / ABP_UINT32_SIZEOF ) ], i );
wkane 0:9509fece98da 376 i += ABP_UINT32_SIZEOF;
wkane 0:9509fece98da 377 }
wkane 0:9509fece98da 378 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_IP_CONFIGURATION_DS );
wkane 0:9509fece98da 379 break;
wkane 0:9509fece98da 380 }
wkane 0:9509fece98da 381 #endif
wkane 0:9509fece98da 382 #if ETN_IA_IP_ADDRESS_BYTE_0_2_ENABLE
wkane 0:9509fece98da 383 case ABP_ETN_IA_IP_ADDRESS_BYTE_0_2:
wkane 0:9509fece98da 384 {
wkane 0:9509fece98da 385 UINT16 i;
wkane 0:9509fece98da 386 UINT8 abIp[ 3 ];
wkane 0:9509fece98da 387
wkane 0:9509fece98da 388 /*
wkane 0:9509fece98da 389 ** Copy the 17th Instance 1 attribute (IP address byte 0 to 2) to the message.
wkane 0:9509fece98da 390 */
wkane 0:9509fece98da 391
wkane 0:9509fece98da 392 ABCC_PORT_MemCpy( abIp, ETN_IA_IP_ADDRESS_BYTE_0_2_VALUE, ABP_ETN_IA_IP_ADDRESS_BYTE_0_2_DS );
wkane 0:9509fece98da 393
wkane 0:9509fece98da 394 for( i = 0; i < ABP_ETN_IA_IP_ADDRESS_BYTE_0_2_DS; i++ )
wkane 0:9509fece98da 395 {
wkane 0:9509fece98da 396 ABCC_SetMsgData8( psNewMessage, abIp[ i ], i );
wkane 0:9509fece98da 397 }
wkane 0:9509fece98da 398 ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_IP_ADDRESS_BYTE_0_2_DS );
wkane 0:9509fece98da 399 break;
wkane 0:9509fece98da 400 }
wkane 0:9509fece98da 401 #endif
wkane 0:9509fece98da 402 default:
wkane 0:9509fece98da 403
wkane 0:9509fece98da 404 /*
wkane 0:9509fece98da 405 ** Unsupported attribute.
wkane 0:9509fece98da 406 */
wkane 0:9509fece98da 407 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
wkane 0:9509fece98da 408 break;
wkane 0:9509fece98da 409 }
wkane 0:9509fece98da 410 break;
wkane 0:9509fece98da 411
wkane 0:9509fece98da 412 case ABP_CMD_SET_ATTR:
wkane 0:9509fece98da 413
wkane 0:9509fece98da 414 switch( bAttribute )
wkane 0:9509fece98da 415 {
wkane 0:9509fece98da 416 #if ETN_IA_MAC_ADDRESS_ENABLE
wkane 0:9509fece98da 417 case ABP_ETN_IA_MAC_ADDRESS:
wkane 0:9509fece98da 418
wkane 0:9509fece98da 419 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 420 break;
wkane 0:9509fece98da 421 #endif
wkane 0:9509fece98da 422 #if ETN_IA_ENABLE_HICP_ENABLE
wkane 0:9509fece98da 423 case ABP_ETN_IA_ENABLE_HICP:
wkane 0:9509fece98da 424
wkane 0:9509fece98da 425 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 426 break;
wkane 0:9509fece98da 427 #endif
wkane 0:9509fece98da 428 #if ETN_IA_ENABLE_WEB_ENABLE
wkane 0:9509fece98da 429 case ABP_ETN_IA_ENABLE_WEB:
wkane 0:9509fece98da 430
wkane 0:9509fece98da 431 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 432 break;
wkane 0:9509fece98da 433 #endif
wkane 0:9509fece98da 434 #if ETN_IA_ENABLE_MOD_TCP_ENABLE
wkane 0:9509fece98da 435 case ABP_ETN_IA_ENABLE_MOD_TCP:
wkane 0:9509fece98da 436
wkane 0:9509fece98da 437 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 438 break;
wkane 0:9509fece98da 439 #endif
wkane 0:9509fece98da 440 #if ETN_IA_ENABLE_WEB_ADI_ACCESS_ENABLE
wkane 0:9509fece98da 441 case ABP_ETN_IA_ENABLE_WEB_ADI_ACCESS:
wkane 0:9509fece98da 442
wkane 0:9509fece98da 443 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 444 break;
wkane 0:9509fece98da 445 #endif
wkane 0:9509fece98da 446 #if ETN_IA_ENABLE_FTP_ENABLE
wkane 0:9509fece98da 447 case ABP_ETN_IA_ENABLE_FTP:
wkane 0:9509fece98da 448
wkane 0:9509fece98da 449 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 450 break;
wkane 0:9509fece98da 451 #endif
wkane 0:9509fece98da 452 #if ETN_IA_ENABLE_ADMIN_MODE_ENABLE
wkane 0:9509fece98da 453 case ABP_ETN_IA_ENABLE_ADMIN_MODE:
wkane 0:9509fece98da 454
wkane 0:9509fece98da 455 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 456 break;
wkane 0:9509fece98da 457 #endif
wkane 0:9509fece98da 458 #if ETN_IA_NETWORK_STATUS_ENABLE
wkane 0:9509fece98da 459 case ABP_ETN_IA_NETWORK_STATUS:
wkane 0:9509fece98da 460 {
wkane 0:9509fece98da 461 /*
wkane 0:9509fece98da 462 ** Set the 8th Instance 1 attribute (Network Status) to the message.
wkane 0:9509fece98da 463 */
wkane 0:9509fece98da 464
wkane 0:9509fece98da 465 if( ABCC_GetMsgDataSize( psNewMessage ) > ABP_ETN_IA_NETWORK_STATUS_DS )
wkane 0:9509fece98da 466 {
wkane 0:9509fece98da 467 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_TOO_MUCH_DATA );
wkane 0:9509fece98da 468 break;
wkane 0:9509fece98da 469 }
wkane 0:9509fece98da 470 else if( ABCC_GetMsgDataSize( psNewMessage ) < ABP_ETN_IA_NETWORK_STATUS_DS )
wkane 0:9509fece98da 471 {
wkane 0:9509fece98da 472 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_NOT_ENOUGH_DATA );
wkane 0:9509fece98da 473 break;
wkane 0:9509fece98da 474 }
wkane 0:9509fece98da 475
wkane 0:9509fece98da 476 ABCC_GetMsgData16( psNewMessage, &etn_iNetworkStatus, 0 );
wkane 0:9509fece98da 477 #if ETN_OBJ_USE_SET_ATTR_SUCCESS_CALLBACK
wkane 0:9509fece98da 478 ETN_SetAttrSuccessCallback( iInstance, bAttribute );
wkane 0:9509fece98da 479 #endif
wkane 0:9509fece98da 480 ABP_SetMsgResponse( psNewMessage, 0 );
wkane 0:9509fece98da 481 break;
wkane 0:9509fece98da 482 }
wkane 0:9509fece98da 483 #endif
wkane 0:9509fece98da 484 #if ETN_IA_PORT1_MAC_ADDRESS_ENABLE
wkane 0:9509fece98da 485 case ABP_ETN_IA_PORT1_MAC_ADDRESS:
wkane 0:9509fece98da 486
wkane 0:9509fece98da 487 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 488 break;
wkane 0:9509fece98da 489 #endif
wkane 0:9509fece98da 490 #if ETN_IA_PORT2_MAC_ADDRESS_ENABLE
wkane 0:9509fece98da 491 case ABP_ETN_IA_PORT2_MAC_ADDRESS:
wkane 0:9509fece98da 492
wkane 0:9509fece98da 493 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 494 break;
wkane 0:9509fece98da 495 #endif
wkane 0:9509fece98da 496 #if ETN_IA_ENABLE_ACD_ENABLE
wkane 0:9509fece98da 497 case ABP_ETN_IA_ENABLE_ACD:
wkane 0:9509fece98da 498
wkane 0:9509fece98da 499 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 500 break;
wkane 0:9509fece98da 501 #endif
wkane 0:9509fece98da 502 #if ETN_IA_PORT1_STATE_ENABLE
wkane 0:9509fece98da 503 case ABP_ETN_IA_PORT1_STATE:
wkane 0:9509fece98da 504
wkane 0:9509fece98da 505 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 506 break;
wkane 0:9509fece98da 507 #endif
wkane 0:9509fece98da 508 #if ETN_IA_PORT2_STATE_ENABLE
wkane 0:9509fece98da 509 case ABP_ETN_IA_PORT2_STATE:
wkane 0:9509fece98da 510
wkane 0:9509fece98da 511 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 512 break;
wkane 0:9509fece98da 513 #endif
wkane 0:9509fece98da 514 #if ETN_IA_ENABLE_WEB_UPDATE_ENABLE
wkane 0:9509fece98da 515 case ABP_ETN_IA_ENABLE_WEB_UPDATE:
wkane 0:9509fece98da 516
wkane 0:9509fece98da 517 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 518 break;
wkane 0:9509fece98da 519 #endif
wkane 0:9509fece98da 520 #if ETN_IA_ENABLE_HICP_RESET_ENABLE
wkane 0:9509fece98da 521 case ABP_ETN_IA_ENABLE_HICP_RESET:
wkane 0:9509fece98da 522
wkane 0:9509fece98da 523 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 524 break;
wkane 0:9509fece98da 525 #endif
wkane 0:9509fece98da 526 #if ETN_IA_IP_CONFIGURATION_ENABLE
wkane 0:9509fece98da 527 case ABP_ETN_IA_IP_CONFIGURATION:
wkane 0:9509fece98da 528 {
wkane 0:9509fece98da 529 UINT16 i;
wkane 0:9509fece98da 530
wkane 0:9509fece98da 531 /*
wkane 0:9509fece98da 532 ** Set the 16th Instance 1 attribute (IP configuration) to the message.
wkane 0:9509fece98da 533 */
wkane 0:9509fece98da 534
wkane 0:9509fece98da 535 if( ABCC_GetMsgDataSize( psNewMessage ) > ABP_ETN_IA_IP_CONFIGURATION_DS )
wkane 0:9509fece98da 536 {
wkane 0:9509fece98da 537 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_TOO_MUCH_DATA );
wkane 0:9509fece98da 538 break;
wkane 0:9509fece98da 539 }
wkane 0:9509fece98da 540 else if( ABCC_GetMsgDataSize( psNewMessage ) < ABP_ETN_IA_IP_CONFIGURATION_DS )
wkane 0:9509fece98da 541 {
wkane 0:9509fece98da 542 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_NOT_ENOUGH_DATA );
wkane 0:9509fece98da 543 break;
wkane 0:9509fece98da 544 }
wkane 0:9509fece98da 545
wkane 0:9509fece98da 546 i = 0;
wkane 0:9509fece98da 547 while( i < ABP_ETN_IA_IP_CONFIGURATION_DS )
wkane 0:9509fece98da 548 {
wkane 0:9509fece98da 549 ABCC_GetMsgData32( psNewMessage, &etn_sIpConfig.alIpConfig[ ( i / ABP_UINT32_SIZEOF ) ], i );
wkane 0:9509fece98da 550 i += ABP_UINT32_SIZEOF;
wkane 0:9509fece98da 551 }
wkane 0:9509fece98da 552 #if ETN_OBJ_USE_SET_ATTR_SUCCESS_CALLBACK
wkane 0:9509fece98da 553 ETN_SetAttrSuccessCallback( iInstance, bAttribute );
wkane 0:9509fece98da 554 #endif
wkane 0:9509fece98da 555 ABP_SetMsgResponse( psNewMessage, 0 );
wkane 0:9509fece98da 556 break;
wkane 0:9509fece98da 557 }
wkane 0:9509fece98da 558 #endif
wkane 0:9509fece98da 559 #if ETN_IA_IP_ADDRESS_BYTE_0_2_ENABLE
wkane 0:9509fece98da 560 case ABP_ETN_IA_IP_ADDRESS_BYTE_0_2:
wkane 0:9509fece98da 561
wkane 0:9509fece98da 562 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
wkane 0:9509fece98da 563 break;
wkane 0:9509fece98da 564 #endif
wkane 0:9509fece98da 565
wkane 0:9509fece98da 566 default:
wkane 0:9509fece98da 567
wkane 0:9509fece98da 568 /*
wkane 0:9509fece98da 569 ** Unsupported attribute.
wkane 0:9509fece98da 570 */
wkane 0:9509fece98da 571 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
wkane 0:9509fece98da 572 break;
wkane 0:9509fece98da 573 }
wkane 0:9509fece98da 574 break;
wkane 0:9509fece98da 575
wkane 0:9509fece98da 576 default:
wkane 0:9509fece98da 577
wkane 0:9509fece98da 578 /*
wkane 0:9509fece98da 579 ** Unsupported command.
wkane 0:9509fece98da 580 */
wkane 0:9509fece98da 581 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
wkane 0:9509fece98da 582 break;
wkane 0:9509fece98da 583 }
wkane 0:9509fece98da 584 }
wkane 0:9509fece98da 585
wkane 0:9509fece98da 586 /*------------------------------------------------------------------------------
wkane 0:9509fece98da 587 ** Processes commands to the ETN Object (Instance 0)
wkane 0:9509fece98da 588 **------------------------------------------------------------------------------
wkane 0:9509fece98da 589 ** Arguments:
wkane 0:9509fece98da 590 ** psNewMessage - Pointer to a ABP_MsgType message.
wkane 0:9509fece98da 591 **
wkane 0:9509fece98da 592 ** Returns:
wkane 0:9509fece98da 593 ** None
wkane 0:9509fece98da 594 **------------------------------------------------------------------------------
wkane 0:9509fece98da 595 */
wkane 0:9509fece98da 596 static void ObjectCommand( ABP_MsgType* psNewMessage )
wkane 0:9509fece98da 597 {
wkane 0:9509fece98da 598 /*
wkane 0:9509fece98da 599 ** This function processes commands to the Ethernet Object (Instance 0).
wkane 0:9509fece98da 600 */
wkane 0:9509fece98da 601 switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
wkane 0:9509fece98da 602 {
wkane 0:9509fece98da 603 case ABP_CMD_GET_ATTR:
wkane 0:9509fece98da 604 {
wkane 0:9509fece98da 605 switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
wkane 0:9509fece98da 606 {
wkane 0:9509fece98da 607 case ABP_OA_NAME:
wkane 0:9509fece98da 608 {
wkane 0:9509fece98da 609 UINT16 iStrLength;
wkane 0:9509fece98da 610
wkane 0:9509fece98da 611 /*
wkane 0:9509fece98da 612 ** Copy the attribute to a message.
wkane 0:9509fece98da 613 */
wkane 0:9509fece98da 614 iStrLength = (UINT16)strlen( etn_sObject.pcName );
wkane 0:9509fece98da 615 ABCC_SetMsgString( psNewMessage, etn_sObject.pcName, iStrLength, 0 );
wkane 0:9509fece98da 616 ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
wkane 0:9509fece98da 617 break;
wkane 0:9509fece98da 618 }
wkane 0:9509fece98da 619
wkane 0:9509fece98da 620 case ABP_OA_REV:
wkane 0:9509fece98da 621
wkane 0:9509fece98da 622 /*
wkane 0:9509fece98da 623 ** Copy the attribute to a message.
wkane 0:9509fece98da 624 */
wkane 0:9509fece98da 625 ABCC_SetMsgData8( psNewMessage, etn_sObject.bRevision, 0 );
wkane 0:9509fece98da 626 ABP_SetMsgResponse( psNewMessage, ABP_OA_REV_DS );
wkane 0:9509fece98da 627 break;
wkane 0:9509fece98da 628
wkane 0:9509fece98da 629 case ABP_OA_NUM_INST:
wkane 0:9509fece98da 630
wkane 0:9509fece98da 631 /*
wkane 0:9509fece98da 632 ** Copy the attribute to a message.
wkane 0:9509fece98da 633 */
wkane 0:9509fece98da 634 ABCC_SetMsgData16( psNewMessage, etn_sObject.iNumberOfInstances, 0 );
wkane 0:9509fece98da 635 ABP_SetMsgResponse( psNewMessage, ABP_OA_NUM_INST_DS );
wkane 0:9509fece98da 636 break;
wkane 0:9509fece98da 637
wkane 0:9509fece98da 638 case ABP_OA_HIGHEST_INST:
wkane 0:9509fece98da 639
wkane 0:9509fece98da 640 /*
wkane 0:9509fece98da 641 ** Copy the attribute to a message.
wkane 0:9509fece98da 642 */
wkane 0:9509fece98da 643 ABCC_SetMsgData16( psNewMessage, etn_sObject.iHighestInstanceNo, 0 );
wkane 0:9509fece98da 644 ABP_SetMsgResponse( psNewMessage, ABP_OA_HIGHEST_INST_DS );
wkane 0:9509fece98da 645 break;
wkane 0:9509fece98da 646
wkane 0:9509fece98da 647 default:
wkane 0:9509fece98da 648
wkane 0:9509fece98da 649 /*
wkane 0:9509fece98da 650 ** Unsupported attribute.
wkane 0:9509fece98da 651 */
wkane 0:9509fece98da 652 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
wkane 0:9509fece98da 653 break;
wkane 0:9509fece98da 654 }
wkane 0:9509fece98da 655 break;
wkane 0:9509fece98da 656 }
wkane 0:9509fece98da 657
wkane 0:9509fece98da 658 default:
wkane 0:9509fece98da 659
wkane 0:9509fece98da 660 /*
wkane 0:9509fece98da 661 ** Unsupported command.
wkane 0:9509fece98da 662 */
wkane 0:9509fece98da 663 ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
wkane 0:9509fece98da 664 break;
wkane 0:9509fece98da 665
wkane 0:9509fece98da 666 } /* End of switch( Command number ) */
wkane 0:9509fece98da 667 }
wkane 0:9509fece98da 668
wkane 0:9509fece98da 669 #endif /* ETN_OBJ_ENABLE */