Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/11/2011, 21:33
mindoata
 
Fecha de Ingreso: septiembre-2008
Mensajes: 136
Antigüedad: 15 años, 7 meses
Puntos: 1
GPS en Windows Mobile

Buenas compañeros.

Yo he utilizado un programa que consegui para leer la cadena GPGGA que me da las coordenadas geograficas, en la PDA Dolphin me funciona perfectamente pero al utilizarlo en la PDA motorola MC65 me genera una excepcion (OutOfMemoryException).
He visto la configuracion de la PDA y veo todo en orden.
A continuacion les muestro el codigo, la linea en rojo es en donde me muestra la excepcion muchas gracias.
Código:
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 Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    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
            If TextBox2.Text = "Error GPS" Then
                GC.GetTotalMemory(False)
                GC.Collect()
                TextBox2.Text = ""
                TextBox3.Text = ""
                TextBox4.Text = ""
            End If
            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