예제 #1
0
        public static byte[] func16Response(byte device)
        {
            byte[] response = new byte[8];

            response[0] = device;
            response[1] = 0x10;
            response[2] = 0x0;
            response[3] = 0x1;
            response[4] = 0x0;
            response[5] = 0xA;
            byte[] CRC = Modbus.CRC(response.Take(6).ToArray());
            response[6] = CRC[0];
            response[7] = CRC[1];

            return(response);
        }
예제 #2
0
        public static byte[] func3Response(byte[] data, byte device)
        {
            int len = data.Length * 2 + 5;

            byte[] response = new byte[len];
            response[0] = device;
            response[1] = 3;
            response[2] = (byte)data.Length;
            for (int i = 0; i < data.Length; i++)
            {
                response[3 + i * 2] = 0;
                response[4 + i * 2] = data[i];
            }
            byte[] CRC = Modbus.CRC(response.Take(len - 2).ToArray());
            response[len - 2] = CRC[0];
            response[len - 1] = CRC[1];

            string ss = HexConverter.toString(response);

            return(response);
        }