Parcourir la source

Add automatic handling of includes for additional CIP objects

Markus il y a 4 ans
Parent
commit
3d7770a83d

+ 10 - 0
source/CMakeLists.txt

@@ -146,6 +146,16 @@ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall" )
 ####################################################
 # Internal cache holding the available CIP objects #
 ####################################################
+
+# Add definitions for additional CIP Objects
+string(COMPARE NOTEQUAL "${OpENer_ADD_CIP_OBJECTS}" "" OpENer_HAS_ADDITIONAL_OBJECT)
+if (OpENer_HAS_ADDITIONAL_OBJECT)
+    string(REPLACE " " ";" OpENer_ADD_CIP_OBJECTS_LIST ${OpENer_ADD_CIP_OBJECTS})
+    foreach (CIP_OBJECT IN LISTS OpENer_ADD_CIP_OBJECTS_LIST)
+        add_definitions(-D${CIP_OBJECT})
+    endforeach ()
+endif ()
+
 set( OpENer_ADD_CIP_OBJECTS "" CACHE INTERNAL STRING )
 set( OpENer_ADD_CIP_OBJECTS_INCLUDES "" CACHE INTERNAL STRING )
 

+ 24 - 0
source/src/cip/cipcommon.c

@@ -30,6 +30,15 @@
 #include "stdlib.h"
 #include "ciptypes.h"
 
+#if defined(CIP_FILE_OBJECT) && 0 != CIP_FILE_OBJECT
+  #include "OpENerFileObject/cipfile.h"
+#endif
+
+#if defined(CIP_SECURITY_OBJECTS) && 0 != CIP_SECURITY_OBJECTS
+  #include "SecurityObjects/CipSecurityObject/cipsecurity.h"
+  #include "SecurityObjects/EtherNetIPSecurityObject/ethernetipsecurity.h"
+  #include "SecurityObjects/CertificateManagementObject/certificatemanagement.h"
+#endif
 /* private functions*/
 
 EipStatus CipStackInit(const EipUint16 unique_connection_id) {
@@ -52,6 +61,21 @@ EipStatus CipStackInit(const EipUint16 unique_connection_id) {
 #endif
   eip_status = CipQoSInit();
   OPENER_ASSERT(kEipStatusOk == eip_status);
+
+#if defined(CIP_FILE_OBJECT) && 0 != CIP_FILE_OBJECT
+  eip_status = CipFileInit();
+  OPENER_ASSERT(kEipStatusOk == eip_status);
+#endif
+
+#if defined(CIP_SECURITY_OBJECTS) && 0 != CIP_SECURITY_OBJECTS
+  eip_status = CipSecurityInit();
+  OPENER_ASSERT(kEipStatusOk == eip_status);
+  eip_status = EIPSecurityInit();
+  OPENER_ASSERT(kEipStatusOk == eip_status);
+  eip_status = CertificateManagementObjectInit();
+  OPENER_ASSERT(kEipStatusOk == eip_status);
+#endif
+
   /* the application has to be initialized at last */
   eip_status = ApplicationInitialization();
   OPENER_ASSERT(kEipStatusOk == eip_status);

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

@@ -29,6 +29,29 @@
 
 #include "typedefs.h"
 
+/** @brief Set this define if you have a CIP File capable device
+ *
+ *  This define changes the OpENer device configuration in a way that
+ *  the File object is initialized.
+ *
+ *  This define should be set from the CMake command line using
+ *  "-DCIP_FILE_OBJECT:BOOL=ON"
+ */
+#ifndef CIP_FILE_OBJECT
+  #define CIP_FILE_OBJECT 0
+#endif
+
+/** @brief Set this define if you have a CIP Security capable device
+ *
+ *  This define changes the OpENer device configuration in a way that
+ *  the Security related objects are initialized.
+ *
+ *  This define should be set from the CMake command line using
+ *  "-DCIP_SECURITY_OBJECTS:BOOL=ON"
+ */
+#ifndef CIP_SECURITY_OBJECTS
+  #define CIP_SECURITY_OBJECTS 0
+#endif
 
 /** @brief Set this define if you have a DLR capable device
  *