Shop OBEX P1 Docs P2 Docs Learn Events
Wondering about Full Duplex Serial — Parallax Forums

Wondering about Full Duplex Serial

HumanOzzHumanOzz Posts: 13
edited 2010-07-29 06:20 in Propeller 1
Hey guys,

i was just wondering about the object Full duplex serial. At the start~

bla.start(.....) at the main program to initializing the object with a new cog.

From the full duplex serial program:

PUB rx : rxbyte

'' Receive byte (may wait for byte)
'' returns $00..$FF

repeat while (rxbyte := rxcheck) < 0

Well, basically i was wondering about this part, if i put in at the main program -

somename := bla.rx

Its actually using the main program cog to wait for a byte right?
Correct me if i'm wrong.
If its actualy using another cog other than the main program one is using, then it is using the cog it has used in the initialization right?
If this is the case, so that means that after the initialization, this object is given a cog to the rest of the things in the fullduplex code.
Which one is correct?
Thanks
jumpin.gif

Comments

  • KyeKye Posts: 2,200
    edited 2010-07-29 04:16
    The main cog will be waiting for a byte to come in.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • Mike GreenMike Green Posts: 23,101
    edited 2010-07-29 04:24
    When you do the .start call, you're starting another cog (with COGNEW) that takes care of receiving and transmitting data into and out of buffers that are declared in FullDuplexSerial. The .start call initializes the buffers so they appear empty. When the new cog finally gets going (after about 100us), it will put any received bytes into the receive buffer and transmit any bytes put into the transmit buffer. The .rx call checks the buffer pointers and waits for at least one character to be in the buffer, then removes a character from the buffer and returns its value.
  • HumanOzzHumanOzz Posts: 13
    edited 2010-07-29 04:40
    Thanks for the quick reply,
    Mike, are you saying that the main program cog is not used to wait for a byte?
  • AribaAriba Posts: 2,690
    edited 2010-07-29 06:20
    If you call the rx methode, the main cog will wait until a byte is in the rx-buffer. This is useful if you need that received byte before you can continue the program.

    If you only want check if a byte is in the buffer, then use the rxcheck methode.
    if you want wait a certain time for a byte then use the rxtime methode.

    Andy
Sign In or Register to comment.