在 WM 平台上开发 GPS 导航系统
2010-02-21 22:52:00 来源:WEB开发网87 If Words(2) <> "" Then
88 Select Case Words(2)
89 Case "A"
90 RaiseEvent FixObtained()
91 Case "V"
92 RaiseEvent FixLost()
93 End Select
94 End If
95 ' Indicate that the sentence was recognized
96 Return True
97 End Function
98 ' Returns True if a sentence's checksum matches the calculated checksum
99 Public Function IsValid(ByVal sentence As String) As Boolean
100 ' Compare the characters after the asterisk to the calculation
101 Return sentence.Substring(sentence.IndexOf("*") + 1) = GetChecksum(sentence)
102 End Function
103 ' Calculates the checksum for a sentence
104 Public Function GetChecksum(ByVal sentence As String) As String
105 ' Loop through all chars to get a checksum
106 Dim Character As Char
107 Dim Checksum As Integer
108 For Each Character In sentence
109 Select Case Character
110 Case "$"c
111 ' Ignore the dollar sign
112 Case "*"c
113 ' Stop processing before the asterisk
114 Exit For
115 Case Else
116 ' Is this the first value for the checksum?
117 If Checksum = 0 Then
118 ' Yes. Set the checksum to the value
119 Checksum = Convert.ToByte(Character)
120 Else
121 ' No. XOR the checksum with this character's value
122 Checksum = Checksum Xor Convert.ToByte(Character)
123 End If
124 End Select
125 Next
126 ' Return the checksum formatted as a two-character hexadecimal
127 Return Checksum.ToString("X2")
128 End Function
129 End Class
130
正如你所看到的,一大堆的信息都装在NMEA一句话中。现在$ GPRMC语句已经被充分解析,解析器可以扩展以支持第二句:$
- ››开发Android 日历教程
- ››开发学院总结 Win 8实用技巧大全
- ››开发学院原创教程:把win8的IE10放桌面上方法(非...
- ››开发者眼中的Windows Phone和Android
- ››开发学院教你用SQL 语句最快速清空MySQL 数据表的...
- ››WM 无法连接到win 7及webservice的异类原因
- ››开发一个自己的HTML在线编辑器(一)
- ››开发一个自己的HTML在线编辑器(二)
- ››开发者在App Store上赚的钱比在Android Market上多...
- ››开发者应深入学习的10个Android开源应用项目
- ››WM/WP上最完美的背光控制软件
- ››WM性能优化的一些经验
更多精彩
赞助商链接