Shop OBEX P1 Docs P2 Docs Learn Events
Question regarding RX on FullDuplexSerial — Parallax Forums

Question regarding RX on FullDuplexSerial

Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
edited 2007-09-15 22:13 in Propeller 1
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.

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-09-15 21:15
    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.
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-15 21:19
    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)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-09-15 22:13
    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. [noparse]:)[/noparse]
    Oldbitcollector

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

    — Calvin, of 'Cavin and Hobbes.
Sign In or Register to comment.