private byte[] reserved; //保留,6字节 public SeerHead(AGVFrameTypes frameType, UInt32 len) { sync = SYNC; version = 1; short sNumber = (short)(new Random().Next(UInt16.MaxValue)); number = (UInt16)((short)IPAddress.HostToNetworkOrder(sNumber)); length = (UInt32)((int)IPAddress.HostToNetworkOrder((int)len)); type = (UInt16)((short)IPAddress.HostToNetworkOrder((short)frameType)); reserved = new byte[6] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; }
public AGVComFrame(AGVFrameTypes type, object serialData) { if (serialData != null) { string data = JsonConvert.SerializeObject(serialData); byte[] bData = ASCIIEncoding.ASCII.GetBytes(data); Data = bData; Head = new SeerHead(type, (UInt16)bData.Length); } else { Head = new SeerHead(type, 0); Data = null; } }