Pārlūkot izejas kodu

Moves user config for IDLE header to CMakeLists

Moves the switches for producing and consuming IDLE headers to the CMake
configuration. CMake options are set to the standard values, as expected
in the stc/eds file.

Signed-off-by: Martin Melik-Merkumians <melik-merkumians@acin.tuwien.ac.at>
Martin Melik-Merkumians 7 gadi atpakaļ
vecāks
revīzija
4e22cfddc1

+ 12 - 0
source/CMakeLists.txt

@@ -27,6 +27,18 @@ find_path( OpENer_BUILDSUPPORT_DIR OpENer.cmake ${PROJECT_SOURCE_DIR}/buildsuppo
  
 INCLUDE( ${OpENer_BUILDSUPPORT_DIR}/OpENer.cmake )
 
+option(OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER "Shall produced data from OpENer also include a run idle header?" FALSE)
+option(OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER "Will consumed data from OpENer also include a run idle header?" TRUE)
+
+if(OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER)
+  add_definitions(-DOPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER)
+endif()
+
+if(OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER)
+  add_definitions(-DOPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER)
+endif()
+
+
 #######################################
 # Platform switches                   #
 #######################################

+ 20 - 18
source/src/cip/cipioconnection.c

@@ -141,12 +141,13 @@ EipUint16 SetupIoConnectionOriginatorToTargetConnectionPoint(
       data_size -= 2; /* remove 16-bit sequence count length */
       diff_size += 2;
     }
-    if ( (kOpenerConsumedDataHasRunIdleHeader) && (data_size > 0)
-         && (!is_heartbeat) ) {
+#ifdef OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER
+    if ( (data_size > 0) && (!is_heartbeat) ) {
       /* we only have an run idle header if it is not an heartbeat connection */
       data_size -= 4; /* remove the 4 bytes needed for run/idle header */
       diff_size += 4;
     }
+#endif
     if ( ( (CipByteArray *) attribute->data )->length != data_size ) {
       /*wrong connection size */
       connection_object->correct_originator_to_target_size =
@@ -240,12 +241,13 @@ EipUint16 SetupIoConnectionTargetToOriginatorConnectionPoint(
       data_size -= 2; /* remove 16-bit sequence count length */
       diff_size += 2;
     }
-    if ( (kOpenerProducedDataHasRunIdleHeader) && (data_size > 0)
-         && (!is_heartbeat) ) {
+#ifdef OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER
+    if ( (data_size > 0) && (!is_heartbeat) ) {
       /* we only have an run idle header if it is not an heartbeat connection */
       data_size -= 4; /* remove the 4 bytes needed for run/idle header */
       diff_size += 4;
     }
+#endif
     if ( ( (CipByteArray *) attribute->data )->length != data_size ) {
       /*wrong connection size*/
       connection_object->correct_target_to_originator_size =
@@ -823,9 +825,9 @@ EipStatus SendConnectedData(CipConnectionObject *connection_object) {
   outgoing_message.current_message_position -= 2;
   common_packet_format_data->data_item.length = producing_instance_attributes
                                                 ->length;
-  if (kOpenerProducedDataHasRunIdleHeader) {
-    common_packet_format_data->data_item.length += 4;
-  }
+#ifdef OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER
+  common_packet_format_data->data_item.length += 4;
+#endif /* OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER */
 
   if (kConnectionObjectTransportClassTriggerTransportClass1 ==
       ConnectionObjectGetTransportClassTriggerTransportClass(connection_object) )
@@ -840,10 +842,10 @@ EipStatus SendConnectedData(CipConnectionObject *connection_object) {
                     &outgoing_message.current_message_position);
   }
 
-  if (kOpenerProducedDataHasRunIdleHeader) {
-    AddDintToMessage( g_run_idle_state,
-                      &(outgoing_message.current_message_position) );
-  }
+#ifdef OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER
+  AddDintToMessage( g_run_idle_state,
+                    &(outgoing_message.current_message_position) );
+#endif /* OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER */
 
   memcpy(outgoing_message.current_message_position,
          producing_instance_attributes->data,
@@ -879,14 +881,14 @@ EipStatus HandleReceivedIoConnectionData(
 
   if (data_length > 0) {
     /* we have no heartbeat connection */
-    if (kOpenerConsumedDataHasRunIdleHeader) {
-      EipUint32 nRunIdleBuf = GetDintFromMessage( &(data) );
-      if (g_run_idle_state != nRunIdleBuf) {
-        RunIdleChanged(nRunIdleBuf);
-      }
-      g_run_idle_state = nRunIdleBuf;
-      data_length -= 4;
+#ifdef OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER
+    EipUint32 nRunIdleBuf = GetDintFromMessage( &(data) );
+    if (g_run_idle_state != nRunIdleBuf) {
+      RunIdleChanged(nRunIdleBuf);
     }
+    g_run_idle_state = nRunIdleBuf;
+    data_length -= 4;
+#endif /* OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER */
 
     if (NotifyAssemblyConnectedDataReceived(
           connection_object->consuming_instance, (EipUint8 *const)data,

+ 0 - 10
source/src/ports/POSIX/sample_application/opener_user_conf.h

@@ -89,16 +89,6 @@
  */
 static const MilliSeconds kOpenerTimerTickInMilliSeconds = 10;
 
-/** @brief Define if RUN IDLE data is sent with consumed data
- */
-static const int kOpenerConsumedDataHasRunIdleHeader = 1;
-
-/** @brief Define if RUN IDLE data is to be sent with produced data
- *
- * Per default we don't send run idle headers with produced data
- */
-static const int kOpenerProducedDataHasRunIdleHeader = 0;
-
 #ifdef OPENER_WITH_TRACES
 /* If we have tracing enabled provide print tracing macro */
 #include <stdio.h>