How to recognize the data format from GPS-M1zz?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • basyarie
    New Member
    • Nov 2006
    • 6

    How to recognize the data format from GPS-M1zz?

    Dear VB mania, especially VB6 specialist

    I have a problem with my GPS. So far, I have a GPS-M1zz from Pioneer Navicom company. It has 2 type of data format, i.e. Pioneer Format and NMEA data standard. I have already retrieved and parsed the NMEA one using VB6 properly. I could display all NMEA data concisely. I could understand weell this standard.
    But, now, I have a problem with the Pioneer format standard. It is very different format with special HEX data format rather than NMEA with ASCII character.
    I`ve already tested a small routine program to retrieve Pioneer data format. Below is the example:
    case I : I used the function:
    varBuffer = mscPort.Input
    txtRecieveData. Text = txtRecieveData. Text & varBuffer:
    output:
    u€  イC &О& ( ! 64・ u€  イC &О& ( ! 64・ u€  イC &О& ( ! 64・ u€  イC &О& ( ! 64€

    Case II:
    But, when I wrote
    varBuffer = Asc(mscPort.Inp ut), the output becomes:
    161781617830161 783016178301617 830161783016178 301617830161783 016178301617830 161783016178301 617830161783016 178301617830161 783016178301617 830161783

    In order to understand the Pioneer packet format, here they are:

    <DLE> <ID> <data type> <CS> <DLE> <ETX>
    in case of checksum byte is exist.
    DLE(Data Link Escape) is 2 byte with HEX number 10h
    ID = 1 byte
    ETX (End of Text) with HEX number 03h

    The questions are:

    1. How to recognize the beginning of Data, ID etc, when I use CASE II retrieved data? Is there a mistake with my routine? If yes, how to revise it?

    2. This format is no delimiter like NMEA format with "comma". It is sequently the data is retrieved. How to parse it into each of their sentence part?

    I need helps.

    Thanks alot.

    ps: I am using VB6 version.

    Regards,
    basyarie
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Could you try displaying all the ASCII values from Case I, in hex format? Something simple would do, like this (not tested, and assuming your u€  イC &О& ( ! 64 data is in a variable called strBuffer)...
    Code:
    Dim I As Long
    For I = 1 To Len(strBuffer)
      Debug.Print Hex$(Asc(Mid$(strBuffer,I,1)))
    Next

    Comment

    • basyarie
      New Member
      • Nov 2006
      • 6

      #3
      Thanks Mr.Moderator,

      I`ve tried your code in Debug window and the result is like in below:
      10 DLE
      75 ID
      80
      1
      F4E7
      D
      7
      B2
      2E
      72
      19
      8145
      1E
      FF
      FF
      7
      3
      2
      10
      10
      39
      18
      7
      3
      2
      9
      24
      27
      FF
      7F
      FF
      7F
      FF
      FF
      1A
      10 DLE
      3 ETX

      Here, DLE is start of packet, and ETX is last of packet. In my GPS case, there are many packet ID, in this case, ID75 is confirmed. But, so far I don`t understand well this packet type, because the manual book is in Japanese. :)
      Okay, your code could change the data to Hex format. But, when I tried to display in VB Text window, gradually "Not Responding" state is clarified.
      My code is:
      txtReceiveData. Text = txtReceiveData. Text & Hex$(Asc(Mid$ (varBuffer, i, 1)))

      Why it appeared?

      Thanks a lot.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        :) It sounds as though you're closer to your goal, at least.

        Originally posted by basyarie
        ...But, when I tried to display in VB Text window, gradually "Not Responding" state is clarified.
        Not sure what's happening here. I think we'd need to see more of the code. That one statement looked alright, as far as I can tell.
        Last edited by Killer42; Mar 6 '07, 07:52 AM. Reason: Typo

        Comment

        • basyarie
          New Member
          • Nov 2006
          • 6

          #5
          Dear Moderator,

          Thank you very much for the response.
          It`s a great for me could discuss my problem here.
          Actually, my goal is how to retrieve the Gyro data from my GPS unit and then parse it aimed at controlling an electronic circuit. But, now, I need the Gyro data from my GPS (because it includes Gyro sensor). And it should be done by retrieving the manufacturer defined data packet. In this case, HEX number data packet. I got, but mistake type of data.
          Okay, now, I`d like to explain the circumstance.
          So far, I had an answer from my GPS manufacturer. They told me that I should retrieve "IDA3 type data". To get it, an input HEX number data should be sent. The format is (in HEX), each of part is 1 byte of the lenght (the whole are 6 bytes):

          10 A3 00, 01, or 02 CS 10 03

          <DLE> <ID> <Data for checksum> <Checksum> <DLE> <ETX>

          And the output should be (in HEX):

          <DLE> <ID> <ST> <Speed> <Direction> <Odometer> <Speed check value> <Direction check value> <CS> <DLE> <ETX>

          DLE, ID, ST, ETX is 1 byte
          Speed: 2 bytes
          Direction: 2 bytes
          Odometer: 4 bytes
          each of check value: 2 bytes

          My routines programs is below:
          1. <send data command button>
          Code:
          '   Event to load button "Send"
          Private Sub cmdSendData_Click()
          
          Dim Dat As String
          Dim L As Long
          Dim A As Variant
          Dim CC As Variant
          Dim CS As Variant
          Dim DatTX As Variant
          Dim i As Long
          
          
              '   Confirmation of Comm port is opened or not
              If mscPort.PortOpen = True Then
              
                  '   Written words on the textboxt is sent
                  '   then at the terminator they are added
                  mscPort.Output = txtSendData.Text & Chr(&HA)
                  
                  Dat = txtSendData.Text
                  L = Len(Dat)
                  A = 0
                  For i = 1 To L
                      CC = Mid$(Dat, i, 1)
                      A = Asc(CC) Xor A
                  Next i
                  
                  CS = Hex$(A)
                  
                  If Len(CS) = 1 Then
                      CS = "0" + CS
                  End If
                  
                  DatTX = "10" + "A3" + Dat + CS + "10" + "03" + Chr$(13)      
                  'gyro input format
                  mscPort.Output = DatTX           
                 ' TX data buffer
                                 
                  Debug.Print DatTX
               End If
          
                  For i = 1 To Len(DatTX)
                      
                  Next
          
          End Sub
          2. <OnComm subroutine>
          Code:
          Dim varBuffer As Variant
          Dim varBuffer2 As Variant
          
          Select Case mscPort.CommEvent
               Case comEvReceive
               Dim i As Long
               For i = 1 To Len(varBuffer)
                  varBuffer2 = Hex$(Asc(Mid$(varBuffer, i, 1)))
                  txtReceiveData.Text = txtReceiveData.Text & varBuffer2
               Next
          End Select
          End Sub
          With this code, I still do not get the Gyro data sentence. Is there any mistake with my code?

          Okay, That`s all.

          I need helps.
          Thanks a lot.



          Moderator wrote:
          >>It sounds as though yopu're closer to your goal, at least.

          >>Not sure what's happening here. I think we'd need to see more of the code. That >>one statement looked alright, as far as I can tell.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            I'm out of my depth here. For one thing, I've never done anything much with the comm control.

            I do have a couple of questions, though:
            • Are you sure that the command (the 10 A3 01...) is supposed to be sent as a hex representation? This seems a little surprising to me, but of course that doesn't make it wrong.
              If we take this example: 10 A3 00 - this can be a representation of 3, 6 or 8 bytes, depending on how you interpret it. That makes this kind of discussion very confusing at times. But your description seems to indicate that this represents three bytes, while your code sends it as 6 (ASCII character "1", then "0", then "A", then "3" and so on).
            • Is the text supposed to be sent twice? That definitely doesn't seem correct.
              mscPort.Output = txtSendData.Tex t & Chr(&HA)
              mscPort.Output = DatTX
            • In the OnComm routine, where did varBuffer get its value? I don't see any code to set it - is it a parameter to the event procedure?

            Comment

            • basyarie
              New Member
              • Nov 2006
              • 6

              #7
              Dear Moderator,

              Thank you very much for the response.
              Two days ago, I have finished my work completely even though only one bug is exist. But, all of my routines program could be performed properly.

              Thanks a lot.

              Next time may I will discuss here again.

              See..

              basyarie

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                Glad to hear it worked out.

                Comment

                Working...