WEB开发网
开发学院手机开发Windows Mobile 开发 在 WM 平台上开发 GPS 导航系统 阅读

在 WM 平台上开发 GPS 导航系统

 2010-02-21 22:52:00 来源:WEB开发网   
核心提示:87 If Words(2) <> "" Then88 Select Case Words(2)89 Case "A"90 RaiseEvent FixObtained()91 Case "V"92 RaiseEvent FixLost()93 E

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语句已经被充分解析,解析器可以扩展以支持第二句:$

上一页  10 11 12 13 14 15 16 17 18 19 20  下一页

Tags:WM 平台 开发

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