PDA

View Full Version : Question regarding RX on FullDuplexSerial



Oldbitcollector (Jeff)
09-16-2007, 03:47 AM
I'm writing a communication routine that checks for data from both the propeller keyboard as well as a remote source.

Here's a snippet from the routine.



PRI getline | i, c ,a,d,e
i := 0
repeat
c := key.getkey

e := ser.rx
text.out(e)




When the code hits e:=ser.tx it freezes, I assume waiting for something to actually come back
from the remote source. Can someone show me a way to make it behave more like the key.getkey function
so that it doesn't care if nothing is there or not and keeps on going? I'm running this in a loop, so it will
have a chance to check again in a few milseconds.

Thanks!
Oldbitcollector

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

— Calvin, of 'Cavin and Hobbes.

deSilva
09-16-2007, 04:15 AM
Bad luck, Bitcollector! SimpleSerial sports no buffer where a byte is assembled in parallel to your main activities. You have to use a more advanced object that will occupy a COG to do that.

deSilva
09-16-2007, 04:19 AM
Ooops, you are already using FullDuplexSerial, so do:



PUB rxcheck : rxbyte

'' Check if byte received (never waits)
'' returns -1 if no byte received, $00..$FF if byte

Oldbitcollector (Jeff)
09-16-2007, 05:13 AM
Bingo! This works..




PRI getline | i, c ,a,d,e
i := 0
repeat
c := key.key
if c <> 0
'text.out(c) 'Half Duplex when this line is not remarked
ser.tx(c)
if c == fReturn
ser.tx(10)
ser.tx(13)
if c == bspKey
ser.tx(8)

e := ser.rxtime(10)
if e > 10
'text.dec(e)
text.out(e)




Now, I've got a terminal program on my prop!
(Been dialing TelBBS systems with the propeller today. *very cool*)

Now to the bigger project. :)
Oldbitcollector

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

— Calvin, of 'Cavin and Hobbes.