Browse Source

Add OPENER_IS_DLR_DEVICE as configuration option

OpENer can now be configured with OPENER_IS_DLR_DEVICE that should change
OpENer to become a DLR capable device. This is still work in progress.

At the moment it only adds needed defines in the opener_user_conf.h files
and the Ethernet Link object gains the capability to have an interface
label that is not empty.

Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu>
Stefan Mätje 6 years ago
parent
commit
f2ba1dfa98

+ 5 - 0
source/CMakeLists.txt

@@ -45,6 +45,11 @@ if(OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER)
   add_definitions(-DOPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER)
 endif()
 
+option(OPENER_IS_DLR_DEVICE "Is OpENer built with support for a basic DLR device?" FALSE)
+if (OPENER_IS_DLR_DEVICE)
+  add_definitions(-DOPENER_IS_DLR_DEVICE)
+endif()
+
 # The number of bytes used for the buffer that will be used for generating any reply data of messages.
 # There are two uses in OpENer:
 #   1. Explicit messages will use this buffer to store the data generated by the request

+ 19 - 1
source/src/cip/cipethernetlink.c

@@ -13,6 +13,8 @@
  * - Attribute  2: Interface Flags
  * - Attribute  3: Physical Address (Ethernet MAC)
  * - Attribute 10: Interface Label
+ *    If the define OPENER_ETHLINK_LABEL_ENABLE is set then this attribute
+ *    has a string content ("PORT 1" by default on instance 1).
  * - Attribute 11: Interface Capabilities
  *
  */
@@ -28,6 +30,17 @@
 #include "opener_api.h"
 #include "trace.h"
 
+#ifndef OPENER_ETHLINK_LABEL_ENABLE
+  #define OPENER_ETHLINK_LABEL_ENABLE  0
+#endif
+
+#if defined(OPENER_ETHLINK_LABEL_ENABLE) && OPENER_ETHLINK_LABEL_ENABLE != 0
+  #define INTERFACE_LABEL_ACCESS_MODE kGetableSingleAndAll
+  #define INTERFACE_LABEL             "PORT 1"
+#else
+  #define INTERFACE_LABEL_ACCESS_MODE kGetableAll
+#endif
+
 /** @brief Type definition of the Interface Control attribute (#6)
  *
  *  This is used only internally at the moment.
@@ -132,6 +145,10 @@ EipStatus CipEthernetLinkInit() {
   /* set attributes to initial values */
   g_ethernet_link.interface_speed = 100;
   g_ethernet_link.interface_flags = 0xF; /* successful speed and duplex neg, full duplex active link, TODO in future it should be checked if link is active */
+#if defined(OPENER_ETHLINK_LABEL_ENABLE) && OPENER_ETHLINK_LABEL_ENABLE != 0
+  g_ethernet_link.interface_label.length = sizeof INTERFACE_LABEL -1;
+  g_ethernet_link.interface_label.string = (EipByte *)INTERFACE_LABEL;
+#endif
   g_ethernet_link.interface_caps.capability_bits = kEthLinkCapAutoNeg;
   g_ethernet_link.interface_caps.speed_duplex_selector =
     kEthLinkSpeedDpx_100_FD;
