serin problem building integers
Archiver
Posts: 46,084
When I grab an input through the SERIN function like:
aTarget var word
serin inputPortReceive,$40f0,[noparse][[/noparse]WAIT("@"),dec aTarget]
and then send over some bytes through that serial port, as soon as
the @ character is received, the Stamp starts building a word length
integer. As soon as a non-integer character arrives, such as "!",
the variable aTarget gets set. This all works great, so if I send
the string "@12233!", the aTarget var gets set to 12233 and I can use
it in the Stamp. But if I send 3 identical characters in a row, the
third like character seems to get interpreted as a non-integer
character. So if I send the string "@12223!" the Stamp sets the
aTarget variable to 122 since the third 2 in a row gets seen as some
invalid character. Has anyone else seen this, and if so, is it
possible to overcome?
Thanks,
/John
aTarget var word
serin inputPortReceive,$40f0,[noparse][[/noparse]WAIT("@"),dec aTarget]
and then send over some bytes through that serial port, as soon as
the @ character is received, the Stamp starts building a word length
integer. As soon as a non-integer character arrives, such as "!",
the variable aTarget gets set. This all works great, so if I send
the string "@12233!", the aTarget var gets set to 12233 and I can use
it in the Stamp. But if I send 3 identical characters in a row, the
third like character seems to get interpreted as a non-integer
character. So if I send the string "@12223!" the Stamp sets the
aTarget variable to 122 since the third 2 in a row gets seen as some
invalid character. Has anyone else seen this, and if so, is it
possible to overcome?
Thanks,
/John
Comments
* The BASIC Stamp 2sx and BASIC Stamp 2p may have trouble synchronizing
with the incoming serial stream at this rate and higher due to the lack
of a hardware input buffer. Use only simple variables and no formatters
to try to solve this problem.
Have you tested your code at a lower baud rate? The setup time between
the WAIT and DEC modifiers may be giving you trouble at 9600 baud.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: John Schwab [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=hjpQPliXSg7ugOXRz31tvkLK-7HaSelnzp-B1nwoyYUPKylUdMpdSVlJgvFbRNe1I6RGXMGKQGHWCA5tV04C9QE]johnschwab5678@y...[/url
Sent: Thursday, September 11, 2003 7:05 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] serin problem building integers
When I grab an input through the SERIN function like:
aTarget var word
serin inputPortReceive,$40f0,[noparse][[/noparse]WAIT("@"),dec aTarget]
and then send over some bytes through that serial port, as soon as
the @ character is received, the Stamp starts building a word length
integer. As soon as a non-integer character arrives, such as "!",
the variable aTarget gets set. This all works great, so if I send
the string "@12233!", the aTarget var gets set to 12233 and I can use
it in the Stamp. But if I send 3 identical characters in a row, the
third like character seems to get interpreted as a non-integer
character. So if I send the string "@12223!" the Stamp sets the
aTarget variable to 122 since the third 2 in a row gets seen as some
invalid character. Has anyone else seen this, and if so, is it
possible to overcome?
Thanks,
/John
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
which solved the problem. It is very strange that no matter how
slowly (time between character) I send the characters across the line
(at 9600bps), three like characters cause a problem when WAIT is in
use. So I worked around it by waiting for a special character, and
then doing a SERIN with no wait. This way the Stamp waits for
the "@" character, and then grabs the word length integer. I tested
this, and it allows me to grab integers like 22222, etc.
Thanks,
/John
--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> There is this cautionary note in the manual and the online help
file:
>
> * The BASIC Stamp 2sx and BASIC Stamp 2p may have trouble
synchronizing
> with the incoming serial stream at this rate and higher due to the
lack
> of a hardware input buffer. Use only simple variables and no
formatters
> to try to solve this problem.
>
> Have you tested your code at a lower baud rate? The setup time
between
> the WAIT and DEC modifiers may be giving you trouble at 9600 baud.
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
Original Message
> From: John Schwab [noparse][[/noparse]mailto:johnschwab5678@y...]
> Sent: Thursday, September 11, 2003 7:05 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] serin problem building integers
>
>
> When I grab an input through the SERIN function like:
>
> aTarget var word
> serin inputPortReceive,$40f0,[noparse][[/noparse]WAIT("@"),dec aTarget]
>
> and then send over some bytes through that serial port, as soon as
> the @ character is received, the Stamp starts building a word
length
> integer. As soon as a non-integer character arrives, such as "!",
> the variable aTarget gets set. This all works great, so if I send
> the string "@12233!", the aTarget var gets set to 12233 and I can
use
> it in the Stamp. But if I send 3 identical characters in a row,
the
> third like character seems to get interpreted as a non-integer
> character. So if I send the string "@12223!" the Stamp sets the
> aTarget variable to 122 since the third 2 in a row gets seen as
some
> invalid character. Has anyone else seen this, and if so, is it
> possible to overcome?
>
> Thanks,
> /John
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
Subject
> and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>
> This message has been scanned by WebShield. Please report SPAM to
> abuse@p...