Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 public void DisconnectPort(ref CommunicationManager comm)
 {
     if (comm != null)
     {
         comm.ClosePort();
         Thread.Sleep(10);
         comm.UpdatePortMainWinTitle -= new CommunicationManager.UpdateParentPortEventHandler(UpdateWinTitle);
         if (clsGlobal.CommWinRef.Contains(comm.PortName))
         {
             clsGlobal.CommWinRef.Remove(comm.PortName);
         }
         sysCmdExec.CloseWinByProcId(comm.HostAppCmdWinId);
     }
 }
Ejemplo n.º 3
0
 private bool searchforProtocolAndBaud_OSP(ref CommunicationManager comm)
 {
     comm.MessageProtocol = "OSP";
     comm.RxType = CommunicationManager.ReceiverType.SLC;
     string[] strArray = new string[5];
     strArray = "115200,4800,38400,9600,57600,19200".Split(new char[] { ',' });
     for (int i = 0; i < strArray.Length; i++)
     {
         if ((comm.CurrentProtocol != "OSP") || (comm.CurrentBaud != strArray[i]))
         {
             comm.BaudRate = strArray[i];
             Refresh();
             if (!comm.ClosePort())
             {
                 return false;
             }
             if (!comm.OpenPort())
             {
                 return false;
             }
             if (comm.waitforSSBMsg())
             {
                 return true;
             }
         }
     }
     return false;
 }