How to Serial comm. wait for a string?


Results 1 to 9 of 9

Threaded View

  1. #6
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: How to Serial comm. wait for a string?

    Hi elcrcp,

    If you look in the PBP manual under "serin2" you will find the "input modifiers" table...

    DEC{1...10} allows you to specify how many decimal digits to receive into the next variable.
    So DEC2 latdeg,DEC2 latmin,wait(".")
    will receive the next 2 decimal digits into the variable "latdeg" and then the following 2 decimal digits into "latmin"

    There is also a "SKIP n" parameter to ignore the next "n" digits, etc. etc.

    Code:
    GPRMC VAR BYTE[64]
    
    hh      VAR BYTE  'hours
    mm      VAR BYTE  'minutes
    ss      VAR BYTE  'seconds
    sss     var word  'milliseconds
    fix     VAR WORD  'GPS fix
    latdeg  VAR BYTE  'degrees latitude
    latmin  VAR BYTE  'minutes latitude  
    latminn var word  'fractional minutes latitude
    NS      VAR BYTE  'north or south
    londeg  VAR BYTE  'degrees longitude
    lonmin  VAR BYTE  'minutes longitude
    lonminn var word  'fractional minutes longitude
    EW      VAR BYTE  'east or west
    Knots   VAR byte  'speed in knots (units)
    Knotss  var byte 'speed in fractional knots
    course  var word  'heading
    dy      VAR BYTE  'day
    mt      VAR BYTE  'month
    yr      VAR BYTE  'year
    above is how I defined my varialbes...

    so if the latdeg value is between 0-255 it will fit within the "byte" sized variable even if it is 1,2 or 3 digits (ie 99, 127, 08, etc)

    PS. I may not have correctly sized all the varibles (bit, byte or word) so use your own judgment there... I wrote that code a couple of years ago.

    Since "course" could be anything between 0-359 degrees it would need to be bigger than a byte as a byte can only hold up to 255

    hope that helps
    Last edited by Heckler; - 25th December 2015 at 19:44.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

Similar Threads

  1. wait for a string
    By sahin5002 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 2nd April 2009, 23:27
  2. Serial Comm startup
    By ruijc in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th January 2008, 15:20
  3. serial comm problem
    By win_832001 in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 29th June 2006, 13:57
  4. Whats going on? serial comm
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 2nd June 2005, 11:57
  5. Serial comm Problems
    By Fossil in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th January 2004, 02:29

Members who have read this thread : 1

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