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

Function GetExclusiveOwnerConnection

source/src/cip/appcontype.c:178–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178CipConnectionObject *GetExclusiveOwnerConnection(
179 const CipConnectionObject *const RESTRICT connection_object,
180 EipUint16 *const extended_error) {
181
182 for (size_t i = 0; i < OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS; ++i) {
183 if ( (g_exlusive_owner_connections[i].output_assembly ==
184 connection_object->consumed_path.instance_id)
185 && (g_exlusive_owner_connections[i].input_assembly ==
186 connection_object->produced_path.instance_id)
187 && (g_exlusive_owner_connections[i].config_assembly ==
188 connection_object->configuration_path.instance_id) ) {
189
190 /* check if on other connection point with the same output assembly is currently connected */
191 CipConnectionObject *exclusive_owner = GetConnectedOutputAssembly(
192 connection_object->produced_path.instance_id);
193 if ( NULL
194 != exclusive_owner ) {
195 if(kConnectionObjectStateEstablished ==
196 ConnectionObjectGetState(exclusive_owner) ) {
197 *extended_error =
198 kConnectionManagerExtendedStatusCodeErrorOwnershipConflict;
199 OPENER_TRACE_INFO("Hit an Ownership conflict in appcontype.c:198\n");
200 break;
201 }
202 if(kConnectionObjectStateTimedOut ==
203 ConnectionObjectGetState(exclusive_owner)
204 && ConnectionObjectEqualOriginator(connection_object,
205 exclusive_owner) ) {
206 g_exlusive_owner_connections[i].connection_data.
207 connection_close_function(&(g_exlusive_owner_connections[i].
208 connection_data) );
209 return &(g_exlusive_owner_connections[i].connection_data);
210 } else {
211 *extended_error =
212 kConnectionManagerExtendedStatusCodeErrorOwnershipConflict;
213 OPENER_TRACE_INFO(
214 "Hit an Ownership conflict with timed out connection");
215 break;
216 }
217 }
218 return &(g_exlusive_owner_connections[i].connection_data);
219 }
220 }
221 return NULL;
222}
223
224CipConnectionObject *GetInputOnlyConnection(
225 const CipConnectionObject *const RESTRICT connection_object,

Callers 1

Calls 3

ConnectionObjectGetStateFunction · 0.85

Tested by

no test coverage detected