Ejemplo n.º 1
0
        public static byte[] makeConnectPacket(ABContext context)
        {
            byte[] packet;
            ENIP   ip = new ENIP(ENIP.CMD_GET_SESSION);

            ip.setSizes(0);
            int size = ip.size();

            packet = new byte[size];
            int offset = 0;

            try {
                ip.write(packet, offset, context); offset += ip.size();
                return(packet);
            } catch (Exception e) {
                Console.WriteLine(e.ToString());
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static byte[] makeWritePacket(String tag, byte type, byte[] data, ABContext context)
        {
            byte[]      packet;
            ENIP        ip  = new ENIP(ENIP.CMD_RR_DATA);
            CIP_Request cip = new CIP_Request();

            cip.setWrite(tag, type, data);
            ip.setSizes(cip.size());
            int size = ip.size() + cip.size();

            packet = new byte[size];
            int offset = 0;

            try {
                ip.write(packet, offset, context); offset += ip.size();
                cip.write(packet, offset);
                return(packet);
            } catch (Exception e) {
                Console.WriteLine(e.ToString());
                return(null);
            }
        }