Răsfoiți Sursa

Merge branch 'Issue_109'

CapXilinx 8 ani în urmă
părinte
comite
991c18ca25

+ 4 - 2
source/src/cip/cipconnectionmanager.c

@@ -766,8 +766,7 @@ void GeneralConnectionConfiguration(ConnectionObject *connection_object) {
                                                             / 1000 );
   }
 
-  connection_object->production_inhibit_timer = connection_object
-                                                ->production_inhibit_time = 0;
+  connection_object->production_inhibit_timer = 0;
 
   /*setup the preconsumption timer: max(ConnectionTimeoutMultiplier * ExpectedPacketRate, 10s) */
   connection_object->inactivity_watchdog_timer =
@@ -1361,6 +1360,7 @@ EipUint8 ParseConnectionPath(
           GetPathNetworkSegmentSubtype(message);
         if (kNetworkSegmentSubtypeProductionInhibitTimeInMilliseconds
             == network_segment_subtype) {
+          OPENER_TRACE_INFO("PIT segment available - value: %u\n",message[1]);
           connection_object->production_inhibit_time = message[1];
           message += 2;
           remaining_path_size -= 1;
@@ -1556,6 +1556,8 @@ EipUint8 ParseConnectionPath(
     }
   }
 
+  OPENER_TRACE_INFO("Resulting PIT value: %u\n",
+                    connection_object->production_inhibit_time);
   /*save back the current position in the stream allowing followers to parse anything thats still there*/
   message_router_request->data = message;
   return kEipStatusOk;

+ 2 - 0
source/src/cip/cipconnectionmanager.h

@@ -102,6 +102,8 @@ typedef enum {
   kConnectionManagerExtendedStatusCodeMismatchedTToONetworkConnectionPriority =
     0x0136,
   kConnectionManagerExtendedStatusCodeMismatchedTransportClass = 0x0137,
+  kConnectionManagerExtendedStatusCodeMismatchedTToOProductionInhibitTimeSegment
+    = 0x0139,
   kConnectionManagerExtendedStatusCodeConnectionTimedOut = 0x0203,
   kConnectionManagerExtendedStatusCodeUnconnectedRequestTimedOut = 0x0204,
   kConnectionManagerExtendedStatusCodeErrorParameterErrorInUnconnectedSendService

+ 17 - 19
source/src/cip/cipioconnection.c

@@ -95,11 +95,12 @@ unsigned int g_config_data_length = 0; /**< length of g_config_data_buffer. Init
 
 EipUint32 g_run_idle_state; /**< buffer for holding the run idle information. */
 
-EipUint16 ProcessProductionInhibitTime(ConnectionObject *io_connection_object
-                                       ) {
+EipUint16 ProcessProductionInhibitTime(ConnectionObject *io_connection_object)
+{
   if ( kProductionTriggerCyclic
        == GetProductionTrigger(io_connection_object) ) {
     if ( 256 == GetProductionInhibitTime(io_connection_object) ) {
+      OPENER_TRACE_INFO("No PIT segment available\n");
       /* there was no PIT segment in the connection path; set PIT to one fourth of RPI */
       SetProductionInhibitTime(
         GetTargetToOriginatorRequestedPackedInterval(io_connection_object)
@@ -119,9 +120,7 @@ EipUint16 ProcessProductionInhibitTime(ConnectionObject *io_connection_object
 }
 
 CipConnectionObjectTransportClassTriggerClass GetConnectionObjectTransportClass(
-  const ConnectionObject *const connection_object
-  )
-{
+  const ConnectionObject *const connection_object) {
   const unsigned int kTransportClassMask = 0x0F;
 
   switch(connection_object->transport_type_class_trigger &
@@ -137,8 +136,7 @@ CipConnectionObjectTransportClassTriggerClass GetConnectionObjectTransportClass(
   return kCipConnectionObjectTransportClassTriggerClassInvalid;
 }
 
-void SetIoConnectionCallbacks(ConnectionObject *const io_connection_object
-                              ) {
+void SetIoConnectionCallbacks(ConnectionObject *const io_connection_object) {
   io_connection_object->connection_close_function = CloseIoConnection;
   io_connection_object->connection_timeout_function = HandleIoConnectionTimeOut;
   io_connection_object->connection_send_data_function = SendConnectedData;
@@ -232,6 +230,12 @@ EipUint16 SetupIoConnectionTargetToOriginatorConnectionPoint(
         return kConnectionManagerExtendedStatusCodeMismatchedTransportClass;
       }
 
+      if( GetProductionInhibitTime(io_connection_object) !=
+          GetProductionInhibitTime(iterator) ) {
+        return
+          kConnectionManagerExtendedStatusCodeMismatchedTToOProductionInhibitTimeSegment;
+      }
+
     }
 
     iterator = iterator->next_connection_object;
@@ -640,8 +644,7 @@ EipStatus OpenMulticastConnection(
   return kEipStatusOk;
 }
 
-EipUint16 HandleConfigData(ConnectionObject *connection_object
-                           ) {
+EipUint16 HandleConfigData(ConnectionObject *connection_object) {
 
   CipClass *const assembly_class = GetCipClass(kCipAssemblyClassCode);
   EipUint16 connection_manager_status = 0;
@@ -688,8 +691,7 @@ EipUint16 HandleConfigData(ConnectionObject *connection_object
   return connection_manager_status;
 }
 
-void CloseIoConnection(ConnectionObject *connection_object
-                       ) {
+void CloseIoConnection(ConnectionObject *connection_object) {
 
   CheckIoConnectionEvent(connection_object->connection_path.connection_point[
                            kConnectionPointConsumer],
@@ -738,8 +740,7 @@ void CloseIoConnection(ConnectionObject *connection_object
     connection_object);
 }
 
-void HandleIoConnectionTimeOut(ConnectionObject *connection_object
-                               ) {
+void HandleIoConnectionTimeOut(ConnectionObject *connection_object) {
   CheckIoConnectionEvent(connection_object->connection_path.connection_point[0],
                          connection_object->connection_path.connection_point[1],
                          kIoConnectionEventTimedOut);
@@ -786,8 +787,7 @@ void HandleIoConnectionTimeOut(ConnectionObject *connection_object
   connection_object->connection_close_function(connection_object);
 }
 
-EipStatus SendConnectedData(ConnectionObject *connection_object
-                            ) {
+EipStatus SendConnectedData(ConnectionObject *connection_object) {
 
   /* TODO think of adding an own send buffer to each connection object in order to preset up the whole message on connection opening and just change the variable data items e.g., sequence number */
 
@@ -903,8 +903,7 @@ EipStatus HandleReceivedIoConnectionData(
   return kEipStatusOk;
 }
 
-EipStatus OpenCommunicationChannels(ConnectionObject *connection_object
-                                    ) {
+EipStatus OpenCommunicationChannels(ConnectionObject *connection_object) {
 
   EipStatus eip_status = kEipStatusOk;
   /*get pointer to the CPF data, currently we have just one global instance of the struct. This may change in the future*/
@@ -966,8 +965,7 @@ EipStatus OpenCommunicationChannels(ConnectionObject *connection_object
 }
 
 void CloseCommunicationChannelsAndRemoveFromActiveConnectionsList(
-  ConnectionObject *connection_object
-  ) {
+  ConnectionObject *connection_object) {
   IApp_CloseSocket_udp(
     connection_object->socket[kUdpCommuncationDirectionConsuming]);