EtherNet/IP™ Adapter  1.04.06
User Reference Manual

◆ EI_API_CIP_setClassAttr()

uint32_t EI_API_CIP_setClassAttr ( T pCipNode_p,
uint16_t  classId_p,
EI_API_CIP_SAttr_t pAttr_p 
)

Set class attribute value.

This function sets the value of a class attribute. The value is passed in a struct of EI_API_CIP_SAttr_t.

Remarks
The set function can only be used to change the value of an attribute and not the details or properties. Note that the example code only demonstrates how to use the API function. It is however not possible to change for example the attribute type with this function.
Parameters
[in]pCipNode_pPointer to the CIP node.
[in]classId_pClass identifier.
[in]pAttr_pPointer to struct of attribute parameters.
Returns
EI_API_CIP_EError_t as uint32_t value.
Return values
EI_API_CIP_eERR_OKSuccess.
EI_API_CIP_eERR_NODE_INVALIDCIP node is invalid, possibly EI_API_CIP_NODE_new() was not called.
EI_API_CIP_eERR_CLASS_DOES_NOT_EXISTClass does not exists in CIP node dictionary.
EI_API_CIP_eERR_INSTANCE_DOES_NOT_EXISTInstance does not exist in CIP node dictionary.
EI_API_CIP_eERR_ATTRIBUTE_DOES_NOT_EXISTAttribute does not exist in class or instance.
EI_API_CIP_eERR_ATTRIBUTE_INVALID_VALUEInvalid data pointer.
EI_API_CIP_eERR_ATTRIBUTE_UNKNOWN_STATEUnknown state during attribute operation reached.
Example
#include <api/EI_API.h>
EI_API_ADP_T* pEI_API_ADP = NULL;
EI_API_CIP_NODE_T* pEI_API_CIP_NODE = NULL;
uint32_t errCode;
uint8_t numInterfaces = 1;
uint16_t classId = 0x0064;
// Create a new adapter first
pEI_API_ADP = EI_API_ADP_new(numInterfaces);
// Create a CIP node next
pEI_API_CIP_NODE = EI_API_CIP_NODE_new();
// Create a class
errCode = EI_API_CIP_createClass(pEI_API_CIP_NODE, classId);
// Add class attributes
...
// Attribute parameter set, here use attribute IDs in vendor specific range
EI_API_CIP_eEDT_UINT newValue = 5;
char prodname[] = "Hello this is my new string";
attr.id = 0x0066;
attr.edtSize = strlen(prodname) - 1;
attr.pvValue = &prodname;
errCode = EI_API_CIP_setClassAttr(pEI_API_CIP_NODE, classId, &attr);
attr.id = 0x0067;
attr.edtSize = 0;
attr.pvValue = &newValue;
errCode = EI_API_CIP_setClassAttr(pEI_API_CIP_NODE, classId, &attr);
See also
EI_API_CIP_addClassAttr EI_API_CIP_getClassAttr EI_API_CIP_setInstanceAttr EI_API_CIP_SAttr_t EI_API_CIP_EEdt_t EI_API_CIP_ECdt_t EI_API_CIP_EAr_t
EI_API_CIP_SAttr
General attribute parameter collection.
Definition: EI_API_CIP.h:192
EI_API_CIP_createClass
ETHIP_API uint32_t EI_API_CIP_createClass(T *pCipNode_p, uint16_t classId_p)
Create a CIP class.
Definition: EI_API_CIP_main.c:361
EI_API_CIP_setClassAttr
ETHIP_API uint32_t EI_API_CIP_setClassAttr(T *pCipNode_p, uint16_t classId_p, EI_API_CIP_SAttr_t *pAttr_p)
Set class attribute value.
Definition: EI_API_CIP_main.c:834
EI_API_CIP_NODE_new
ETHIP_API T * EI_API_CIP_NODE_new(void)
Create a new CIP node.
Definition: EI_API_CIP_main.c:69
EI_API_CIP_SAttr::pvValue
void * pvValue
Definition: EI_API_CIP.h:200
EI_API_CIP_SAttr::id
uint16_t id
Definition: EI_API_CIP.h:193
EI_API_CIP_SAttr::edtSize
uint16_t edtSize
Definition: EI_API_CIP.h:197
EI_API_ADP_new
ETHIP_API T * EI_API_ADP_new(uint8_t numInterfaces_p)
Create a new EtherNet/IP adapter.
Definition: EI_API_ADP_main.c:235