<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

      https://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
  -->
<test:testsuite xmlns:test="https://plc4x.apache.org/schemas/parser-serializer-testsuite.xsd"
                byteOrder="BIG_ENDIAN">

  <name>EIP</name>

  <protocolName>eip</protocolName>
  <outputFlavor>read-write</outputFlavor>

  <testcase>
    <name>Register Session</name>
    <raw>00650004000000000000000000000000000000000000000000010000</raw>
    <root-type>EipPacket</root-type>
    <xml>
      <EipPacket>
        <command dataType="uint" bitLength="16">101</command>
        <packetLength dataType="uint" bitLength="16">4</packetLength>
        <sessionHandle dataType="uint" bitLength="32">0</sessionHandle>
        <status dataType="uint" bitLength="32">0</status>
        <senderContext isList="true">
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
        </senderContext>
        <options dataType="uint" bitLength="32">0</options>
        <EipConnectionRequest>
          <protocolVersion dataType="uint" bitLength="16">1</protocolVersion>
          <flags dataType="uint" bitLength="16">0</flags>
        </EipConnectionRequest>
      </EipPacket>
    </xml>
  </testcase>

  <testcase>
    <name>CIP Read Request</name>
    <raw>
      006F0028000012340000000001000000000000010000000000000000000000020000000000B200185202200624019D05000A4C03910472617465000100010104
    </raw>
    <root-type>EipPacket</root-type>
    <xml>
      <EipPacket>
        <command dataType="uint" bitLength="16">111</command>
        <packetLength dataType="uint" bitLength="16">40</packetLength>
        <sessionHandle dataType="uint" bitLength="32">4660</sessionHandle>
        <status dataType="uint" bitLength="32">0</status>
        <senderContext isList="true">
          <value dataType="uint" bitLength="8">1</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">1</value>
        </senderContext>
        <options dataType="uint" bitLength="32">0</options>
        <CipRRData>
          <reserved dataType="uint" bitLength="32">0</reserved>
          <reserved dataType="uint" bitLength="16">0</reserved>
          <exchange>
            <CipExchange>
              <itemCount dataType="uint" bitLength="16">2</itemCount>
              <nullPtr dataType="uint" bitLength="32">0</nullPtr>
              <unconnectedData dataType="uint" bitLength="16">178</unconnectedData>
              <size dataType="uint" bitLength="16">24</size>
              <service>
                <CipService>
                  <service dataType="uint" bitLength="8">82</service>
                  <CipUnconnectedRequest>
                    <reserved dataType="uint" bitLength="8">2</reserved>
                    <reserved dataType="uint" bitLength="8">32</reserved>
                    <reserved dataType="uint" bitLength="8">6</reserved>
                    <reserved dataType="uint" bitLength="8">36</reserved>
                    <reserved dataType="uint" bitLength="8">1</reserved>
                    <reserved dataType="uint" bitLength="16">40197</reserved>
                    <messageSize dataType="uint" bitLength="16">10</messageSize>
                    <unconnectedService>
                      <CipService>
                        <service dataType="uint" bitLength="8">76</service>
                        <CipReadRequest>
                          <requestPathSize dataType="int" bitLength="8">3</requestPathSize>
                          <tag dataType="byte" bitLength="48">0x910472617465</tag>
                          <elementNb dataType="uint" bitLength="16">1</elementNb>
                        </CipReadRequest>
                      </CipService>
                    </unconnectedService>
                    <route dataType="uint" bitLength="16">1</route>
                    <backPlane dataType="int" bitLength="8">1</backPlane>
                    <slot dataType="int" bitLength="8">4</slot>
                  </CipUnconnectedRequest>
                </CipService>
              </service>
            </CipExchange>
          </exchange>
        </CipRRData>
      </EipPacket>
    </xml>
  </testcase>

  <testcase>
    <name>CIP Read Response</name>
    <raw>006F001A000012340000000001000000000000010000000000000000000000020000000000B2000ACC00000000C400000216</raw>
    <root-type>EipPacket</root-type>
    <xml>
      <EipPacket>
        <command dataType="uint" bitLength="16">111</command>
        <packetLength dataType="uint" bitLength="16">26</packetLength>
        <sessionHandle dataType="uint" bitLength="32">4660</sessionHandle>
        <status dataType="uint" bitLength="32">0</status>
        <senderContext isList="true">
          <value dataType="uint" bitLength="8">1</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">1</value>
        </senderContext>
        <options dataType="uint" bitLength="32">0</options>
        <CipRRData>
          <reserved dataType="uint" bitLength="32">0</reserved>
          <reserved dataType="uint" bitLength="16">0</reserved>
          <exchange>
            <CipExchange>
              <itemCount dataType="uint" bitLength="16">2</itemCount>
              <nullPtr dataType="uint" bitLength="32">0</nullPtr>
              <unconnectedData dataType="uint" bitLength="16">178</unconnectedData>
              <size dataType="uint" bitLength="16">10</size>
              <service>
                <CipService>
                  <service dataType="uint" bitLength="8">204</service>
                  <CipReadResponse>
                    <reserved dataType="uint" bitLength="8">0</reserved>
                    <status dataType="uint" bitLength="8">0</status>
                    <extStatus dataType="uint" bitLength="8">0</extStatus>
                    <dataType>
                      <CIPDataTypeCode dataType="uint" bitLength="16" stringRepresentation="DINT">196</CIPDataTypeCode>
                    </dataType>
                    <data dataType="byte" bitLength="32">0x00000216</data>
                  </CipReadResponse>
                </CipService>
              </service>
            </CipExchange>
          </exchange>
        </CipRRData>
      </EipPacket>
    </xml>
  </testcase>

  <testcase>
    <name>CIP Write Request</name>
    <raw>
      006F0034000012340000000001000000000000010000000000000000000000020000000000B200245202200624019D0500164D069116436172746F6E53697A6500C400010000000E00010104
    </raw>
    <root-type>EipPacket</root-type>
    <xml>
      <EipPacket>
        <command dataType="uint" bitLength="16">111</command>
        <packetLength dataType="uint" bitLength="16">52</packetLength>
        <sessionHandle dataType="uint" bitLength="32">4660</sessionHandle>
        <status dataType="uint" bitLength="32">0</status>
        <senderContext isList="true">
          <value dataType="uint" bitLength="8">1</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">1</value>
        </senderContext>
        <options dataType="uint" bitLength="32">0</options>
        <CipRRData>
          <reserved dataType="uint" bitLength="32">0</reserved>
          <reserved dataType="uint" bitLength="16">0</reserved>
          <exchange>
            <CipExchange>
              <itemCount dataType="uint" bitLength="16">2</itemCount>
              <nullPtr dataType="uint" bitLength="32">0</nullPtr>
              <unconnectedData dataType="uint" bitLength="16">178</unconnectedData>
              <size dataType="uint" bitLength="16">36</size>
              <service>
                <CipService>
                  <service dataType="uint" bitLength="8">82</service>
                  <CipUnconnectedRequest>
                    <reserved dataType="uint" bitLength="8">2</reserved>
                    <reserved dataType="uint" bitLength="8">32</reserved>
                    <reserved dataType="uint" bitLength="8">6</reserved>
                    <reserved dataType="uint" bitLength="8">36</reserved>
                    <reserved dataType="uint" bitLength="8">1</reserved>
                    <reserved dataType="uint" bitLength="16">40197</reserved>
                    <messageSize dataType="uint" bitLength="16">22</messageSize>
                    <unconnectedService>
                      <CipService>
                        <service dataType="uint" bitLength="8">77</service>
                        <CipWriteRequest>
                          <requestPathSize dataType="int" bitLength="8">6</requestPathSize>
                          <tag dataType="byte" bitLength="96">0x9116436172746f6e53697a65</tag>
                          <dataType>
                            <CIPDataTypeCode dataType="uint" bitLength="16" stringRepresentation="DINT">196</CIPDataTypeCode>
                          </dataType>
                          <elementNb dataType="uint" bitLength="16">1</elementNb>
                          <data dataType="byte" bitLength="32">0x0000000e</data>
                        </CipWriteRequest>
                      </CipService>
                    </unconnectedService>
                    <route dataType="uint" bitLength="16">1</route>
                    <backPlane dataType="int" bitLength="8">1</backPlane>
                    <slot dataType="int" bitLength="8">4</slot>
                  </CipUnconnectedRequest>
                </CipService>
              </service>
            </CipExchange>
          </exchange>
        </CipRRData>
      </EipPacket>
    </xml>
  </testcase>

  <testcase>
    <name>CIP Write Response</name>
    <raw>006F0014000012340000000001000000000000010000000000000000000000020000000000B20004CD000000</raw>
    <root-type>EipPacket</root-type>
    <xml>
      <EipPacket>
        <command dataType="uint" bitLength="16">111</command>
        <packetLength dataType="uint" bitLength="16">20</packetLength>
        <sessionHandle dataType="uint" bitLength="32">4660</sessionHandle>
        <status dataType="uint" bitLength="32">0</status>
        <senderContext isList="true">
          <value dataType="uint" bitLength="8">1</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">0</value>
          <value dataType="uint" bitLength="8">1</value>
        </senderContext>
        <options dataType="uint" bitLength="32">0</options>
        <CipRRData>
          <reserved dataType="uint" bitLength="32">0</reserved>
          <reserved dataType="uint" bitLength="16">0</reserved>
          <exchange>
            <CipExchange>
              <itemCount dataType="uint" bitLength="16">2</itemCount>
              <nullPtr dataType="uint" bitLength="32">0</nullPtr>
              <unconnectedData dataType="uint" bitLength="16">178</unconnectedData>
              <size dataType="uint" bitLength="16">4</size>
              <service>
                <CipService>
                  <service dataType="uint" bitLength="8">205</service>
                  <CipWriteResponse>
                    <reserved dataType="uint" bitLength="8">0</reserved>
                    <status dataType="uint" bitLength="8">0</status>
                    <extStatus dataType="uint" bitLength="8">0</extStatus>
                  </CipWriteResponse>
                </CipService>
              </service>
            </CipExchange>
          </exchange>
        </CipRRData>
      </EipPacket>
    </xml>
  </testcase>


</test:testsuite>