EtherNet/IP™ Adapter  1.04.06
User Reference Manual

◆ EI_API_CIP_addInstanceService()

uint32_t EI_API_CIP_addInstanceService ( T pCipNode_p,
uint16_t  classId_p,
uint16_t  instanceId_p,
EI_API_CIP_SService_t pService_p 
)

Add one or more service/s to the class instance.

This function adds one or more service/s to the class with the class and instance identifiers passed as parameters classId_p and instanceId_p.

Remarks
The service EI_API_CIP_eSC_SETATTRSINGLE includes EI_API_CIP_eSC_GETATTRSINGLE, so its not necessary for a bitwise operation (or) for example (EI_API_CIP_eSC_GETATTRSINGLE | EI_API_CIP_eSC_SETATTRSINGLE).
Parameters
[in]pCipNode_pPointer to the CIP node.
[in]classId_pClass identifier.
[in]instanceId_pInstance identifier.
[in]pService_pService or services the class will support.
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_BLACKLISTOperation on the CIP object with specified identifier (class ID) are not allowed.
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_SERVICE_ALREADY_EXISTService already exist.
EI_API_CIP_eERR_SERVICE_PARAMETERWrong or invalid service parameters.
EI_API_CIP_eERR_SERVICE_INVALIDService is invalid, possibly NULL pointer.
EI_API_CIP_eERR_MEMALLOCMemory allocation error.
EI_API_CIP_eERR_NOT_IMPLEMENTEDNot implemented function.
EI_API_CIP_eERR_CLASS_UNKNOWN_STATEUnknown state during class 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);
// Create instance in class with identifier classId
errCode = EI_API_CIP_createInstance(pEI_API_CIP_NODE, classId, 0x0001);
// Add services to instance 0x01 for the class with classId
// Example for Get_Attribute_Single
errCode = EI_API_CIP_addInstanceService(pEI_API_CIP_NODE, classId, 0x0001, EI_API_CIP_eSC_GETATTRSINGLE)
// Example for Get_Attribute_All
// List of attribute ID's
uint16_t getAttributesAllResponseInstanceLevel01[] = { 1, 2, 3, 4, 5 };
srvc_all = { EI_API_CIP_eSC_GETATTRIBUTESALL, 5, getAttributesAllResponseInstanceLevel01 };
errCode = EI_API_CIP_addInstanceService(pEI_API_CIP_NODE, classId_p, 0x0001, &srvc_all);
See also
EI_API_CIP_createClass EI_API_CIP_createInstance EI_API_CIP_ESc_t EI_API_CIP_EError_t
EI_API_CIP_SService::code
EI_API_CIP_ESc_t code
Definition: EI_API_CIP.h:181
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_addInstanceService
ETHIP_API uint32_t EI_API_CIP_addInstanceService(T *pCipNode_p, uint16_t classId_p, uint16_t instanceId_p, EI_API_CIP_SService_t *pService_p)
Add one or more service/s to the class instance.
Definition: EI_API_CIP_main.c:1077
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_eSC_GETATTRIBUTESALL
@ EI_API_CIP_eSC_GETATTRIBUTESALL
Definition: EI_API_def.h:114
EI_API_CIP_SService
General service parameter collection.
Definition: EI_API_CIP.h:180
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_eSC_GETATTRSINGLE
@ EI_API_CIP_eSC_GETATTRSINGLE
Definition: EI_API_def.h:116
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