Пример #1
0
 private int searchforProtocol_I2C(ref CommunicationManager comm)
 {
     comm.AutoDetectProtocolAndBaudDone = false;
     comm.CurrentProtocol = comm.MessageProtocol;
     if (!comm.OpenPort())
     {
         return 0;
     }
     Thread.Sleep(5);
     frmSimpleDialog dialog = new frmSimpleDialog("Auto Detect Protocol");
     dialog.Show();
     dialog.MdiParent = clsGlobal.g_objfrmMDIMain;
     dialog.DisplayMessage = string.Format("\tDetecting {0}\n\n\t\t Please wait...", "NMEA");
     dialog.ShowMessage();
     if (comm.waitforNMEAMsg_I2C() != string.Empty)
     {
         comm.AutoDetectProtocolAndBaudDone = false;
         Thread.Sleep(50);
         if (!comm.ClosePort())
         {
             dialog.Close();
             return 0;
         }
         Thread.Sleep(5);
         comm.RxType = CommunicationManager.ReceiverType.NMEA;
         comm.RxType = CommunicationManager.ReceiverType.SLC;
         if (!comm.OpenPort())
         {
             dialog.Close();
             return 0;
         }
         comm.AutoDetectProtocolAndBaudDone = true;
         dialog.Close();
         return 1;
     }
     dialog.DisplayMessage = string.Format("\tDetecting {0}\n\n\t\t Please wait...", "OSP");
     dialog.ShowMessage();
     if (comm.waitforSSBMsg_I2C() != string.Empty)
     {
         comm.AutoDetectProtocolAndBaudDone = false;
         Thread.Sleep(50);
         if (!comm.ClosePort())
         {
             dialog.Close();
             return 0;
         }
         Thread.Sleep(5);
         comm.MessageProtocol = "OSP";
         comm.RxType = CommunicationManager.ReceiverType.SLC;
         if (!comm.OpenPort())
         {
             dialog.Close();
             return 0;
         }
         comm.AutoDetectProtocolAndBaudDone = true;
         dialog.Close();
         return 1;
     }
     dialog.Close();
     return 2;
 }