Dictionary<string, string> itemsUblox = new Dictionary<string, string>()
{
{"UBX-MGA-ACK","B5 62 13 60 00 00"},//值后面需加校验和,函数在后面
{"UBX-MGA-ANO","B5 62 13 20 00 00"},
{"UBX-MGA-BDS","B5 62 13 03 00 00"},
{"UBX-MGA-DBD","B5 62 13 80 00 00"},
{"UBX-MGA-GAL","B5 62 13 02 00 00"},
{"UBX-MGA-GLO","B5 62 13 06 00 00"},
{"UBX-MGA-GPS","B5 62 13 00 00 00"},
{"UBX-MGA-INI","B5 62 13 40 00 00"},
{"UBX-MGA-QZSS","B5 62 13 05 00 00"},
{"UBX-NAV-CLOCK","B5 62 01 22 00 00"},
{"UBX-NAV-DOP","B5 62 01 04 00 00"},
{"UBX-NAV-EOE","B5 62 01 61 00 00"},
{"UBX-NAV-GEOFENCE","B5 62 01 39 00 00"},
{"UBX-NAV-HPPOSECEF","B5 62 01 13 00 00"},
{"UBX-NAV-HPPOSLLH","B5 62 01 14 00 00"},
{"UBX-NAV-ODO","B5 62 01 09 00 00"},
{"UBX-NAV-ORB","B5 62 01 34 00 00"},
{"UBX-NAV-POSECEF","B5 62 01 01 00 00"},
{"UBX-NAV-POSELLH","B5 62 01 02 00 00"},
{"UBX-NAV-PVT","B5 62 01 07 00 00"},
{"UBX-NAV-RESETODO","B5 62 01 10 00 00"},
{"UBX-NAV-SAT","B5 62 01 35 00 00"},
{"UBX-NAV-SIG","B5 62 01 43 00 00"},
{"UBX-NAV-STATUS","B5 62 01 03 00 00"},
{"热启动","B5 62 06 04 04 00 00 00 02 00"},
{"温启动","B5 62 06 04 04 00 01 00 02 00"},
{"冷启动","B5 62 06 04 04 00 FF FF 02 00"}
};
private string CalSum(string Send)//计算校验和
{
Int32 CK_A = 0, CK_B = 0;
string[] Sections = Send.Split(' ');
for (int I = 2; I < Sections.Length; I++)//从消息类别开始
{
CK_A += Int32.Parse(Sections[I], System.Globalization.NumberStyles.HexNumber);
CK_B += CK_A;
}
string CK_AHex = CK_A.ToString("X");//取最后两位
string CK_BHex = CK_B.ToString("X");//取最后两位
if (CK_AHex.Length > 2)
{
CK_AHex = CK_AHex.Substring(CK_AHex.Length - 2);
}
else if (CK_AHex.Length<2)
{
CK_AHex = "0" + CK_AHex;
}
if (CK_BHex.Length>2)
{
CK_BHex = CK_BHex.Substring(CK_BHex.Length - 2);
}
else if (CK_BHex.Length < 2)
{
CK_BHex = "0" + CK_BHex;
}
return Send + " " + CK_AHex + " " + CK_BHex;
}
private static byte[] strToToHexByte(string hexString)//将16字符串转为Byte数组,直接写入串口
{
hexString = hexString.Replace(" ", "");
if ((hexString.Length % 2) != 0)
hexString += " ";
byte[] returnBytes = new byte[hexString.Length / 2];
for (int i = 0; i < returnBytes.Length; i++)
returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
return returnBytes;
}
C#_Ublox指令参照
最新推荐文章于 2024-01-05 10:47:39 发布