WEB开发网
开发学院手机开发Windows Mobile 开发 Windows mobile gps 串口通信 NMEA命令和数据处理... 阅读

Windows mobile gps 串口通信 NMEA命令和数据处理

 2010-06-22 03:15:00 来源:WEB开发网   
核心提示:下面是 GPS命名空间里面 的 NMEAProtocol 的这个类的代码using System;using System.Collections.Specialized;using System.Text;using System.Text.RegularExpressions;using System.IO;nam

下面是 GPS命名空间里面 的 NMEAProtocol 的这个类的代码

using System;

using System.Collections.Specialized;

using System.Text;

using System.Text.RegularExpressions;

using System.IO;

namespace GPS

{

public class NMEAProtocol

{

private const int NP_MAX_CMD_LEN = 8; // maximum command length (NMEA address)

private const int NP_MAX_DATA_LEN = 256; // maximum data length

private const int NP_MAX_CHAN = 36; // maximum number of channels

private const int NP_WAYPOINT_ID_LEN = 32; // waypoint max string len

private NMEAState nState; // Current state protocol parser is in

private byte checksum; // Calculated NMEA sentence checksum

private byte receivedChecksum; // Received NMEA sentence checksum (if exists)

private int index; // Index used for command and data

private byte[] command; // NMEA command

private byte[] data; // NMEA data

// number of NMEA commands received (processed or not processed)

public int CommandCount;

public GPGGAData GPGGA;

public GPGSAData GPGSA = new GPGSAData();

public GPGSVData GPGSV = new GPGSVData();

public GPRMBData GPRMB;

public GPRMCData GPRMC;

public GPZDAData GPZDA;

public NMEAProtocol()

{

command = new byte[NP_MAX_CMD_LEN];

data = new byte[NP_MAX_DATA_LEN];

}

public void ParseBuffer(byte[] buffer)

{

foreach(byte b in buffer)

{

ProcessNMEA(b);

}

return;

}

public void ProcessNMEA(byte btData)

{

switch(nState)

{

///////////////////////////////////////////////////////////////////////

// Search for start of message '$'

1 2 3 4 5 6  下一页

Tags:Windows mobile gps

编辑录入:coldstar [复制链接] [打 印]
赞助商链接