Shop OBEX P1 Docs P2 Docs Learn Events
Reading a value using Serin and DEC — Parallax Forums

Reading a value using Serin and DEC

ArchiverArchiver Posts: 46,084
edited 2000-06-13 17:06 in General Discussion
I am trying to use the Serin command to set a variable
(16bit WORD named "OUTROC"). I want to send in decimal
data. I am using the DEC keyword. But my BS2 will only
accept 2 characters. I don't know why it won't wait for
the "non-numeric" value to stop reading the characters
andset the variable.

I am using a speed of 19200 with 8N. Does this have
anything to do with flow control? I am connected
directlyto my PC.

The following code is supposed to read a string of numeric
characters, set the value to OUTROC and then echo the same
value back to the controller.

OUTROC VAR WORD
SERIN 14,32,[noparse][[/noparse]DEC OUTROC]
debug ? OUTROC
SEROUT 13,32,[noparse][[/noparse]DEC OUTROC]

If I send "1234" from my PC, the stamp will only echo "12".
I've tried using DEC4, but the same problem remains.

Thanks!

__________________________________________________
Do You Yahoo!?
Yahoo! Photos -- now, 100 FREE prints!
http://photos.yahoo.com

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-06-13 17:06
    >The following code is supposed to read a string of numeric
    >characters, set the value to OUTROC and then echo the same
    >value back to the controller.
    >
    > OUTROC VAR WORD
    > SERIN 14,32,[noparse][[/noparse]DEC OUTROC]
    > debug ? OUTROC
    > SEROUT 13,32,[noparse][[/noparse]DEC OUTROC]
    >
    >If I send "1234" from my PC, the stamp will only echo "12".
    >I've tried using DEC4, but the same problem remains.

    Try it at a lower baud rate, or with pacing between the characters of the
    string. The Stamp may have trouble receiving data at 19200, if the
    characters of the string are sent one right on top of one another. It may
    be missing the start bit on your third character.

    The most reliable syntax for receiving strings at high baud rates on the
    stamp is:
    X var byte(4) ' string array 4 bytes
    serin 14,32,[noparse][[/noparse]STR X\4]
    debug ? str x\4
    ' have to convert string to word variable

    -- Tracy Allen
    Electronically Monitored Ecosystems
    http://www.emesystems.com
Sign In or Register to comment.