Browse Source

finished work on feature request# 3571880: TCP/IP Object Instance Attributes ID 8 and ID 9
updated stc file

Alois Zoitl 13 years ago
parent
commit
603e387ae2
2 changed files with 57 additions and 8 deletions
  1. 4 4
      data/OpENerPC.stc
  2. 53 4
      src/cip/ciptcpipinterface.c

+ 4 - 4
data/OpenerPC.stc → data/OpENerPC.stc

@@ -1,10 +1,10 @@
- StcRev Data |1.21|A-8|OpENer_AZRAEL|1335117429| DevData |255|0|500|500|500,500|X||ENet|
+ StcRev Data |1.21|A-8|OpENer|1352323903| DevData |255|0|500|500|500,500|X||ENet|
 [<00>]-------|OpENer PC||
   General    |3.8|EtherNet/IP Vol 2, Ed 1.9||1.2|Rockwell Automation/Allen-Bradley|1|65001|
   DevProfile |12|Communications Adapter|,04,05,06,07,08,09,10,11,15,16,29,30,32,33,43,55,243,244,245,246,67,71,72|
   PhysConf   ||X| |X| | | | |0|X| | |
   LEDs       | | | | |
-  IP MAC Set | |X| |192.168.0.2| | ||00:00:00:00:00:00| |
+  IP MAC Set | |X| |192.168.0.1| | ||00:00:00:00:00:00| |
   CRate Set  |X| | |X| | ||
   CRate Sup  | |X| | |X|
   Net Behavi | | ||| | | | | | | |
@@ -120,7 +120,7 @@
   CAL        | | | | | | | |
   CS         |X|X|
   CSP        |||
-  IAG        |X|X|X|X|X|X| | |
+  IAG        |X|X|X|X|X|X|X|X|
   IAS        | | | | | | | | |
   IAL        | =(1,17)| =(4)| | | | | =(1..255)| |
   IS         |X| |X|X|
@@ -135,7 +135,7 @@
   CSP        ||||
   IAG        |X|X|X| | | | | | | |
   IAS        | | | | | | | | | | |
-  IAL        | =(0,100)| |MAC address (00:15:C5:BF:D0:87)| | | | | | | |
+  IAL        | =(0,100)| |MAC address (00:00:00:00:00:00)| | | | | | | |
   IS         |X|X| | |
   ISP        |||||
   VSA        | |

+ 53 - 4
src/cip/ciptcpipinterface.c

@@ -55,6 +55,10 @@ EIP_STATUS
 getAttributeSingleTCPIPInterface(S_CIP_Instance *pa_pstInstance,
     S_CIP_MR_Request *pa_pstMRRequest, S_CIP_MR_Response *pa_pstMRResponse);
 
+EIP_STATUS
+getAttributeAllTCPIPInterface(S_CIP_Instance * pa_pstInstance,
+    S_CIP_MR_Request * pa_stMRRequest, S_CIP_MR_Response * pa_stMRResponse);
+
 EIP_STATUS
 configureNetworkInterface(const char *pa_acIpAdress,
     const char *pa_acSubNetMask, const char *pa_acGateway)
@@ -186,7 +190,8 @@ CIP_TCPIP_Interface_Init()
   insertService(p_stTCPIPClass, CIP_GET_ATTRIBUTE_SINGLE,
       &getAttributeSingleTCPIPInterface, "GetAttributeSingleTCPIPInterface");
 
-  /*FIXME fix get attribute all issues */
+  insertService(p_stTCPIPClass, CIP_GET_ATTRIBUTE_ALL,
+      &getAttributeAllTCPIPInterface, "SetAttributeSingleTCPIPInterface");
 
   insertService(p_stTCPIPClass, CIP_SET_ATTRIBUTE_SINGLE,
       &setAttributeSingleTCP, "SetAttributeSingle");
@@ -232,10 +237,11 @@ getAttributeSingleTCPIPInterface(S_CIP_Instance *pa_pstInstance,
       pa_pstMRResponse->DataLength += encodeData(CIP_UINT,
           &(g_stMultiCastconfig.m_unNumMcast), &paMsg);
 
-      EIP_UINT32 unMultiCastAddr = ntohl(g_stMultiCastconfig.m_unMcastStartAddr);
+      EIP_UINT32 unMultiCastAddr = ntohl(
+          g_stMultiCastconfig.m_unMcastStartAddr);
 
-      pa_pstMRResponse->DataLength += encodeData(CIP_UDINT,
-          &unMultiCastAddr, &paMsg);
+      pa_pstMRResponse->DataLength += encodeData(CIP_UDINT, &unMultiCastAddr,
+          &paMsg);
     }
   else
     {
@@ -245,3 +251,46 @@ getAttributeSingleTCPIPInterface(S_CIP_Instance *pa_pstInstance,
   return nRetVal;
 }
 
+EIP_STATUS
+getAttributeAllTCPIPInterface(S_CIP_Instance * pa_pstInstance,
+    S_CIP_MR_Request * pa_stMRRequest, S_CIP_MR_Response * pa_stMRResponse)
+{
+
+  int j;
+  EIP_UINT8 *ptmp;
+  int nAttrNum;
+  S_CIP_attribute_struct *pstAttribute;
+
+  ptmp = pa_stMRResponse->Data; /* pointer into the reply */
+  pstAttribute = pa_pstInstance->pstAttributes;
+
+  for (j = 0; j < pa_pstInstance->pstClass->nNr_of_Attributes; j++) /* for each instance attribute of this class */
+    {
+      nAttrNum = pstAttribute->CIP_AttributNr;
+      if (nAttrNum < 32
+          && (pa_pstInstance->pstClass->nGetAttrAllMask & 1 << nAttrNum)) /* only return attributes that are flagged as being part of GetAttributeALl */
+        {
+          pa_stMRRequest->RequestPath.AttributNr = nAttrNum;
+
+          if (8 == nAttrNum)
+            { /* insert 6 zeros for the required empty safety network number according to Table 5-3.10 */
+              memset(pa_stMRResponse->Data, 0, 6);
+              pa_stMRResponse->Data += 6;
+            }
+
+          if (EIP_OK_SEND
+              != getAttributeSingleTCPIPInterface(pa_pstInstance,
+                  pa_stMRRequest, pa_stMRResponse))
+            {
+              pa_stMRResponse->Data = ptmp;
+              return EIP_ERROR;
+            }
+          pa_stMRResponse->Data += pa_stMRResponse->DataLength;
+        }
+      pstAttribute++;
+    }
+  pa_stMRResponse->DataLength = pa_stMRResponse->Data - ptmp;
+  pa_stMRResponse->Data = ptmp;
+
+  return EIP_OK_SEND;
+}