Results 1 to 8 of 8

Thread: [HELP!]Problem with my APP

  1. #1

    Thread Starter
    Hyperactive Member FireKnox101's Avatar
    Join Date
    Aug 2005
    Location
    Snohomish,Washington
    Posts
    301

    Exclamation [HELP!]Problem with my APP

    Ok i was reading this artical on how to make a GPS app for your pda, heres the link http://www.devx.com/wireless/Article/32938, i know the app this guy made is in 2005, but i found other ways of doing what he did, heres were im stuck, i load my app up on to my pda and when i hit Connect to GPS i get this exception,

    System.ApplicationException:CreateFile Failed: 161

    What am i doing wrong??? heres my code,

    VB Code:
    1. Imports OpenNETCF
    2.  
    3. Public Class frmMain
    4.     Inherits System.Windows.Forms.Form
    5.  
    6. Windows Form Designer generated code
    7.  
    8.     '---serial port to connect to the GPS receiver---
    9.     Private WithEvents serialPort As New IO.Ports.SerialPort
    10.  
    11.     '---IP address of the server---
    12.     Private ServerIP As String = "Some IP adress"
    13.  
    14.     '---the ID of the user---
    15.     Private ID As String = "1"
    16.  
    17.     '---use for synchronization---
    18.     Dim sync As New Sync
    19.  
    20.     Public Delegate Sub myDelegate()
    21.  
    22.     Public Sub updateTextBox()
    23.         txtGpsData.Text += serialPort.ReadExisting()
    24.         Dim lines() As String = txtGpsData.Text.Split(vbLf)
    25.         If lines.Length < 2 Then
    26.             Exit Sub
    27.         End If
    28.         If txtGpsData.Text.Length >= 500 Then
    29.             '---clear until the last $---
    30.             txtGpsData.Text = _
    31.                txtGpsData.Text.Substring(txtGpsData.Text.LastIndexOf("$"))
    32.         End If
    33.         If lines(lines.Length - 2).StartsWith("$GPGGA") Or _
    34.            lines(lines.Length - 2).StartsWith("$GPRMC") Then
    35.             processGPSData(lines(lines.Length - 2))
    36.         End If
    37.     End Sub
    38.  
    39.     Private Sub DataReceived( _
    40.            ByVal sender As Object, _
    41.            ByVal e As IO.Ports.SerialDataReceivedEventArgs) _
    42.            Handles serialPort.DataReceived
    43.         txtGpsData.Invoke(New myDelegate(AddressOf updateTextBox))
    44.  
    45.     End Sub
    46.  
    47.     Private Sub processGPSData(ByVal str As String)
    48.         Dim rawLatLng As Double
    49.         Try
    50.             '---separate the GPS data into various fields---
    51.             Dim field() As String
    52.             field = str.Split(",")
    53.             Dim lat, lng As Double
    54.  
    55.             Select Case field(0)
    56.                 Case "$GPGGA"
    57.                     '---latitude---
    58.                     rawLatLng = Convert.ToDouble(field(2))
    59.                     lat = (rawLatLng \ 100) + _
    60.                          ((rawLatLng - ((rawLatLng \ 100) * 100)) / 60)
    61.  
    62.                     '---latitude is negative if South---
    63.                     If field(3) = "S" Then
    64.                         lat *= -1.0
    65.                     End If
    66.  
    67.                     '---longitude---
    68.                     rawLatLng = Convert.ToDouble(field(4))
    69.                     lng = (rawLatLng \ 100) + _
    70.                          ((rawLatLng - ((rawLatLng \ 100) * 100)) / 60)
    71.  
    72.                     '---longitude is negative if West---
    73.                     If field(5) = "W" Then
    74.                         lng *= -1.0
    75.                     End If
    76.  
    77.                     '---display the lat and lng---
    78.                     lblLat.Text = "Lat:" & lat
    79.                     lblLng.Text = "Lng:" & lng
    80.  
    81.                     '---synchronize with the server---
    82.                     sync.PerformSync(ServerIP, ID & ":" & lat & ":")
    83.  
    84.                 Case "$GPRMC"
    85.                     '---display the speed---
    86.                     If field(7) = String.Empty Then
    87.                         lblSpeed.Text = "Speed: 0 km/h"
    88.                     Else
    89.                         lblSpeed.Text = "Speed: " & _
    90.                          (Convert.ToDouble(field(7)) * 1.85).ToString _
    91.                          & " km/h"
    92.                     End If
    93.             End Select
    94.         Catch
    95.             MsgBox("An error has occurred")
    96.         End Try
    97.     End Sub
    98.  
    99.     Private Sub mnuConnect_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuConnect.Click
    100.  
    101.         '---close the port if it is already open---
    102.         If serialPort.IsOpen Then
    103.             serialPort.Close()
    104.         End If
    105.  
    106.         '---set the parameters and open the port---
    107.         Try
    108.             With serialPort
    109.                 .PortName = "COM7"
    110.                 .BaudRate = 9600
    111.                 .Parity = IO.Ports.Parity.None
    112.                 .DataBits = 8
    113.                 .StopBits = IO.Ports.StopBits.One
    114.             End With
    115.             serialPort.Open()
    116.  
    117.             '---disable the Connect GPS menu item---
    118.             MenuItem1.Enabled = False
    119.  
    120.             '---enable the Disconnect menu item---
    121.             MenuItem3.Enabled = True
    122.         Catch ex As Exception
    123.             MsgBox(ex.ToString)
    124.         End Try
    125.  
    126.     End Sub
    127.  
    128.     Private Sub mnuIP_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuIP.Click
    129.  
    130.         '---Input box for the user to enter the servers ip---
    131.         ServerIP = InputBox( _
    132.        "Please enter the IP address of server", "Server IP")
    133.  
    134.     End Sub
    135.  
    136.     Private Sub mnuID_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuID.Click
    137.  
    138.         '---Lets the user tell the server the differenc between differnt users---
    139.         ID = InputBox("Please enter your ID", "ID")
    140.  
    141.     End Sub
    142.  
    143.     Private Sub mnuDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDisconnect.Click
    144.  
    145.         serialPort.Close()
    146.         MenuItem1.Enabled = True  '---Connect GPS---
    147.         MenuItem3.Enabled = False '---Disconnect---
    148.  
    149.     End Sub
    150. End Class

    Im Using VB.net 2003 Smart Device Application
    Last edited by FireKnox101; Feb 1st, 2007 at 05:58 PM.

    Im currently using: VB.NET 2003, And VB 2005 Express
    My Projects
    Form Them Show Keypress In App
    Simple Ping Control

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [HELP!]Problem with my APP

    Are you debugging on the PDA? If so, which line is throwing the error? If not, then do so, and tell us which line is throwing the error.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Hyperactive Member FireKnox101's Avatar
    Join Date
    Aug 2005
    Location
    Snohomish,Washington
    Posts
    301

    Re: [HELP!]Problem with my APP

    ok were i get the error is when i click on the "Connect to GPS" Menu button
    but in the debug it dosent show what line its erroring on, i know that sounds weird but i cant find were its erroring at. I found this link also http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=5751.

    Im currently using: VB.NET 2003, And VB 2005 Express
    My Projects
    Form Them Show Keypress In App
    Simple Ping Control

  4. #4
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: [HELP!]Problem with my APP

    Hi,
    are they not suggesting changing to "COM7:"?

    Have you tried stepping through the code?

    Which version of OpenNETCF are you using?

    Is this on the PDA or the emulator?

    So many questions

    Pete

  5. #5

    Thread Starter
    Hyperactive Member FireKnox101's Avatar
    Join Date
    Aug 2005
    Location
    Snohomish,Washington
    Posts
    301

    Re: [HELP!]Problem with my APP

    I changed the "COM7" to "COM7:" and that did nothing,
    im using OpenNETCF 1.4
    Yes i tried stepping threw the code,
    im testing this on the pda.

    Im currently using: VB.NET 2003, And VB 2005 Express
    My Projects
    Form Them Show Keypress In App
    Simple Ping Control

  6. #6
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: [HELP!]Problem with my APP

    Hi,
    so when you step through the code, where do you get the error?

    Pete

  7. #7

    Thread Starter
    Hyperactive Member FireKnox101's Avatar
    Join Date
    Aug 2005
    Location
    Snohomish,Washington
    Posts
    301

    Re: [HELP!]Problem with my APP

    sorry for the late post, got really busy.

    that's the killer thing when I run the app on my pda when I'm debuging it dosent show, were the error is, I'm guessing its it the mnuconnect_click event. but I don't know, ill post back with my sorcue, can't do that from my phone =).

    Im currently using: VB.NET 2003, And VB 2005 Express
    My Projects
    Form Them Show Keypress In App
    Simple Ping Control

  8. #8
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: [HELP!]Problem with my APP

    Hi,
    that's why I asked about stepping through - that should show you exactly

    Pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width