當前位置: 首頁>>代碼示例>>C#>>正文


C# SerialPort.ToString方法代碼示例

本文整理匯總了C#中System.IO.Ports.SerialPort.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# SerialPort.ToString方法的具體用法?C# SerialPort.ToString怎麽用?C# SerialPort.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.Ports.SerialPort的用法示例。


在下文中一共展示了SerialPort.ToString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AC12GPS

        public AC12GPS(string portName)
        {
            myGPS = new SerialPort();

            //Initialize Serial Port Parameters
            myGPS.PortName = portName;
            myGPS.BaudRate = DEFAULT_BAUD_RATE;
            myGPS.Parity = DEFAULT_PARITY;
            myGPS.DataBits = DEFAULT_DATA_BITS;
            myGPS.StopBits = DEFAULT_STOP_BITS;
            myGPS.Handshake = DEFAULT_HANDSHAKE;

            myGPS.ReadTimeout = DEFAULT_TIMEOUT;
            myGPS.WriteTimeout = DEFAULT_TIMEOUT;

            myGPS.Open();
            
            //Initialize data
            myData = new UTMData();
            myData.East = 0.0;
            myData.North = 0.0;
            myData.NumSat = 0;
            myData.Timestamp = 0.0;

            if (myGPS.IsOpen)
            {
                //Setup GPS
                Console.WriteLine("Sucessfully Connected!");
                Console.WriteLine(myGPS.ToString());
                myGPS.RtsEnable = true;
                command("$PASHS,PWR,ON");
                System.Threading.Thread.Sleep(10);
                command("$PASHQ,PRT");
                System.Threading.Thread.Sleep(10);
                command("$PASHQ,RID");
                System.Threading.Thread.Sleep(10);
                command("$PASHS,OUT,A,NMEA");
                /*System.Threading.Thread.Sleep(10);
                command("$PASHS,NME,GSV,A,ON");*/
                /*System.Threading.Thread.Sleep(10);
                command("$PASHS,NME,GGA,A,ON");*/
                /*System.Threading.Thread.Sleep(10);
                command("$PASHS,NME,GSA,A,ON");
                System.Threading.Thread.Sleep(10);
                command("$PASHS,NME,VTG,A,ON");*/
                System.Threading.Thread.Sleep(10);
                command("$PASHS,NME,UTM,A,ON");     //Make GPS send UTM coordinate string

                // Create a new mutex to make sure manual update and autoupdate don't conflict
                mut = new Mutex();  
            }
            else
            {
                Console.WriteLine("Connection Failed!");    //Oh Shit!
            }
        }
開發者ID:faheem0,項目名稱:caltechrobotics,代碼行數:56,代碼來源:AC12GPS.cs


注:本文中的System.IO.Ports.SerialPort.ToString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。