Wmobile中GPS的问题 [英] problem with GPS in Wmobile
本文介绍了Wmobile中GPS的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用了一个程序来读取GPGGA字符串,该字符串为我提供了地理坐标,Dolphin PDA效果很好,但是我使用了Motorola MC65 PDA却是一个异常(OutOfMemoryException).
我已经看到了PDA的配置,并按顺序看到了所有内容.
我在下面显示代码,行
I''ve used a program I got to read the GPGGA string that gives me the geographical coordinates, the Dolphin PDA works well but I use the motorola MC65 PDA me an exception (OutOfMemoryException).
I have seen the configuration of the PDA and see everything in order.
Below I show the code, the line
Dim datos As String = SerialPort1.ReadExisting()
是异常显示我的地方,非常感谢您.
is where the exception shows me thank you very much.
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.IO.Ports
Imports System.IO
Public Class Form1
Public Latitud As String
Public Longitud As String
Public Altitud As String
Public Sub New()
' Esto es necesario
InitializeComponent()
' Aqui intentamos abri el puerto
Try
SerialPort1.PortName = "COM7"
SerialPort1.Open()
Catch ex As Exception
MessageBox.Show(ex.Message)
Timer1.Enabled = False
Button3.Text = "GPS"
Return
End Try
End Sub
Private Sub timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If SerialPort1.IsOpen Then
'En esta variable, insertamos todo lo leido del Puerto.
Dim datos As String = SerialPort1.ReadExisting()
'Aqui creamos las diferentes lineas, basandonos en el simbolo del dolar
Dim strArr() As String = datos.Split("$")
Dim i As Integer = 0
'TextBox1.Text = strArr.Length
If strArr.Length > 1 Then
Try
For i = 0 To strArr.Length
'Ahora obtenemos los datos, separados por las comas.
Dim strTemp As String = strArr(i)
Dim lineArr() As String = strTemp.Split(",")
'Si la linea es GPGGA, cojemos los bloques de cadena 2 y 4 (latidud y longitud) y pasamos los datos obtenidos a coordenadas UTM.
If (lineArr(0) = "GPGGA") Then
Try
Dim dLat As Decimal
Dim dLon As Decimal
Dim dAlt As Decimal
Dim pla As String
Dim plo As String
Dim pAl As String
pla = lineArr(3)
plo = lineArr(5)
pAl = lineArr(10)
dLat = Convert.ToDecimal(lineArr(2))
dLat = dLat / 100
Dim lat() As String = dLat.ToString().Split(".")
Latitud = lat(0).ToString() + "." + ((Convert.ToDouble(lat(1)) / 0.6)).ToString("#####")
TextBox2.Text = pla + " " + Latitud
dLon = Convert.ToDecimal(lineArr(4))
dLon = dLon / 100
Dim lon() As String = dLon.ToString().Split(".")
Longitud = lon(0).ToString() + ".0" + ((Convert.ToDouble(lon(1)) / 0.6)).ToString("#####")
TextBox3.Text = plo + " " + Longitud
dAlt = Convert.ToDecimal(lineArr(9))
Dim alt() As String = dAlt.ToString().Split(".")
Altitud = alt(0).ToString() + "." + ((Convert.ToDouble(alt(1)) / 60)).ToString("#####")
TextBox4.Text = Altitud + " " + pAl
Catch
' Si no podemos leer el GPS
TextBox2.Text = "Leyendo GPS"
TextBox3.Text = "Leyendo GPS"
TextBox4.Text = "Leyendo GPS"
End Try
End If
Next
Catch
'No hacemos nada
End Try
End If
Else
TextBox2.Text = "Puerto COM Cerrado"
TextBox3.Text = "Puerto COM Cerrado"
TextBox4.Text = "Puerto COM Cerrado"
End If
End Sub
Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'Comprobamos el estado del timer y lo invertimos.
If Timer1.Enabled = True Then
Timer1.Enabled = False
Else
Timer1.Enabled = True
End If
If Button3.Text = "GPS" Then
Button3.Text = "Parar"
Else
Button3.Text = "GPS"
End If
End Sub
End Class
推荐答案
") Dim i As 整数 = 0 ' TextBox1.Text = strArr.Length 如果 strArr.Length> 1 然后 尝试 对于 i = 0 要 strArr.Length ' Ahora obtenemos los datos,separados por las comas. Dim strTemp As 字符串 = strArr(i ) Dim lineArr() As 字符串 = strTemp .Split(" ) ' 西格里娜(s la linea es)GPGGA,第2天和第4天(经纬度)和在帕萨莫斯(pasamos los datos obtenidos a) coordenadas UTM. 如果(lineArr( 0 )= " GPGGA")尝试 Dim dLat As 十进制 Dim dLon As 十进制 Dim dAlt As 十进制 Dim pla As 字符串 Dim plo As 字符串 Dim pAl As String pla = lineArr( 3 ) plo = lineArr( 5 ) pAl = lineArr( 10 ) dLat = Convert.ToDecimal(lineArr( 2 )) dLat = dLat/ 100 Dim lat() As 字符串 = dLat .ToString().Split(" ) 纬度=纬度( 0 ).ToString()+ " +(((Convert.ToDouble(lat( 1 ))/ 0 . 6 )).ToString(" ) TextBox2.Text = pla + " +纬度 dLon = Convert.ToDecimal(lineArr( 4 )) dLon = dLon/ 100 Dim lon() As 字符串 = dLon .ToString().Split(" ) 纵向= lon( 0 ).ToString()+ " +((Convert.ToDouble(lon( 0 . 6 )).ToString(" ) TextBox3.Text = plo + " +纵向 dAlt = Convert.ToDecimal(lineArr( 9 )) Dim alt() As 字符串 = dAlt .ToString().Split(" ) Altitud = alt( 0 ).ToString()+ " +((Convert.ToDouble(alt( 1 ))/ 60 )) .ToString(" ) TextBox4.Text = Altitud + " + pAl 捕获 ' 没有任何GPS信号 TextBox2.Text = " TextBox3.Text = " TextBox4.Text = " 结束 尝试 结束 如果 下一步 捕获 ' 没有hacemos nada 结束 尝试 结束 如果 其他 TextBox2.Text = " TextBox3.Text = " TextBox4.Text = " 结束 如果 结束 子 私有 子 Button3_Click_1( ByVal 发件人 As 系统.对象, ByVal e As System.EventArgs)句柄 Button3.Click ' 无所事事. 如果 Timer1.Enabled = 真实 然后 Timer1.Enabled = 错误 其他 Timer1.Enabled = 真 结束 如果 如果 Button3.Text = " 然后 Button3.Text = " 其他 Button3.Text = " 结束 如果 结束 子 结束 类
") Dim i As Integer = 0 'TextBox1.Text = strArr.Length If strArr.Length > 1 Then Try For i = 0 To strArr.Length 'Ahora obtenemos los datos, separados por las comas. Dim strTemp As String = strArr(i) Dim lineArr() As String = strTemp.Split(",") 'Si la linea es GPGGA, cojemos los bloques de cadena 2 y 4 (latidud y longitud) y pasamos los datos obtenidos a coordenadas UTM. If (lineArr(0) = "GPGGA") Then Try Dim dLat As Decimal Dim dLon As Decimal Dim dAlt As Decimal Dim pla As String Dim plo As String Dim pAl As String pla = lineArr(3) plo = lineArr(5) pAl = lineArr(10) dLat = Convert.ToDecimal(lineArr(2)) dLat = dLat / 100 Dim lat() As String = dLat.ToString().Split(".") Latitud = lat(0).ToString() + "." + ((Convert.ToDouble(lat(1)) / 0.6)).ToString("#####") TextBox2.Text = pla + " " + Latitud dLon = Convert.ToDecimal(lineArr(4)) dLon = dLon / 100 Dim lon() As String = dLon.ToString().Split(".") Longitud = lon(0).ToString() + ".0" + ((Convert.ToDouble(lon(1)) / 0.6)).ToString("#####") TextBox3.Text = plo + " " + Longitud dAlt = Convert.ToDecimal(lineArr(9)) Dim alt() As String = dAlt.ToString().Split(".") Altitud = alt(0).ToString() + "." + ((Convert.ToDouble(alt(1)) / 60)).ToString("#####") TextBox4.Text = Altitud + " " + pAl Catch ' Si no podemos leer el GPS TextBox2.Text = "Leyendo GPS" TextBox3.Text = "Leyendo GPS" TextBox4.Text = "Leyendo GPS" End Try End If Next Catch 'No hacemos nada End Try End If Else TextBox2.Text = "Puerto COM Cerrado" TextBox3.Text = "Puerto COM Cerrado" TextBox4.Text = "Puerto COM Cerrado" End If End Sub Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'Comprobamos el estado del timer y lo invertimos. If Timer1.Enabled = True Then Timer1.Enabled = False Else Timer1.Enabled = True End If If Button3.Text = "GPS" Then Button3.Text = "Parar" Else Button3.Text = "GPS" End If End Sub End Class
这篇关于Wmobile中GPS的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文