Shop OBEX P1 Docs P2 Docs Learn Events
Serin WAIT & Timeout — Parallax Forums

Serin WAIT & Timeout

Helen CHelen C Posts: 34
edited 2004-09-14 08:25 in BASIC Stamp
Am I correct in assuming that if you use the "WAIT" command in the following line of code and the stamp receives some serial data but not the "+" that is·waiting for then·the timeout will never execute?

SERIN RX\FLOW,BAUD,60000,No_Response,[noparse][[/noparse]WAIT ("+"),DEC value]

If this is·the case should I write all the data byte by byte to the eeprom and then read it back to find the "+" and "value"?

Thanks in advance for any sugesstions.

Helen

Comments

  • NewzedNewzed Posts: 2,503
    edited 2004-09-13 17:28
    If you use the WAIT modifier with a serin, the Stamp will wait forever if you have no timeout.· With a timeout it will go to the specified label when the timeout period has expired.·

    I really don't understand your second question.· The WAIT modifier must be a part of the serin command - I don't think you can import it as DATA, if that is what you meant.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Try the Stamp Tester

    http://hometown.aol.com/newzed/index.html
    ·
  • K de JongK de Jong Posts: 154
    edited 2004-09-13 17:34
    Hi Helen,

    No, after the timeout time the program will jump to your No_Response label.

    I use this code in one of my programs:
    SERIN 16,BAUD,950,LBL,[noparse][[/noparse]WAIT("S"),UniByte]

    If there is an "S" it will take a Byte as input. If it has to wait longer than 950 ms it will jump to label LBL:

    I hope this will help,

    Klaus
  • Helen CHelen C Posts: 34
    edited 2004-09-13 17:48
    Thanks for the replies but I am still having trouble.· I am using the WAIT and timeout as above but sometimes my program never times out.· What I suspect is happening is that occasionally the stamp·receives some serial data but not the "+" specified by the WAIT moderator.·

    I seem to remember reading something on the old Stamp forum about this issue to the effect that if this happens the SERIN command will not timeout.· Is this correct?

    Helen
  • NewzedNewzed Posts: 2,503
    edited 2004-09-13 17:52
    Change your WAIT modifier from " + " to something more complex, like "ABC".· Then see what happens.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Try the Stamp Tester

    http://hometown.aol.com/newzed/index.html
    ·
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2004-09-13 18:24
    SERIN RX\FLOW,BAUD,60000,No_Response,[noparse][[/noparse]WAIT ("+"),DEC value]
    



    The command times out only if there is a timeout interval (60 seconds on a BS2) of complete silence on the serial line. If there is activity of any kind on the serial line (even noise) more frequently than once per minute, it may never time out.

    Since you are using the flow control, it may be possible to write a loop that has a much lower timeout value and tests each byte that comes in. It depends on what it on the other end of the comm link and how it treats the flow control.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-09-13 18:38
    To quote the online help file:
    Online Help said...
    Here's a very important concept: this timeout feature is not picky about the kind of data SERIN receives; if any serial data is received, it prevents the timeout. In the example above, SERIN wants a decimal number. But even if SERIN received letters "ABCD..." at intervals of less than two seconds, it would never abort.
    So apparently, as long as data is coming in, the timeout counter is reset, preventing timeout.· If your data is never seen, then you will be stuck there.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-09-13 18:40
    Ah Tracy, you posted a reply while I was copying and pasting...I guess I gotta be a little quicker on the draw...

    smilewinkgrin.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
  • Helen CHelen C Posts: 34
    edited 2004-09-14 08:25
    That is what I thought. I will go with Tracys suggestion of a shorter timeout and checking each byte as it comes in.

    Thanks for the help.

    Helen
Sign In or Register to comment.