示例#1
0
        public void BuildReadDiscreteCommandTest( )
        {
            ModbusTcpNet modbusTcp = new ModbusTcpNet("127.0.0.1");

            OperateResult <byte[]> command = modbusTcp.BuildReadDiscreteCommand("s=2;100", 10);

            Assert.IsTrue(command.IsSuccess, "command create failed");

            if (command.Content[2] == 0x00 &&
                command.Content[3] == 0x00 &&
                command.Content[4] == 0x00 &&
                command.Content[5] == 0x06 &&
                command.Content[6] == 0x02 &&
                command.Content[7] == 0x02 &&
                command.Content[8] == 0x00 &&
                command.Content[9] == 0x64 &&
                command.Content[10] == 0x00 &&
                command.Content[11] == 0x0A)
            {
            }
            else
            {
                Assert.Fail("command check failed : " + HslCommunication.BasicFramework.SoftBasic.ByteToHexString(command.Content, ' '));
            }
        }