For Next Loops and Serin2?


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2005
    Posts
    37

    Default For Next Loops and Serin2?

    I am trying to use SERIN2 and get 1 byte at a time! The data being received could be any lenght up to 32 bytes. I have tried the following but it seems to fail. Can anyone tell me if this will work? K will be to send the characters out another port.

    Code:
    mainloop:
        for i = 0 to 31
            serin2 GPIO.1,84,1000,mainloop,[str receive\1]
            command[i] = receive
            k = k + 1
            if (command[i] == 13) then goto process
        next i
    
    process:
        SEROUT2 GPIO.0,84,["packet len", dec k, " ",  str command\k,13]
    goto mainloop
    Thanks in advance,

    Scott

  2. #2


    Did you find this post helpful? Yes | No

    Default Try this

    Here is what I do to parse an unknown length GPS message.

    GetData:
    ProcessRMC:
    serin2 rx232, 188, 2000, nogps,[WAIT("$GPRMC")] ' find start
    for i = 0 to 84 ' plenty of length - can be cut back
    serin2 rx232, 188, [a[i]]
    next i

    Here I bring in 84 characters after first finding the $GPRMC header. Having made the 84 character array I then go through it and count commas to find the particular fields I am looking for.

    The complete code was posted to the GPS section of this forum a couple of years back.

    HTH
    Brian

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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