MCPcopy Create free account
hub / github.com/EIPStackGroup/OpENer / CreateAssemblyObject

Function CreateAssemblyObject

source/src/cip/cipassembly.c:80–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80CipInstance *CreateAssemblyObject(const EipUint32 instance_id,
81 EipByte *const data,
82 const EipUint16 data_length) {
83 CipClass *assembly_class = GetCipClass(kCipAssemblyClassCode);
84 if(NULL == assembly_class) {
85 assembly_class = CreateAssemblyClass();
86 }
87
88 if(NULL == assembly_class) {
89 return NULL;
90 }
91
92 CipInstance *const instance = AddCIPInstance(assembly_class, instance_id); /* add instances (always succeeds (or asserts))*/
93
94 CipByteArray *const assembly_byte_array = (CipByteArray *) CipCalloc(1,
95 sizeof(
96 CipByteArray) );
97 if(assembly_byte_array == NULL) {
98 return NULL; /*TODO remove assembly instance in case of error*/
99 }
100
101 assembly_byte_array->length = data_length;
102 assembly_byte_array->data = data;
103 InsertAttribute(instance,
104 3,
105 kCipByteArray,
106 assembly_byte_array,
107 kSetAndGetAble);
108 /* Attribute 4 Number of bytes in Attribute 3 */
109 InsertAttribute(instance,
110 4,
111 kCipUint,
112 &(assembly_byte_array->length),
113 kGetableSingle);
114
115 return instance;
116}
117
118EipStatus NotifyAssemblyConnectedDataReceived(CipInstance *const instance,
119 const EipUint8 *const data,

Callers 3

Calls 4

GetCipClassFunction · 0.85
CreateAssemblyClassFunction · 0.85
InsertAttributeFunction · 0.85
CipCallocFunction · 0.50

Tested by

no test coverage detected