timeout for Simple_Serial read?
janb
Posts: 74
Hi,
I'm using Simple_Serial OBJ to read characters from pin=26=Rx:
rs: "Simple_Serial"
...
·rs.start(26,-1,9600)
...
repeat 'endless loop
· · c:=rs.rx
··· tv.out(c)
It may happen the sender is not functioning and I'd like to abort this loop
after e.g. 10 seconds.
Since the coge runing rs.tx hangs on
··· waitpeq(inverted & |< sin, |< sin, 0)·············· ' wait for start bit
I was thinking to fire· cog#2 at the start and after some time out
execute on cog#2
·· dira[noparse][[/noparse]26]:=0
···outa[noparse][[/noparse]26]:=0 ' produce a·false input message
But it seems to not work, cog#1 still hangs.
Is there any other trick I could·try perhaps?
Thanks
Jan·
I'm using Simple_Serial OBJ to read characters from pin=26=Rx:
rs: "Simple_Serial"
...
·rs.start(26,-1,9600)
...
repeat 'endless loop
· · c:=rs.rx
··· tv.out(c)
It may happen the sender is not functioning and I'd like to abort this loop
after e.g. 10 seconds.
Since the coge runing rs.tx hangs on
··· waitpeq(inverted & |< sin, |< sin, 0)·············· ' wait for start bit
I was thinking to fire· cog#2 at the start and after some time out
execute on cog#2
·· dira[noparse][[/noparse]26]:=0
···outa[noparse][[/noparse]26]:=0 ' produce a·false input message
But it seems to not work, cog#1 still hangs.
Is there any other trick I could·try perhaps?
Thanks
Jan·
Comments
-Phil
' To wait for a low level on both pins 25 (as timeout helper) and 26 (as serial in):
frqb := 1
dira[noparse][[/noparse]25] := 1
cntb := nco_mode | 25 ' NCO mode, pin pa25
phsb := -10 * clkfreq ' starts with p25 high, low after 10 seconds
waitpne( (|< 26) | (|< 25), (|< 26) | (|< 25), 0)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
thanks for all advices.
I took from them :
- it is possible
- protect RX·pin w/ resistor , done
Attached files show a soultion:
- second Simple_Serial OBJ initialized with reveresed Rx<-->TX pins
- activated·on a··2nd cog after time out of 7 seconds
·· sends some emergency text to the RXpin·for the 1st cog,
·· next·restores·this pin·back as input
Works good , the tcl script can be fired to test the RX pin reads from external soruce all the time.
The advatage of this aproach (in my opinion) is I have avoided ·low level commands. (except one dira[noparse][[/noparse]pinRx]~·· )
Thanks
Jan