bs1->bs2sx serial problems
Archiver
Posts: 46,084
hi, I'm using 2400 baud (using correct codes on both stamps), and I
have the both serial lines connected by a 10k to ground. I also have
a common ground between both stamps. I can send the message "rdy" to
the bs1 from the bs2sx. I can send the message "x" to the bs2sx from
the bs1. However, I can't manage to send a number from the bs1 to the
bs2sx!! I know that the "rdy" and "x" are transmitted successfully,
because I have [noparse][[/noparse]wait("x")] in the bs2sx code and serin...
("rdy") in the bs1 code.
However, if I change the bs2sx code to [noparse][[/noparse]wait("x"),dec
pressure] I never get the number value to be stored in pressure,
even though my bs1 code is serout...("x",#23) . I have tried
putting pauses in between the "x" and #23 transmissions, and it still
doesn't work. Any ideas? My code is below:
'################--BS1 Code--###############
symbol bs2inP = 5 '<-comes from bs2sx io pin 2
symbol bs2outP = 6 '<-goes to bs2sx io pin 3
AD = 3
again:
ad = 3
debug "waiting",cr
serin bs2inP, N2400,("rdy")
pause 50
serout bs2outP, N2400,("x")
serout bs2outP, N2400,(#23)
debug "sent it!",cr
goto again
'##############--BS2SX Code--###############
bs1outP con 2 '<---goes to io pin 5 on bs1
bs1inP con 3 '<--comes from io pin 6 on bs1
pressure var byte
getpressure:
serout bs1outP,17405,[noparse][[/noparse]"rdy"] '<-2400 inverted
debug "waiting",cr
serin bs1inP,17405,10000,bs1error,[noparse][[/noparse]wait("x"),dec pressure]
debug "ok",cr
pause 100
high 14
pause 500
low 14
pause 3000
goto getpressure
bs1error:
debug "error!!",cr
high 15
pause 2000
low 15
goto getpressure
have the both serial lines connected by a 10k to ground. I also have
a common ground between both stamps. I can send the message "rdy" to
the bs1 from the bs2sx. I can send the message "x" to the bs2sx from
the bs1. However, I can't manage to send a number from the bs1 to the
bs2sx!! I know that the "rdy" and "x" are transmitted successfully,
because I have [noparse][[/noparse]wait("x")] in the bs2sx code and serin...
("rdy") in the bs1 code.
However, if I change the bs2sx code to [noparse][[/noparse]wait("x"),dec
pressure] I never get the number value to be stored in pressure,
even though my bs1 code is serout...("x",#23) . I have tried
putting pauses in between the "x" and #23 transmissions, and it still
doesn't work. Any ideas? My code is below:
'################--BS1 Code--###############
symbol bs2inP = 5 '<-comes from bs2sx io pin 2
symbol bs2outP = 6 '<-goes to bs2sx io pin 3
AD = 3
again:
ad = 3
debug "waiting",cr
serin bs2inP, N2400,("rdy")
pause 50
serout bs2outP, N2400,("x")
serout bs2outP, N2400,(#23)
debug "sent it!",cr
goto again
'##############--BS2SX Code--###############
bs1outP con 2 '<---goes to io pin 5 on bs1
bs1inP con 3 '<--comes from io pin 6 on bs1
pressure var byte
getpressure:
serout bs1outP,17405,[noparse][[/noparse]"rdy"] '<-2400 inverted
debug "waiting",cr
serin bs1inP,17405,10000,bs1error,[noparse][[/noparse]wait("x"),dec pressure]
debug "ok",cr
pause 100
high 14
pause 500
low 14
pause 3000
goto getpressure
bs1error:
debug "error!!",cr
high 15
pause 2000
low 15
goto getpressure
Comments
Here's what I think may be happening. With this statement:
serout bs2outP, N2400,(#23)
the BS1 sends two bytes: '2' and '3'. It then goes back to again:
and waits for the BS2SX to send "rdy". On the BS2SX side, it
receives the '2' and '3', but then waits to receive something other
than an ASCII numeric to terminate the unspecified-length DEC input.
Nothing comes because the BS1 is also waiting, so each waits on the
other.
Try this instead for the BS1 output:
serout bs2outP, N2400,(#23,0)
And this on the BS2SX side:
serin bs1inP,17405,10000,bs1error,[noparse][[/noparse]wait("x"),dec pressure,dummy]
where dummy is a throw-away variable. The BS2SX will see the null
byte, terminate the SERIN, and hopefully things will proceed on.
Regards,
Steve