Results 1 to 4 of 4

Thread: MSComm and Hyperterminal

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Location
    Orlando, FL, US
    Posts
    11

    Post

    I am trying to use the MSComm function on VB6.0 to receive some GPS information into a hyperterminal I created. The data that I am receiving looks as follows:
    $GPGSA,A,1,,,,,,,,,,,,,,,*1E
    $GPZDA,190607.00,,,,00,00*6F
    $GPGSV,2,1,08,01,49,328,,03,16,165,,06,09,051,,14,48,277,*71
    $GPGSV,2,2,08,16,19,314,,22,88,154,,25,48,036,,29,15,124,*7E
    $GPRMC,190608.00,V,2834.4610,N,08115.4043,W,,,,,*30
    $GPGGA,190608.00,2834.4610,N,08115.4043,W,0,00,,-95.8,M,,M,,*50
    $GPGSA,A,1,,,,,,,,,,,,,,,*1E
    $GPZDA,190608.00,,,,00,00*60
    $GPGSV,2,1,08,01,49,328,,03,16,165,,06,09,051,,14,48,277,*71
    $GPGSV,2,2,08,16,19,314,,22,88,154,,25,48,036,,29,15,124,*7E

    The problem is that I need to strip some of this data away, and I do not know how to. I believe that it has to do with the MSComm.input. Can someone give me some input on this matter? I appreciate it.

  2. #2
    New Member
    Join Date
    Nov 1999
    Location
    Lake Charles, LA US
    Posts
    2

    Post

    What do you need to parse out?

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Location
    Orlando, FL, US
    Posts
    11

    Post

    Out of these commands, I need to use the command string that begins with $GPRMC. If you look at this string closely, it tells a latitude, a longitude, and a time. In this case the lat is 28.34.., the long. is 81.15.. and the time is 19:06. This data is the one that I need to parse out from that whole set of strings. Thank you, and your help will be greatly appreciated...

  4. #4
    New Member
    Join Date
    Nov 1999
    Location
    Lake Charles, LA US
    Posts
    2

    Post

    Try this in a form. 1 Textbox, 6 Labels 1 Cmd Button:
    ****start code****
    Option Explicit

    Private Sub cmdParse_Click()
    'start parsing
    sParse txtText.Text
    End Sub

    Private Sub Form_Load()
    'laods text into textbox
    txtText = "$GPRMC,190608.00,V,2834.4610,N,08115.4043,W,,,,,*30"
    End Sub

    Private Sub sParse(sText As String)
    Dim iCounter As Integer
    Dim iCounter2 As Integer
    Dim iPos As Integer
    Dim sTime As String
    Dim sLat As String
    Dim sLag As String
    Dim iLen As Integer

    'what you want to parse on
    Const PARSECHAR = ","

    'get out if no text
    If Len(sText) = 0 Then Exit Sub

    'start counters
    iCounter = 1
    iCounter2 = 1

    'get the sections
    iPos = InStr(iCounter, sText, PARSECHAR)

    While iPos <> 0

    Select Case iCounter2
    Case "2" 'section 2 is the time
    sTime = Mid$(sText, iCounter, iPos - iCounter)
    sTime = Left(sTime, 6)
    sTime = Format(sTime, "##:##:##")
    lblTime.Caption = sTime
    Case "4" 'section 4 is Lat
    sLat = Mid$(sText, iCounter, iPos - iCounter)
    iLen = Len(sLat) - 5
    sLat = Left(sLat, iLen)
    sLat = FixNum(sLat) 'fix number to read ##.## or ###.##
    lblLat.Caption = sLat
    Case "6" 'section 6 is Lag
    sLag = Mid$(sText, iCounter, iPos - iCounter)
    sLag = Left(sLag, 4)
    sLag = FixNum(sLag) 'fix number to read ##.## or ###.##
    lblLag.Caption = sLag
    End Select
    iCounter = iPos + 1 'inc counter
    iCounter2 = iCounter2 + 1 'inc counter
    iPos = InStr(iCounter, sText, PARSECHAR) 'next section
    Wend

    End Sub
    Private Function FixNum(sNum As String) As String
    Dim sOne As String
    Dim sTwo As String
    Dim iLen As Integer

    'get number length minus 2 for the .##
    iLen = Len(sNum) - 2

    'get the first half of the number
    sOne = Left(sNum, 2)
    'get the second half of the number
    sTwo = Right(sNum, iLen)
    'put them together
    FixNum = sOne & "." & sTwo

    End Function
    ****end code****

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