Shop OBEX P1 Docs P2 Docs Learn Events
Question about repeat while/until ... — Parallax Forums

Question about repeat while/until ...

Laurent RLaurent R Posts: 27
edited 2009-03-31 09:19 in Propeller 1
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?

Thanks

Laurent R

Comments

  • Luis DigitalLuis Digital Posts: 371
    edited 2009-03-30 14:24
    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
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2009-03-30 15:31
    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)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-30 15:50
    Put the condition at the end of the loop, and you won't have that problem:

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


    Or make the method call part of the conditional:

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


    -Phil
  • Laurent RLaurent R Posts: 27
    edited 2009-03-31 09:19
    Thanks for your help

    I have another question so i'll open a new tread [noparse]:)[/noparse]
Sign In or Register to comment.