cipidentity.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*******************************************************************************
  2. * Copyright (c) 2009, Rockwell Automation, Inc.
  3. * All rights reserved.
  4. *
  5. ******************************************************************************/
  6. #ifndef OPENER_CIPIDENTITY_H_
  7. #define OPENER_CIPIDENTITY_H_
  8. #include "typedefs.h"
  9. #include "ciptypes.h"
  10. /** @brief Identity class code */
  11. static const CipUint kCipIdentityClassCode = 0x01U;
  12. /** @brief Status of the CIP Identity object */
  13. typedef enum {
  14. kOwned = 0x0001, /**< Indicates that the device has an owner */
  15. kConfigured = 0x0004, /**< Indicates that the device is configured to do
  16. something different, than the out-of-the-box default. */
  17. kMinorRecoverableFault = 0x0100, /**< Indicates that the device detected a
  18. fault with itself, which was thought to be recoverable. The device did not
  19. switch to a faulted state. */
  20. kMinorUncoverableFault = 0x0200, /**< Indicates that the device detected a
  21. fault with itself, which was thought to be recoverable. The device did not
  22. switch to a faulted state. */
  23. kMajorRecoverableFault = 0x0400, /**< Indicates that the device detected a
  24. fault with itself,which was thought to be recoverable. The device changed
  25. to the "Major Recoverable Fault" state */
  26. kMajorUnrecoverableFault = 0x0800 /**< Indicates that the device detected a
  27. fault with itself,which was thought to be recoverable. The device changed
  28. to the "Major Unrecoverable Fault" state */
  29. } CipIdentityStatus;
  30. /** @brief Constants for the extended status field in the Status word */
  31. typedef enum {
  32. kSelftestingUnknown = 0x0000U,
  33. kFirmwareUpdateInProgress = 0x0010U,
  34. kStatusAtLeastOneFaultedIoConnection = 0x0020U,
  35. kNoIoConnectionsEstablished = 0x0030U,
  36. kNonVolatileConfigurationBad = 0x0040U,
  37. kMajorFault = 0x0050U,
  38. kAtLeastOneIoConnectionInRunMode = 0x0060U,
  39. kAtLeastOneIoConnectionEstablishedAllInIdleMode = 0x0070U,
  40. kExtStatusMask = 0x00F0U
  41. } CipIdentityExtendedStatus;
  42. /** @brief Constants for the state member of the Identity object. */
  43. typedef enum {
  44. kStateNonExistent = 0U,
  45. kStateSelfTesting = 1U,
  46. kStateStandby = 2U,
  47. kStateOperational = 3U,
  48. kStateMajorRecoverableFault = 4U,
  49. kStateMajorUnrecoverableFault = 5U,
  50. kStateDefault = 255U
  51. } CipIdentityState;
  52. /** @brief Declaration of the Identity object's structure type
  53. */
  54. typedef struct {
  55. CipUint vendor_id; /**< Attribute 1: Vendor ID */
  56. CipUint device_type; /**< Attribute 2: Device Type */
  57. CipUint product_code; /**< Attribute 3: Product Code */
  58. CipRevision revision; /**< Attribute 4: Revision / CipUsint Major, CipUsint Minor */
  59. CipWord status; /**< Attribute 5: Status */
  60. CipWord ext_status; /**< Attribute 5: last set extended status, needed for Status handling */
  61. CipUdint serial_number; /**< Attribute 6: Serial Number, has to be set prior to OpENer's network initialization */
  62. CipShortString product_name; /**< Attribute 7: Product Name */
  63. CipUsint state; /** Attribute 8: state, this member could control the Module Status LED blink pattern */
  64. } CipIdentityObject;
  65. /* global public variables */
  66. extern CipIdentityObject g_identity;
  67. /* public functions */
  68. /** @brief CIP Identity object constructor
  69. *
  70. * @returns kEipStatusError if the class could not be created, otherwise kEipStatusOk
  71. */
  72. EipStatus CipIdentityInit(void);
  73. void CipIdentitySetStatusFlags(const CipWord status_flags);
  74. void CipIdentityClearStatusFlags(const CipWord status_flags);
  75. void CipIdentitySetExtendedDeviceStatus(
  76. CipIdentityExtendedStatus extended_status);
  77. #endif /* OPENER_CIPIDENTITY_H_ */