void ReInit() { if (SerialIOSwitchObj != null) { SerialIOSwitchObj.Close(); } FileObj = new File(InitInfo[2], InitInfo[3]); if (InitInfo[0] != "None") { RS232Obj = new RS232(InitInfo[0], int.Parse(InitInfo[1])); } else { RS232Obj = null; } SerialIOSwitchObj = new SerialIOSwitch(RS232Obj, FileObj); SerialIOSwitchObj.Open(); ZProtocolProcessObj = new ZProtocolProcess(SerialIOSwitchObj); ZProtocolProcessObj.OnReceviceFrame += new ZProtocolProcess.ReceviceData(ZProtocolProcessObj_OnReceviceFrame); ZProtocolProcessObj.OnReceviceBlock += new ZProtocolProcess.ReceviceData(ZProtocolProcessObj_OnReceviceBlock); }
private static void TestZProtocolProcess() { RS232 rs232 = new RS232("COM4", 115200); rs232.Open(); ZProtocolProcess zProtocolProcess = new ZProtocolProcess(rs232); zProtocolProcess.Start(); Console.WriteLine("Ready..."); //while (true) //{ // Console.ReadLine(); // zProtocolProcess.WriteFrame(1, 2, 0); // zProtocolProcess.AddPackage(0xc0, 0xff, new byte[12]); // zProtocolProcess.Send(); // Console.WriteLine("Send"); //} byte[] bs = new byte[12]; for (int i = 0; i < 12; i++) { bs[i] = (byte)i; } Console.ReadLine(); for (int i = 0; i < 100; i++) { zProtocolProcess.WriteFrame((byte)i, (byte)(i + 1), 0); zProtocolProcess.AddBlock((byte)(i + 100), 0xff, bs); zProtocolProcess.Send(); Console.WriteLine("Send"); Thread.Sleep(15); } }