Serin Serout issue == with code
Archiver
Posts: 46,084
Hello can anyone help?
I am presently working on a project to emulate the serial lcd's and
backpacks that exist. I am using two BS2's one as the host and the
other one connected to the LCD. I am attempting to program the BS2
that is connected to the LCD such that it reads the commands sent to
it by the host BS2 by means of Serout and Serin. The host BS2 sends
multiple serout commands to the BS2 with the LCD and I have it
running in a loop. I have the BS2 with the LCD looping with a serin
command to read and interpret the host's serouts. However the BS2
with the LCD only accepts the first serout sent by the host and not
the other ones. Any help would be appreciated. I placed a condensed
version of the code below.
Thanks,
Vince
'*********************************************************************
****
'send
'*********************************************************************
****
ser_out_pin CON 1
Main:
SEROUT ser_out_pin,84,[noparse][[/noparse]"@",$FE,"G",$00,$01] 'Send Column and Row
SEROUT ser_out_pin,84,[noparse][[/noparse]"@","TEST1"] 'Send string
SEROUT ser_out_pin,84,[noparse][[/noparse]"@",$FE,"G",$01,$02] 'Send Column and Row
SEROUT ser_out_pin,84,[noparse][[/noparse]"@","TEST2"] 'Send string
GOTO main
'*********************************************************************
****
'receive
'*********************************************************************
****
S_String VAR Byte [noparse][[/noparse]5]
SI VAR P0 ' Serial In
Main:
Again:
GOSUB in_
GOTO Again
in_:
SerIn2 SI,84,[noparse][[/noparse]WAIT("@"),command,Instruction,Column,Row] ' Get Serial
Data in
SerIn2 SI,84,[noparse][[/noparse]WAIT("@"),STR S_String0\5]
RETURN
decode:
'decode and display
RETURN
I am presently working on a project to emulate the serial lcd's and
backpacks that exist. I am using two BS2's one as the host and the
other one connected to the LCD. I am attempting to program the BS2
that is connected to the LCD such that it reads the commands sent to
it by the host BS2 by means of Serout and Serin. The host BS2 sends
multiple serout commands to the BS2 with the LCD and I have it
running in a loop. I have the BS2 with the LCD looping with a serin
command to read and interpret the host's serouts. However the BS2
with the LCD only accepts the first serout sent by the host and not
the other ones. Any help would be appreciated. I placed a condensed
version of the code below.
Thanks,
Vince
'*********************************************************************
****
'send
'*********************************************************************
****
ser_out_pin CON 1
Main:
SEROUT ser_out_pin,84,[noparse][[/noparse]"@",$FE,"G",$00,$01] 'Send Column and Row
SEROUT ser_out_pin,84,[noparse][[/noparse]"@","TEST1"] 'Send string
SEROUT ser_out_pin,84,[noparse][[/noparse]"@",$FE,"G",$01,$02] 'Send Column and Row
SEROUT ser_out_pin,84,[noparse][[/noparse]"@","TEST2"] 'Send string
GOTO main
'*********************************************************************
****
'receive
'*********************************************************************
****
S_String VAR Byte [noparse][[/noparse]5]
SI VAR P0 ' Serial In
Main:
Again:
GOSUB in_
GOTO Again
in_:
SerIn2 SI,84,[noparse][[/noparse]WAIT("@"),command,Instruction,Column,Row] ' Get Serial
Data in
SerIn2 SI,84,[noparse][[/noparse]WAIT("@"),STR S_String0\5]
RETURN
decode:
'decode and display
RETURN
Comments
I am presently working on a project to emulate the serial lcd's and
backpacks that exist. I am using two BS2's one as the host and the
other one connected to the LCD. I am attempting to program the BS2
that is connected to the LCD such that it reads the commands sent to
it by the host BS2 by means of Serout and Serin. The host BS2 sends
multiple serout commands to the BS2 with the LCD and I have it
running in a loop. I have the BS2 with the LCD looping with a serin
command to read and interpret the host's serouts. However the BS2
with the LCD only accepts the first serout sent by the host and not
the other ones. Any help would be appreciated. I placed a condensed
version of the code below.
Thanks,
Vince
'*********************************************************************
****
'send
'*********************************************************************
****
ser_out_pin CON 1
Main:
SEROUT ser_out_pin,84,[noparse][[/noparse]"@",$FE,"G",$00,$01] 'Send Column and Row
SEROUT ser_out_pin,84,[noparse][[/noparse]"@","TEST1"] 'Send string
SEROUT ser_out_pin,84,[noparse][[/noparse]"@",$FE,"G",$01,$02] 'Send Column and Row
SEROUT ser_out_pin,84,[noparse][[/noparse]"@","TEST2"] 'Send string
GOTO main
'*********************************************************************
****
'receive
'*********************************************************************
****
S_String VAR Byte [noparse][[/noparse]5]
SI VAR P0 ' Serial In
Main:
Again:
GOSUB in_
GOTO Again
in_:
SerIn2 SI,84,[noparse][[/noparse]WAIT("@"),command,Instruction,Column,Row] ' Get Serial
Data in
SerIn2 SI,84,[noparse][[/noparse]WAIT("@"),STR S_String0\5]
RETURN
decode:
'decode and display
RETURN
coming at any given time, you won't be able to do a full-speed
emulation. You'll need to send a byte at a time with a delay (pacing)
between so that the slave Stamp can figure out what to do with the
incoming byte.
Based on the command sent, the slave can jump to a routine to handle the
number of incoming bytes for a given command. With strings, it's a bit
trickier. You'll have to jump to a loop that keeps receiving and
printing characters with a timeout on SERIN that's just a bit slower
than the host's pacing. That way, the slave will breakout of the loop
when the host stops sending the string data.
I wrote an article on communicating between VB and a Stamp that uses a
similar techique; it may be helpful. You can download a PDF version
from our web site.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: enzom2000 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=QR-P3pt9efGUv4TvyBlDJBfovjs_ptlEEHSnlUYwvrYtXwAhUfSoTAUTFnmqoWsVtFTe3bcuNCBxe-LBWGXIW9IiAZTkRQ]vincent.mansueto@s...[/url
Sent: Monday, August 18, 2003 8:12 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Serin Serout issue == with code
Hello can anyone help?
I am presently working on a project to emulate the serial lcd's and
backpacks that exist. I am using two BS2's one as the host and the
other one connected to the LCD. I am attempting to program the BS2
that is connected to the LCD such that it reads the commands sent to
it by the host BS2 by means of Serout and Serin. The host BS2 sends
multiple serout commands to the BS2 with the LCD and I have it
running in a loop. I have the BS2 with the LCD looping with a serin
command to read and interpret the host's serouts. However the BS2
with the LCD only accepts the first serout sent by the host and not
the other ones. Any help would be appreciated. I placed a condensed
version of the code below.
Thanks,
Vince
'*********************************************************************
****
'send
'*********************************************************************
****
ser_out_pin CON 1
Main:
SEROUT ser_out_pin,84,[noparse][[/noparse]"@",$FE,"G",$00,$01] 'Send Column and Row
SEROUT ser_out_pin,84,[noparse][[/noparse]"@","TEST1"] 'Send string
SEROUT ser_out_pin,84,[noparse][[/noparse]"@",$FE,"G",$01,$02] 'Send Column and Row
SEROUT ser_out_pin,84,[noparse][[/noparse]"@","TEST2"] 'Send string
GOTO main
'*********************************************************************
****
'receive
'*********************************************************************
****
S_String VAR Byte [noparse][[/noparse]5]
SI VAR P0 ' Serial In
Main:
Again:
GOSUB in_
GOTO Again
in_:
SerIn2 SI,84,[noparse][[/noparse]WAIT("@"),command,Instruction,Column,Row] ' Get Serial
Data in
SerIn2 SI,84,[noparse][[/noparse]WAIT("@"),STR S_String0\5]
RETURN
decode:
'decode and display
RETURN
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....
Vince
--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> Since the Stamp doesn't have a serial buffer and you don't know
what's
> coming at any given time, you won't be able to do a full-speed
> emulation. You'll need to send a byte at a time with a delay
(pacing)
> between so that the slave Stamp can figure out what to do with the
> incoming byte.
>
> Based on the command sent, the slave can jump to a routine to
handle the
> number of incoming bytes for a given command. With strings, it's a
bit
> trickier. You'll have to jump to a loop that keeps receiving and
> printing characters with a timeout on SERIN that's just a bit slower
> than the host's pacing. That way, the slave will breakout of the
loop
> when the host stops sending the string data.
>
> I wrote an article on communicating between VB and a Stamp that
uses a
> similar techique; it may be helpful. You can download a PDF version
> from our web site.
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
Original Message
> From: enzom2000 [noparse][[/noparse]mailto:vincent.mansueto@s...]
> Sent: Monday, August 18, 2003 8:12 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Serin Serout issue == with code
>
>
> Hello can anyone help?
> I am presently working on a project to emulate the serial lcd's and
> backpacks that exist. I am using two BS2's one as the host and the
> other one connected to the LCD. I am attempting to program the BS2
> that is connected to the LCD such that it reads the commands sent
to
> it by the host BS2 by means of Serout and Serin. The host BS2 sends
> multiple serout commands to the BS2 with the LCD and I have it
> running in a loop. I have the BS2 with the LCD looping with a serin
> command to read and interpret the host's serouts. However the BS2
> with the LCD only accepts the first serout sent by the host and not
> the other ones. Any help would be appreciated. I placed a condensed
> version of the code below.
>
> Thanks,
>
> Vince
>
> '*******************************************************************
**
> ****
> 'send
> '*******************************************************************
**
> ****
>
> ser_out_pin CON 1
>
>
>
> Main:
>
>
> SEROUT ser_out_pin,84,[noparse][[/noparse]"@",$FE,"G",$00,$01] 'Send Column and Row
> SEROUT ser_out_pin,84,[noparse][[/noparse]"@","TEST1"] 'Send string
> SEROUT ser_out_pin,84,[noparse][[/noparse]"@",$FE,"G",$01,$02] 'Send Column and Row
> SEROUT ser_out_pin,84,[noparse][[/noparse]"@","TEST2"] 'Send string
>
>
> GOTO main
>
> '*******************************************************************
**
> ****
> 'receive
> '*******************************************************************
**
> ****
>
> S_String VAR Byte [noparse][[/noparse]5]
> SI VAR P0 ' Serial In
>
>
>
> Main:
>
> Again:
>
> GOSUB in_
> GOTO Again
>
>
>
> in_:
> SerIn2 SI,84,[noparse][[/noparse]WAIT("@"),command,Instruction,Column,Row] ' Get
Serial
> Data in
> SerIn2 SI,84,[noparse][[/noparse]WAIT("@"),STR S_String0\5]
> RETURN
>
> decode:
>
> 'decode and display
>
> RETURN
>
>
>
> 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...
between commands so the receiver can do something
with them.
A simple 'PAUSE 100' between the SEROUT commands
may be sufficient -- PAUSE 1000 would surely
be enough. Note the 'PAUSE' parameter is in
milli-seconds (mSec).
This approach would have the least impact on
your 'emulation', as only the sender would
need to be modified, and only by adding a line
here and there.
To make it most general, perhaps:
PauseVal CON 1000
...
PAUSE PauseVal
...
That way, you can easily adjust the pause duration
until you find one that works well. Note that
'CON' entries don't take variable space -- the
math and replacement is done at compile time.
--- In basicstamps@yahoogroups.com, "enzom2000"
<vincent.mansueto@s...> wrote:
> Hello can anyone help?
> I am presently working on a project to emulate the serial lcd's and
> backpacks that exist. I am using two BS2's one as the host and the
> other one connected to the LCD. I am attempting to program the BS2
> that is connected to the LCD such that it reads the commands sent
to
> it by the host BS2 by means of Serout and Serin. The host BS2 sends
> multiple serout commands to the BS2 with the LCD and I have it
> running in a loop. I have the BS2 with the LCD looping with a serin
> command to read and interpret the host's serouts. However the BS2
> with the LCD only accepts the first serout sent by the host and not
> the other ones. Any help would be appreciated. I placed a condensed
> version of the code below.
>
> Thanks,
>
> Vince
>
> '*******************************************************************
**
> ****
> 'send
> '*******************************************************************
**
> ****
>
> ser_out_pin CON 1
>
>
>
> Main:
>
>
> SEROUT ser_out_pin,84,[noparse][[/noparse]"@",$FE,"G",$00,$01] 'Send Column and Row
> SEROUT ser_out_pin,84,[noparse][[/noparse]"@","TEST1"] 'Send string
> SEROUT ser_out_pin,84,[noparse][[/noparse]"@",$FE,"G",$01,$02] 'Send Column and Row
> SEROUT ser_out_pin,84,[noparse][[/noparse]"@","TEST2"] 'Send string
>
>
> GOTO main
>
> '*******************************************************************
**
> ****
> 'receive
> '*******************************************************************
**
> ****
>
> S_String VAR Byte [noparse][[/noparse]5]
> SI VAR P0 ' Serial In
>
>
>
> Main:
>
> Again:
>
> GOSUB in_
> GOTO Again
>
>
>
> in_:
> SerIn2 SI,84,[noparse][[/noparse]WAIT("@"),command,Instruction,Column,Row] ' Get
Serial
> Data in
> SerIn2 SI,84,[noparse][[/noparse]WAIT("@"),STR S_String0\5]
> RETURN
>
> decode:
>
> 'decode and display
>
> RETURN