OpENer icon indicating copy to clipboard operation
OpENer copied to clipboard

Using same output assembly in multiple connections

Open jobasto opened this issue 4 years ago • 4 comments

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

jobasto avatar Oct 03 '21 17:10 jobasto

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.

MartinMelikMerkumians avatar Oct 18 '21 13:10 MartinMelikMerkumians

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.

jobasto avatar Oct 18 '21 13:10 jobasto

You are right, this only works because OpENer only has one input assembly and is a point for improvement

MartinMelikMerkumians avatar Oct 18 '21 14:10 MartinMelikMerkumians

Just posted PR #385 that hopefully addresses the issue described here.

troglobit avatar Aug 11 '22 09:08 troglobit