Windows mobile gps 串口通信 NMEA命令和数据处理
2010-06-22 03:15:00 来源:WEB开发网GPGGA.LatitudeHemisphere = Cardinal.South;
else
GPGGA.LatitudeHemisphere = Cardinal.North;
//Longitude
GPGGA.Longitude = Convert.ToDouble(fields[3])/100;
if(fields[4]=="E")
GPGGA.LatitudeHemisphere = Cardinal.East;
else
GPGGA.LatitudeHemisphere = Cardinal.West;
//GPS Signal Quality
GPGGA.GPSQuality = (GPSQuality)Convert.ToUInt32( fields[5] );
//Satellites
GPGGA.NumberOfSatellitesInUse = Convert.ToInt32(fields[6]);
//HDOP
GPGGA.HDOP = Convert.ToDouble( fields[7] );
//Altitude
GPGGA.Altitude = Convert.ToDouble(fields[8]);
//increase message count
GPGGA.Count ++;
}
catch(Exception e)
{
System.Diagnostics.Trace.WriteLine("Chaos in ProcessGPGGA! " + e.ToString());
}
}
public bool IsSatUsedInSolution(int SatelliteID)
{
return IsSatelliteUsed(SatelliteID);
}
public void Reset()
{
// TODO: Add NMEAProtocol.Reset implementation
}
private string EncodeToString(byte[] buffer)
{
string s = System.Text.ASCIIEncoding.GetEncoding(1252).GetString(buffer);
// TRIM OFF NULLS!
//s = s.TrimEnd((char)'');
//return s;
//TRIM at the FIRST NULL
string[] strings = s.Split('');
return strings[0];
}
public void ProcessCommand(string sCmd, byte[] bData)
{
string data = EncodeToString(bData);
switch(sCmd)
{
case "GPGGA":
ProcessGPGGA(data);
break;
case "GPGSA":
ProcessGPGSA(data);
break;
case "GPGSV":
ProcessGPGSV(data);
break;
更多精彩
赞助商链接