Esempio 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;
 }
Esempio n. 2
0
 private int searchforProtocolAndBaud(ref CommunicationManager comm)
 {
     comm.AutoDetectProtocolAndBaudDone = false;
     comm.CurrentProtocol = comm.MessageProtocol;
     comm.CurrentBaud = comm.BaudRate;
     Refresh();
     if (!comm.OpenPort())
     {
         return 0;
     }
     Thread.Sleep(10);
     int num = searchforProtocolAndBaud_sub(ref comm);
     if (num == 3)
     {
         comm.BaudRate = comm.CurrentBaud;
         comm.MessageProtocol = comm.CurrentProtocol;
         if (comm.CurrentProtocol == "OSP")
         {
             comm.RxType = CommunicationManager.ReceiverType.SLC;
             comm.RxTransType = CommunicationManager.TransmissionType.GPS;
         }
         else
         {
             comm.RxType = CommunicationManager.ReceiverType.NMEA;
             comm.RxTransType = CommunicationManager.TransmissionType.Text;
         }
         comm.SetupRxCtrl();
         comm.comPort.BaudRate = int.Parse(comm.BaudRate);
         comm.comPort.UpdateSetttings();
         comm.portDataInit();
     }
     comm.AutoDetectProtocolAndBaudDone = true;
     return num;
 }
Esempio 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;
 }
