public static ReadDataServiceRequest BuildLogixReadDataRequest(string tagAddress, ushort number, out int requestSize)
        {
            byte[] newIOI = IOI.BuildIOI(tagAddress);

            int pathLen = newIOI.Length;// IOI.BuildIOI(null, tagAddress);
            ReadDataServiceRequest request = new ReadDataServiceRequest();
            request.Service = (byte)ControlNetService.CIP_ReadData;
            request.PathSize = (byte)(pathLen / 2);
            byte[] path = new byte[pathLen];
            Buffer.BlockCopy(newIOI, 0, path, 0, newIOI.Length);
            //IOI.BuildIOI(path, tagAddress);
            request.Path = path;
            request.Elements = number;

            requestSize = request.Size;

            return request;
        }
        public static WriteDataServiceRequest BuildLogixWriteDataRequest(string tagAddress, ushort dataType, ushort elementCount, byte[] data, ushort structHandle = 0x0000)
#endif
		{
            byte[] newIOI = IOI.BuildIOI(tagAddress);

            int pathLen = newIOI.Length;
            WriteDataServiceRequest request = new WriteDataServiceRequest();
            request.Service = (byte)ControlNetService.CIP_WriteData;
            request.PathSize = (byte)(pathLen / 2);
            byte[] path = new byte[pathLen];
            Buffer.BlockCopy(newIOI, 0, path, 0, newIOI.Length);
            request.Path = path;
            request.Elements = elementCount;
            request.DataType = dataType;
            request.StructHandle = structHandle;
            request.Data = data;

            return request;
        }
Exemple #3
0
        public static ReadDataServiceRequest BuildFragmentedReadDataRequest(string tagAddress, ushort number, uint offset, out int requestSize)
        {
            byte[] newIOI = IOI.BuildIOI(tagAddress);

            int pathLen = newIOI.Length;// IOI.BuildIOI(null, tagAddress);
            ReadDataServiceRequest request = new ReadDataServiceRequest();

            request.Service      = (byte)ControlNetService.CIP_ReadDataFragmented;
            request.PathSize     = (byte)(pathLen / 2);
            request.IsFragmented = true;
            request.DataOffset   = offset;
            byte[] path = new byte[pathLen];
            Buffer.BlockCopy(newIOI, 0, path, 0, newIOI.Length);
            //IOI.BuildIOI(path, tagAddress);
            request.Path     = path;
            request.Elements = number;

            requestSize = request.Size;

            return(request);
        }
        public static ReadDataServiceRequest BuildShortReadDataRequest(uint tagInstance, ushort number, ushort size, out int requestSize)
        {
            byte[] newIOI = IOI.BuildIOI(tagInstance);

            int pathLen = newIOI.Length;
            ReadDataServiceRequest request = new ReadDataServiceRequest();
            request.Service = 0x4E;// (byte)ControlNetService.CIP_ReadData;
            request.PathSize = 0x03;
            byte[] path = new byte[] { 0x20, 0xB2, 0x25, 0x00, 0x21, 0x00 };
            request.Path = path;
            request.Elements = number;

            byte[] addData = new byte[10 + newIOI.Length];
            addData[0] = 0x02; addData[1] = 0x00; addData[2] = 0x01; addData[3] = 0x01; addData[4] = 0x01;
            addData[5] = (byte)(size & 0xFF); addData[6] = (byte)((size & 0xFF00) >> 8);
            addData[7] = 0x03; addData[8] = 0x20; addData[9] = 0x6B;
            Buffer.BlockCopy(newIOI, 0, addData, 10, newIOI.Length);
            request.AddtlData = addData;

            requestSize = request.Size;

            return request;
        }