OpENer
OpENer copied to clipboard
Using same output assembly in multiple connections
Hi,
I'm wondering why in the following code there will be an error returned if one has registered multiple listen only connections using the same output assembly for the heartbeat. In my understanding of the spec it is perfectly fine to use the same assembly instance for all heartbeats. Did I misinterpret the spec or is there a bug in the code?
Best regards, jobasto
https://github.com/EIPStackGroup/OpENer/blob/e1bb0e2fc57d70f76b89d81c7c940f968b5b3b9c/source/src/cip/appcontype.c#L277-L289
Perhaps I misunderstand your question, but the code returns an error if not the correct input_assembly is targeted.
To your question, yes the heartbeat assembly can be used by all input_only or listen_only connections. For both connection types application data is only sent from T->O so from OpENer to the scanner device. the O->T signal is the heartbeat.
Both connections can only access the devices' data inputs, as they cannot be changed by the application.
void ConfigureInputOnlyConnectionPoint(const unsigned int connection_number,
const unsigned int output_assembly,
const unsigned int input_assembly,
const unsigned int config_assembly) {
if (OPENER_CIP_NUM_INPUT_ONLY_CONNS > connection_number) {
g_input_only_connections[connection_number].output_assembly =
output_assembly;
g_input_only_connections[connection_number].input_assembly = input_assembly;
g_input_only_connections[connection_number].config_assembly =
config_assembly;
}
}
ConfigureInputOnlyConnectionPoint(0,
DEMO_APP_HEARTBEAT_INPUT_ONLY_ASSEMBLY_NUM,
DEMO_APP_INPUT_ASSEMBLY_NUM,
DEMO_APP_CONFIG_ASSEMBLY_NUM);
Taking a look on these two code parts, we can see that our output assembly is configured to the same heartbeat assembly for all Input Only connections. So if a connection wants to open an Input Only, it has to give the correct output assembly (first if) and has to refer to an Input assembly (OpENer has only one) to be accepted.
Consider defining two input only connections as follows:
ConfigureInputOnlyConnectionPoint(0,
DEMO_APP_HEARTBEAT_INPUT_ONLY_ASSEMBLY_NUM,
DEMO_APP_INPUT_ASSEMBLY_1_NUM,
DEMO_APP_CONFIG_ASSEMBLY_NUM);
ConfigureInputOnlyConnectionPoint(0,
DEMO_APP_HEARTBEAT_INPUT_ONLY_ASSEMBLY_NUM,
DEMO_APP_INPUT_ASSEMBLY_2_NUM,
DEMO_APP_CONFIG_ASSEMBLY_NUM);
GetListenOnlyConnection iterates over all registered connections and returns when the first connection using the requested output assembly is found. Depending on the input assembly it will be a success or an error. Consequently, if there are multiple registered listen only connections using the same output assembly there will be connections that can't be opened.
You are right, this only works because OpENer only has one input assembly and is a point for improvement
Just posted PR #385 that hopefully addresses the issue described here.