public void CreateReadMemoryCommand() { uint address = 0x02000800; int size = 8; ReadMemoryCommand cmd = new ReadMemoryCommand(address, size); Assert.AreEqual(address, cmd.Address); Assert.AreEqual(size, cmd.Size); Assert.AreEqual("m", cmd.Command); Assert.AreEqual("m2000800,8", cmd.Pack()); }
public void FactoryDataReply() { byte[] expected = new byte[] { 0xCA, 0xFE, 0xBE, 0xBE, 0x00, 0x10, 0x20 }; string dataString = BitConverter.ToString(expected).Replace("-", ""); ReadMemoryCommand readMemory = new ReadMemoryCommand(0x00, 0x00); ReplyPacket reply = ReplyPacketFactory.CreateReplyPacket(dataString, readMemory); Assert.IsInstanceOf<DataReply>(reply); Assert.AreEqual(expected, ((DataReply)reply).GetData()); }
private byte[] SendRead(uint address, int size) { ReadMemoryCommand command = new ReadMemoryCommand(address, size); DataReply reply = this.Client.SendCommandWithoutErrorReply<DataReply>(command); if (reply == null) return new byte[0]; return reply.GetData(); }