本文整理汇总了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!
}
}