Windows mobile gps 串口通信 NMEA命令和数据处理
2010-06-22 03:15:00 来源:WEB开发网}
break;
///////////////////////////////////////////////////////////////////////
case NMEAState.NP_STATE_CHECKSUM_1:
if( (btData - '0') <= 9)
{
receivedChecksum = (byte)((btData - '0') << 4);
}
else
{
receivedChecksum = (byte)((btData - 'A' + 10) << 4);
}
nState = NMEAState.NP_STATE_CHECKSUM_2;
break;
///////////////////////////////////////////////////////////////////////
case NMEAState.NP_STATE_CHECKSUM_2:
if( (btData - '0') <= 9)
{
receivedChecksum |= (byte)((btData - (byte)'0'));
}
else
{
receivedChecksum |= (byte)((btData - (byte)'A' + 10));
}
if(checksum == receivedChecksum)
{
ProcessCommand(EncodeToString(command), data);
}
nState = NMEAState.NP_STATE_SOM;
break;
///////////////////////////////////////////////////////////////////////
default :
nState = NMEAState.NP_STATE_SOM;
break;
}
}
#region INMEAProtocol Members
public void ProcessGPRMB(GPRMBData gprmc)
{
// TODO: Add NMEAProtocol.ProcessGPRMB implementation
}
public void ProcessGPZDA(GPZDAData gpzda)
{
// TODO: Add NMEAProtocol.ProcessGPZDA implementation
}
public void ProcessGPRMC(string data)
{
string[] fields = Regex.Split(data, ",");
//Time: Hour, Minute, Second
//Time is Zulu
GPRMC.Hour = Convert.ToInt32(fields[0].Substring(0, 2));
GPRMC.Minute = Convert.ToInt32(fields[0].Substring(2, 2));
GPRMC.Second = Convert.ToInt32(fields[0].Substring(4, 2));
GPRMC.Day = Convert.ToInt32(fields[8].Substring(0, 2));
更多精彩
赞助商链接