View Full Version : Question about repeat while/until ...

Laurent R
03-30-2009, 07:32 PM
Hi everybody

I have a problem with a serial communication.

First I through that it don't need anything else than x:= serial.RxHex but when try, it looks like the prop don't wait.

So i I try to use this code to wait a serial command before doing a task but now nothing happens when I send the command.

repeat while x==0
x := serial.RxHex

So if somebody has a idea?


Laurent R

Luis Digital
03-30-2009, 09:24 PM
Full-Duplex Serial Driver v1.1

PUB rxcheck : rxbyte

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

03-30-2009, 10:31 PM
You could try

x := 0

repeat while x==0
x := serial.RxHex

If the var is already designated as zero it might help in case it is reading a command already written somewhere else in the program.

Toys are microcontroled.
Robots are microcontroled.
I am microcontrolled.

Phil Pilgrim (PhiPi)
03-30-2009, 10:50 PM
Put the condition at the end of the loop, and you won't have that problem:

x := serial.RxHex
while x == 0

Or make the method call part of the conditional:

repeat while (x := serial.RXHex) == 0


Laurent R
03-31-2009, 04:19 PM
Thanks for your help

I have another question so i'll open a new tread :)