Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Enumeration in C language

Status
Not open for further replies.

vinothmct

Member level 1
Joined
May 2, 2012
Messages
38
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,584
I working on low level C functions so i find a lot of code complex . Can someone explain me this piece of code?

Code:
if (req.pib_attr == ZB_PHY_PIB_CURRENT_CHANNEL)
 

  zb_mlme_get_request_t req;
 

typedef struct zb_mlme_get_request_s
{
  zb_mac_pib_attr_t  pib_attr;
  zb_uint8_t          pib_index;
} ZB_PACKED_STRUCT
zb_mlme_get_request_t;
 


typedef enum
{
  /* PHY PIB */
  ZB_PHY_PIB_CURRENT_CHANNEL                    = 0x00,
  ZB_PHY_PIB_CURRENT_PAGE                       = 0x04,
  /* MAC PIB */
  ZB_PIB_ATTRIBUTE_ACK_WAIT_DURATION            = 0x40,
  ZB_PIB_ATTRIBUTE_ASSOCIATION_PERMIT           = 0x41,
  ZB_PIB_ATTRIBUTE_AUTO_REQUEST                 = 0x42,
  ZB_PIB_ATTRIBUTE_BATT_LIFE_EXT                = 0x43,
  ZB_PIB_ATTRIBUTE_BATT_LIFE_EXT_PERIODS        = 0x44,
  ZB_PIB_ATTRIBUTE_BEACON_PAYLOAD               = 0x45,
  ZB_PIB_ATTRIBUTE_BEACON_PAYLOAD_LENGTH        = 0x46,
  ZB_PIB_ATTRIBUTE_BEACON_ORDER                 = 0x47,
  ZB_PIB_ATTRIBUTE_BEACON_TX_TIME               = 0x48,
  ZB_PIB_ATTRIBUTE_BSN                          = 0x49,
  ZB_PIB_ATTRIBUTE_COORD_EXTEND_ADDRESS         = 0x4a,
  ZB_PIB_ATTRIBUTE_COORD_SHORT_ADDRESS          = 0x4b,
  ZB_PIB_ATTRIBUTE_DSN                          = 0x4c,
  ZB_PIB_ATTRIBUTE_TIMESTAMP_SUPPORTED          = 0x5c,
  ZB_PIB_ATTRIBUTE_SECURITY_ENABLED             = 0x5d
} zb_mac_pib_attr_t;


Here enum is nested inside a structure .

If condition is checked here total enum variable req.pibattr is checked against a member of enum. I have checked values are not assigned to
Collapse | Copy Code
req.pib_attr
..

How the condition will be executed .
 
Last edited by a moderator:

hi,
the enum can not be used as a type.. here in struct, you are using enum wrongly.
just declare a variable (integer).
then check that against the enum value.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top