本文整理匯總了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!
}
}