EtherNet/IP™ Adapter  1.04.06
User Reference Manual

◆ EI_API_CIP_setInstanceAttr()

uint32_t EI_API_CIP_setInstanceAttr ( T pCipNode_p,
uint16_t  classId_p,
uint16_t  instanceId_p,
EI_API_CIP_SAttr_t pAttr_p 
)

Set instance attribute value only.

This function can be used to set the value of a instance attribute. The values are passed in a struct of type EI_API_CIP_SAttr_t.

Remarks
The set function can only be used to change the value of an attribute and not the details/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]instanceId_pInstance 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;
uint16_t instanceId = 0x01;
// 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);
// Create instance in class with identifier classId
errCode = EI_API_CIP_createInstance(pEI_API_CIP_NODE, classId, instanceId);
// Add instance attributes
...
// Now update the instance attributes
// Attribute parameter set
EI_API_CIP_eEDT_UINT newValue = 5;
char prodname[] = "Hello this is my new string";
attr.id = 0x0007;
attr.edtSize = strlen(prodname) - 1;
attr.pvValue = &prodname;
errCode = EI_API_CIP_setInstanceAttr(pEI_API_CIP_NODE, classId, instanceId, &attr);
attr.id = 0x0001
attr.edtSize = 0;
attr.pvValue = &newValue;
errCode = EI_API_CIP_setInstanceAttr(pEI_API_CIP_NODE, classId, instanceId, &attr);
See also
EI_API_CIP_addInstanceAttr EI_API_CIP_getInstanceAttr EI_API_CIP_SAttr_t EI_API_CIP_EEdt_t EI_API_CIP_ECdt_t EI_API_CIP_EAr_t EI_API_CIP_EError_t
EI_API_CIP_SAttr
General attribute parameter collection.
Definition: EI_API_CIP.h:192
EI_API_CIP_createInstance
ETHIP_API uint32_t EI_API_CIP_createInstance(T *pCipNode_p, uint16_t classId_p, uint16_t instanceId_p)
Creates a CIP instance.
Definition: EI_API_CIP_main.c:906
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_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_CIP_setInstanceAttr
ETHIP_API uint32_t EI_API_CIP_setInstanceAttr(T *pCipNode_p, uint16_t classId_p, uint16_t instanceId_p, EI_API_CIP_SAttr_t *pAttr_p)
Set instance attribute value only.
Definition: EI_API_CIP_main.c:2234
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