Esempio n. 4
0
        private bool manualConnect(ref CommunicationManager comm)
        {
            if (comm == null)
            {
                return false;
            }
            try
            {
                bool flag2;
                if (clsGlobal.IsMarketingUser())
                {
                    comm.IsAutoDetectBaud = true;
                }
                if (comm.IsSourceDeviceOpen())
                {
                    goto Label_04E8;
                }
                if (!comm.RequireHostRun || (sysCmdExec.IsExistingWin(comm.HostSWFilePath) != 0))
                {
                    goto Label_02AC;
                }
                string argStr = string.Empty;
                switch (comm.InputDeviceMode)
                {
                    case CommonClass.InputDeviceModes.RS232:
                        argStr = @"-a\\.\\" + comm.HostPair1 + " -y\"" + comm.HostAppCfgFilePath + "\" -e\"" + comm.HostAppMEMSCfgPath + "\"";
                        break;

                    case CommonClass.InputDeviceModes.TCP_Client:
                        argStr = "-n" + comm.CMC.HostAppClient.TCPClientPortNum.ToString() + " -y\"" + comm.HostAppCfgFilePath + "\" -e\"" + comm.HostAppMEMSCfgPath + "\"";
                        break;

                    case CommonClass.InputDeviceModes.TCP_Server:
                        argStr = "-n" + comm.CMC.HostAppServer.TCPServerPortNum.ToString() + " -y\"" + comm.HostAppCfgFilePath + "\" -e\"" + comm.HostAppMEMSCfgPath + "\"";
                        break;
                }
                if (!comm.RequireEE)
                {
                    goto Label_02A4;
                }
                string eESelect = comm.EESelect;
                if (eESelect != null)
                {
                    if (!(eESelect == "CGEE"))
                    {
                        if (eESelect == "SGEE")
                        {
                            goto Label_01EB;
                        }
                        if (eESelect == "Mixed SGEE + CGEE")
                        {
                            goto Label_01F9;
                        }
                    }
                    else
                    {
                        argStr = argStr + " -mode \"ff4_cgee_only\"";
                    }
                }
                goto Label_0205;
            Label_01EB:
                argStr = argStr + " -mode \"ff4_sgee_only\"";
                goto Label_0205;
            Label_01F9:
                argStr = argStr + " -mode \"ff4_mixed_mode\"";
            Label_0205:;
                argStr = argStr + " -s\"" + comm.ServerName + "\" -d\"/diff/packedDifference.f2p" + comm.EEDayNum + "enc.ee\" -j\"" + comm.AuthenticationCode + "\" -k" + comm.ServerPort;
                if ((comm.EESelect == "CGEE") || (comm.EESelect == "Mixed SGEE + CGEE"))
                {
                    argStr = argStr + " -b" + comm.BankTime;
                }
            Label_02A4:
                RunHostAppFromMain(argStr, ref comm);
            Label_02AC:
                flag2 = false;
                if (comm.ProductFamily == CommonClass.ProductType.GSD4e)
                {
                    if (comm.InputDeviceMode == CommonClass.InputDeviceModes.RS232)
                    {
                        if ((comm.ResetPort != string.Empty) && (comm.ResetPort != "-1"))
                        {
                            string s = comm.ResetPort.Replace("COM", "");
                            int result = 0;
                            if (int.TryParse(s, out result))
                            {
                                comm.Init4eMPMWakeupPort(result);
                                comm.Toggle4eWakeupPort();
                            }
                        }
                        if (comm.IsAutoDetectBaud)
                        {
                            if (searchforProtocolAndBaud(ref comm) > 0)
                            {
                                flag2 = true;
                            }
                            else
                            {
                                flag2 = false;
                            }
                        }
                        else
                        {
                            comm.AutoDetectProtocolAndBaudDone = true;
                            flag2 = comm.OpenPort();
                        }
                    }
                    else if (comm.InputDeviceMode == CommonClass.InputDeviceModes.I2C)
                    {
                        if (searchforProtocol_I2C(ref comm) > 0)
                        {
                            flag2 = true;
                        }
                        else
                        {
                            flag2 = false;
                        }
                    }
                    else
                    {
                        flag2 = true;
                    }
                    if (!flag2)
                    {
                        comm.ConnectErrorString = "Autodetect baud failed!";
                        return false;
                    }
                    if (comm.MessageProtocol == "OSP")
                    {
                        comm.RxCurrentTransmissionType = CommunicationManager.TransmissionType.GPS;
                        comm.CMC.RxCurrentTransmissionType = CommonClass.TransmissionType.GPS;
                    }
                    else if (comm.MessageProtocol == "NMEA")
                    {
                        comm.RxCurrentTransmissionType = CommunicationManager.TransmissionType.Text;
                        comm.CMC.RxCurrentTransmissionType = CommonClass.TransmissionType.Text;
                    }
                    else
                    {
                        comm.RxCurrentTransmissionType = CommunicationManager.TransmissionType.Hex;
                        comm.CMC.RxCurrentTransmissionType = CommonClass.TransmissionType.Hex;
                    }
                }
                else
                {
                    comm.AutoDetectProtocolAndBaudDone = true;
                    if (!comm.OpenPort())
                    {
                        comm.ConnectErrorString = "Unable to open port!";
                        return false;
                    }
                }
                if (comm.RxType == CommunicationManager.ReceiverType.TTB)
                {
                    comm.WriteData("A0A2 0009 CCA6 0002 0100 0000 00 8175 B0B3");
                    comm.WriteData("A0A2 0009 CCA6 0004 0100 0000 00 8177 B0B3");
                    comm.WriteData("A0A2 0009 CCA6 0029 0100 0000 00 819C B0B3");
                }
                if (comm.RequireHostRun && (sysCmdExec.IsExistingWin(comm.HostSWFilePath) == 1))
                {
                    sysCmdExec.SetWinSize(comm.HostSWFilePath, 2);
                }
                if (comm.RequireHostRun)
                {
                    comm.RxCtrl.SetMEMSMode(0);
                }
                if (comm.MessageProtocol != "NMEA")
                {
                    comm.RxCtrl.PollClockStatus();
                    comm.RxCtrl.PollSWVersion();
                    comm.RxCtrl.PollNavigationParameters();
                }
                if (comm.RxName == string.Empty)
                {
                    comm.RxName = "SiRF_EVK";
                }
                goto Label_0515;
            Label_04E8:
                manualDisconnect(ref comm);
            }
            catch (Exception exception)
            {
                if (comm != null)
                {
                    comm.ConnectErrorString = "Error: " + exception.ToString();
                }
                return false;
            }
            Label_0515:
            return true;
        }