Ejemplo n.º 1
0
 public void CalculateLrcNull()
 {
     ModbusUtility.CalculateLrc(null);
     Assert.Fail();
 }
Ejemplo n.º 2
0
		public void CalculateLrc()
		{
			ReadCoilsInputsRequest request = new ReadCoilsInputsRequest(Modbus.ReadCoils, 1, 1, 10);
			Assert.AreEqual(243, ModbusUtility.CalculateLrc(new byte[] { 1, 1, 0, 1, 0, 10 }));
		}
 internal override bool ChecksumsMatch(IModbusMessage message, byte[] messageFrame)
 {
     return(ModbusUtility.CalculateLrc(message.MessageFrame) == messageFrame[messageFrame.Length - 1]);
 }
Ejemplo n.º 4
0
		public void CalculateLrcEmpty()
		{
			Assert.AreEqual(0, ModbusUtility.CalculateLrc(new byte[] {}));
		}
Ejemplo n.º 5
0
		public void CalculateLrc2()
		{
			//: 02 01 0000 0001 FC
			ReadCoilsInputsRequest request = new ReadCoilsInputsRequest(Modbus.ReadCoils, 2, 0, 1);			
			Assert.AreEqual(252, ModbusUtility.CalculateLrc(new byte[] { 2, 1, 0, 0, 0, 1}));
		}
Ejemplo n.º 6
0
        public void CreateResponse_SlaveException()
        {
            ModbusTransport transport = new ModbusAsciiTransport(MockRepository.GenerateStub <IStreamResource>());

            byte[]         frame   = { 2, 129, 2 };
            IModbusMessage message = transport.CreateResponse <ReadCoilsInputsResponse>(frame.Concat(SequenceUtility.ToSequence(ModbusUtility.CalculateLrc(frame))).ToArray());

            Assert.IsTrue(message is SlaveExceptionResponse);
        }
Ejemplo n.º 7
0
 public void CalculateLrcNull()
 {
     Assert.Throws <ArgumentNullException>(() => ModbusUtility.CalculateLrc(null));
 }
 internal override bool ChecksumsMatch(IModbusMessage message, byte[] messageFrame) =>
 ModbusUtility.CalculateLrc(message.MessageFrame) == messageFrame[^ 1];