Problem receiving string


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    This should work for a CR terminated string. It will collect uptil CR or 14 characters.

    serin2 rx,baud,5000,main,[WAIT("REC UNREAD"),SKIP 3,STR num\13,SKIP 27,STR sms\14\13]

    From the manual :
    STR ArrayVar\n{\c} - Receive string of n characters optionally ended in character c

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Or...

    You can use the time out to check your array string.

    Code:
    serin2 rx,baud,5000,main,[WAIT("REC UNREAD"),SKIP 3,STR num\13,SKIP 27,STR sms\14]
    From the above code, if you don't receive the whole string (14 characters) then at timeout, program will jump to label main, here you can check your array sms

    Code:
    main:
    A0=0
    for B0=0 to 13
    if sms[B0]>0 then A0=A0+1
    next B0
    If A0 >0 then goto decode

    If variable A0 is found >0 then your array has been loaded and program jump to label Decode where you will decode sms array from sms[0] to sms[A0-1].

    Is there any way I can make this code work if it receives from 1 to upto 14 characters.
    Once in routine Decode,A0 can be anything from 1 to 14 just what you where searching for.

    Naturally, before to go to Serin2 you must clear (set to zero) the array sms.

    Al.
    Last edited by aratti; - 12th October 2009 at 07:32.
    All progress began with an idea

Similar Threads

  1. Receiving Different String lengths
    By Jannie in forum Serial
    Replies: 5
    Last Post: - 26th January 2009, 05:00
  2. Floating Point Display Problem (serial string out)
    By Cash Olsen in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th December 2007, 02:03
  3. Math problem with string result
    By Lotondo in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 15th November 2006, 10:06
  4. Visual Basic 6 & Access 2000
    By Demon in forum Off Topic
    Replies: 33
    Last Post: - 7th September 2006, 04:39
  5. USART Problem Receiving Bytes
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th September 2005, 17:50

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