コード例 #1
0
        public void ErrorSerializeTcpTest()
        {
            string      expected = "00-05-00-00-00-03-0A-81-02";
            ModbusError error    = ModbusError.Create(10, 5, 0, 1, ModbusErrorCode.IllegalDataAddress);
            string      jstring  = JsonConvert.SerializeObject(error);
            ModbusError error2   = JsonConvert.DeserializeObject <ModbusError>(jstring);
            string      actual   = System.BitConverter.ToString(error2.Encode());

            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public void ErrorTcpTest()
        {
            string      expected = "00-05-00-00-00-03-0A-81-02";
            ModbusError error    = ModbusError.Create(10, 5, 0, 1, ModbusErrorCode.IllegalDataAddress);

            byte[] msg    = error.Encode();
            string actual = System.BitConverter.ToString(msg);

            Assert.AreEqual(expected, actual);
        }