public static NewFromBytes ( byte bytes ) : |
||
bytes | byte |
/// A |
리턴 |
public void Parse1() { byte[] expected = TestPacket1; // Static method NewFromBytes () analyzes packet type, // and returns a specific packet object. // Based on given data in this case we know upfront, // it'll be an read-addresses-request. Ssm2ReadAddressesRequest p; p = (Ssm2ReadAddressesRequest)Ssm2Packet.NewFromBytes(expected); // check standard properties Assert.AreEqual(expected.Length, p.Size, "Size"); Assert.AreEqual(true, p.Check(), "Check()"); Assert.AreEqual(Ssm2Device.Engine10, p.Destination, "Destination"); Assert.AreEqual(Ssm2Device.DiagnosticToolF0, p.Source, "Source"); Assert.AreEqual(Ssm2Command.ReadAddressesRequestA8, p.Command, "Command"); // check packet type specifics IList <int> addresses = p.Addresses; Assert.AreEqual(1, addresses.Count, "addrList.Count"); Assert.AreEqual(1, p.AddressesCount, "AddressesCount"); Assert.AreEqual(0x123456, addresses[0], "adr[0]"); }
public void NewFromBytes() { // best for parsing as it does not allocate anything var p = (Ssm2ReadBlockRequest)Ssm2Packet.NewFromBytes(TestPacket1); // Same static method can also be accessed like this: // Ssm2InitRequest.NewFromBytes (...) AssertData1(p); }
public void NewFromBytes() { byte[] packetData = EcuInit1; // best for parsing as it does not allocate anything Ssm2InitRequest p = (Ssm2InitRequest)Ssm2Packet.NewFromBytes(packetData); // Same static method can also be accessed like this: // Ssm2InitRequest.NewFromBytes (...) AssertProperties1(p); }