Shop OBEX P1 Docs P2 Docs Learn Events
Differing Results Using the SX/B SerIn Timeout Option — Parallax Forums

Differing Results Using the SX/B SerIn Timeout Option

Sparks-R-FunSparks-R-Fun Posts: 388
edited 2006-11-22 19:12 in General Discussion
I am experiencing unexpected results with the functioning of the timeout variable as part of the SX/B “SerIn” command. The following information is given in the help file.
SX/B Help File said...
SERIN Pin, BaudMode, ByteVar {, Timeout, ToLabel}

Timeout is an optional byte or word variable/constant that tells SERIN how long to wait (in milliseconds) for incoming data. If data does not arrive in time, the program will jump to the address specified by ToLabel.

When I specify a timeout value of 10ms directly like this:
serin SIn, T9600, Temp1, 10, SerialDataPaused


it seems to work as expected with a quick jump to SerialDataPaused when no serial data is received.

However, when I try to accomplish the same thing in this manner:
tmpW1    Var    Word

tmpW1 = 10
serin SIn, T9600, Temp1, tmpW1, SerialDataPaused



the jump to SerialDataPaused when no data is received does not occur for well over a minute! =O

It seems to me that both methods should produce nearly similar results. What am I missing? Have I overlooked something obvious in regard to the use of a variable?

- Sparks

Comments

  • BeanBean Posts: 8,129
    edited 2006-11-22 18:32
    Use a byte variable instead of word variable for the timeout.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
    ·
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2006-11-22 19:12
    Bean,

    Thanks for the quick reply! smile.gif

    For my application (a bar code reader) I do not know exactly when to expect the serial data to begin. It could take several seconds for the label to found and read. My intention is to allow up to 5,000 ms (5 seconds) for the first character to be received. The amount of data actually transmitted varies with each different label type but once the data starts flowing the data stream does not pause until all the data has been sent. I was hoping to place the “SerIn” command in a subroutine and call it once with a very long timeout value to catch the first character and then repeatedly thereafter with a very short timeout value to catch the remaining characters. The occurrence of a timeout would signal the end of expected data.

    Do you expect the support of a word variable for the timeout value to be incorporated into a future release?

    I think I can work around this now that I understand the limitation. As always, I appreciate the response and the effort put into the compiler!

    - Sparks
Sign In or Register to comment.