@@ -165,7 +182,8 @@ EipStatus CipEthernetLinkInit() {
     InsertAttribute(ethernet_link_instance, 9, kCipUsint,
                     &dummy_attribute_usint, kGetableAll);
     InsertAttribute(ethernet_link_instance, 10, kCipShortString,
-                    &g_ethernet_link.interface_label, kGetableAll);
+                    &g_ethernet_link.interface_label,
+                    INTERFACE_LABEL_ACCESS_MODE);
     InsertAttribute(ethernet_link_instance, 11, kCipAny,
                     &g_ethernet_link.interface_caps, kGetableSingleAndAll);
   } else {

+ 45 - 16
source/src/ports/MINGW/sample_application/opener_user_conf.h

@@ -26,8 +26,47 @@
 
 typedef unsigned short in_port_t;
 
-/** @brief Identity configuration of the device */
-#include "devicedata.h"
+/** Set this define if you have a DLR capable device
+ *
+ * This define changes the OpENer device configuration in a way that
+ *  the DLR object is initialized and the other configuration stuff
+ *  that is mandatory for a DLR device is also enabled.
+ */
+#ifndef OPENER_IS_DLR_DEVICE
+  #define OPENER_IS_DLR_DEVICE  0
+#endif
+
+#if defined(OPENER_IS_DLR_DEVICE) && OPENER_IS_DLR_DEVICE != 0
+  /* Enable all the stuff the DLR device depends on */
+  #define OPENER_TCPIP_IFACE_CFG_SETTABLE 1
+  #define OPENER_ETHLINK_LABEL_ENABLE  1
+#endif
+
+
+/* Control some configuration of TCP/IP object */
+
+/** Set this define if you want the Interface Configuration to be settable
+ *
+ * This define makes the TCP/IP object's Interface Configuration (attribute #5)
+ *  and the Host Name (attribute #6) settable. This is required as per ODVA
+ *  publication 70 "Recommended Functionality for EIP Devices" Version
+ *  10. This also enables the storage of these attributes in NV data
+ *  storage area.
+ */
+#ifndef OPENER_TCPIP_IFACE_CFG_SETTABLE
+  #define OPENER_TCPIP_IFACE_CFG_SETTABLE 0
+#endif
+
+/* Control some configuration of Ethernet Link object */
+
+/** Set this define if you want a real interface label for the Ethernet Link object
+ *
+ * This define adds a interface label to the Ethernet Link object that has a string
+ *  length greater than zero. It defaults to "PORT 1".
+ */
+#ifndef OPENER_ETHLINK_LABEL_ENABLE
+  #define OPENER_ETHLINK_LABEL_ENABLE  0
+#endif
 
 /** @brief Define the number of objects that may be used in connections
  *
@@ -38,7 +77,7 @@ typedef unsigned short in_port_t;
 #define OPENER_CIP_NUM_APPLICATION_SPECIFIC_CONNECTABLE_OBJECTS 1
 
 /** @brief Define the number of supported explicit connections.
- *  According to ODVA's PUB 70 this number should be greater than 6.
+ *  According to ODVA's PUB 70 this number should be equal or greater than 6.
  */
 #define OPENER_CIP_NUM_EXPLICIT_CONNS 6
 
@@ -75,19 +114,9 @@ typedef unsigned short in_port_t;
  */
 #define OPENER_NUMBER_OF_SUPPORTED_SESSIONS 20
 
-/** @brief  The time in ms of the timer used in this implementations
- */
-static const int 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
+/** @brief The time in ms of the timer used in this implementations, time base for time-outs and production timers
  */
-static const int kOpenerProducedDataHasRunIdleHeader = 0;
+static const MilliSeconds kOpenerTimerTickInMilliSeconds = 10;
 
 #ifdef OPENER_WITH_TRACES
 /* If we have tracing enabled provide print tracing macro */
@@ -135,7 +164,7 @@ static const int kOpenerProducedDataHasRunIdleHeader = 0;
 #endif
 
 /** @brief The number of bytes used for the Ethernet message buffer on
- * the pc port. For different platforms it may makes sense to
+ * the PC port. For different platforms it may makes sense to
  * have more than one buffer.
  *
  *  This buffer size will be used for any received message.

+ 15 - 2
source/src/ports/POSIX/sample_application/opener_user_conf.h

@@ -37,15 +37,18 @@
  *  that is mandatory for a DLR device is also enabled.
  */
 #ifndef OPENER_IS_DLR_DEVICE
-  #define OPENER_IS_DLR_DEVICE  0 /* not yet implemented */
+  #define OPENER_IS_DLR_DEVICE  0
 #endif
 
 #if defined(OPENER_IS_DLR_DEVICE) && OPENER_IS_DLR_DEVICE != 0
   /* Enable all the stuff the DLR device depends on */
   #define OPENER_TCPIP_IFACE_CFG_SETTABLE 1
+  #define OPENER_ETHLINK_LABEL_ENABLE  1
 #endif
 
 
+/* Control some configuration of TCP/IP object */
+
 /** Set this define if you want the Interface Configuration to be settable
  *
  * This define makes the TCP/IP object's Interface Configuration (attribute #5)
@@ -58,6 +61,16 @@
   #define OPENER_TCPIP_IFACE_CFG_SETTABLE 0
 #endif
 
+/* Control some configuration of Ethernet Link object */
+
+/** Set this define if you want a real interface label for the Ethernet Link object
+ *
+ * This define adds a interface label to the Ethernet Link object that has a string
+ *  length greater than zero. It defaults to "PORT 1".
+ */
+#ifndef OPENER_ETHLINK_LABEL_ENABLE
+  #define OPENER_ETHLINK_LABEL_ENABLE  0
+#endif
 
 /** @brief Define the number of objects that may be used in connections
  *
@@ -79,7 +92,7 @@
  */
 #define OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS 1
 
-/** @brief  Define the number of supported input only connections.
+/** @brief Define the number of supported input only connections.
  *  Each of these connections has to be configured with the function
  *  void configureInputOnlyConnectionPoint(unsigned int pa_unConnNum, unsigned int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned int pa_unConfigAssembly)
  *

+ 47 - 4
source/src/ports/WIN32/sample_application/opener_user_conf.h

@@ -31,6 +31,49 @@ typedef unsigned short in_port_t;
 
 #include "typedefs.h"
 
+
+/** Set this define if you have a DLR capable device
+ *
+ * This define changes the OpENer device configuration in a way that
+ *  the DLR object is initialized and the other configuration stuff
+ *  that is mandatory for a DLR device is also enabled.
+ */
+#ifndef OPENER_IS_DLR_DEVICE
+  #define OPENER_IS_DLR_DEVICE  0
+#endif
+
+#if defined(OPENER_IS_DLR_DEVICE) && OPENER_IS_DLR_DEVICE != 0
+  /* Enable all the stuff the DLR device depends on */
+  #define OPENER_TCPIP_IFACE_CFG_SETTABLE 1
+  #define OPENER_ETHLINK_LABEL_ENABLE  1
+#endif
+
+
+/* Control some configuration of TCP/IP object */
+
+/** Set this define if you want the Interface Configuration to be settable
+ *
+ * This define makes the TCP/IP object's Interface Configuration (attribute #5)
+ *  and the Host Name (attribute #6) settable. This is required as per ODVA
+ *  publication 70 "Recommended Functionality for EIP Devices" Version
+ *  10. This also enables the storage of these attributes in NV data
+ *  storage area.
+ */
+#ifndef OPENER_TCPIP_IFACE_CFG_SETTABLE
+  #define OPENER_TCPIP_IFACE_CFG_SETTABLE 0
+#endif
+
+/* Control some configuration of Ethernet Link object */
+
+/** Set this define if you want a real interface label for the Ethernet Link object
+ *
+ * This define adds a interface label to the Ethernet Link object that has a string
+ *  length greater than zero. It defaults to "PORT 1".
+ */
+#ifndef OPENER_ETHLINK_LABEL_ENABLE
+  #define OPENER_ETHLINK_LABEL_ENABLE  0
+#endif
+
 /** @brief Define the number of objects that may be used in connections
  *
  *  This number needs only to consider additional objects. Connections to
@@ -40,7 +83,7 @@ typedef unsigned short in_port_t;
 #define OPENER_CIP_NUM_APPLICATION_SPECIFIC_CONNECTABLE_OBJECTS 1
 
 /** @brief Define the number of supported explicit connections.
- *  According to ODVA's PUB 70 this number should be greater than 6.
+ *  According to ODVA's PUB 70 this number should be equal or greater than 6.
  */
 #define OPENER_CIP_NUM_EXPLICIT_CONNS 6
 
@@ -77,9 +120,9 @@ typedef unsigned short in_port_t;
  */
 #define OPENER_NUMBER_OF_SUPPORTED_SESSIONS 20
 
-/** @brief  The time in ms of the timer used in this implementations
+/** @brief The time in ms of the timer used in this implementations, time base for time-outs and production timers
  */
-static const int kOpenerTimerTickInMilliSeconds = 10;
+static const MilliSeconds kOpenerTimerTickInMilliSeconds = 10;
 
 #ifdef OPENER_WITH_TRACES
 /* If we have tracing enabled provide print tracing macro */
@@ -130,7 +173,7 @@ static const int kOpenerTimerTickInMilliSeconds = 10;
 #endif
 
 /** @brief The number of bytes used for the Ethernet message buffer on
- * the pc port. For different platforms it may makes sense to
+ * the PC port. For different platforms it may makes sense to
  * have more than one buffer.
  *
  *  This buffer size will be used for any received message.