Shop OBEX P1 Docs P2 Docs Learn Events
receiveByte() without waiting — Parallax Forums

receiveByte() without waiting

NickMNickM Posts: 2
edited 2009-03-23 15:30 in General Discussion
Hello forummembers,

I'm having a problem with the receiveByte() command.
The program communicates through the EB500 module to my laptop.
My program in a short version is this:

while ( data != '0' ) {
· // the program here
·
· if (EB500RX.byteAvailable()) {
··· data = (char) EB500RX.receiveByte();
· }
}

The idea is to execute the program continiously untill i give the 0 command on my laptop. So if·the EB500 module·receives nothing, he doesnt need to wait (receiveByte() does that) for data but needs to go on with the program.

Is there any way to accomplish this without reprogramming the UART.java? or is this necessary?

thanks in advance!

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-03-23 15:30
    Your example already does that.
    If the EB500 has no data sent, the EB500RX.byteAvailable will be false,
    and EB500RX.receiveByte() is not called, hence no wait.
    If the EB500 has sent data, the EB500RX.byteAvailable will be true and
    EB500RX.receiveByte() is called, but since there is data. it is immediately
    returned, so no wait either.

    regards peter
Sign In or Register to comment.