SPIN newbie needs help with REPEAT UNTIL
K6MLE
Posts: 106
in Propeller 1
Here is the code I've got so far (snip of the pertinent section):
text.Start(12)
pst.StartRxTx(9,6,0,2_400)
BYTEFILL(@inbuf,0,bufsize)
repeat until inbuf[0] == $24
pst.StrIn(@inbuf) ' read the rxpin until CR encountered.
' repeat
WindSpeed
Temperature
WindDir
RainGuage
What I'm expecting is for the four routines to display Speed, Temp, Dir & Rain only when there is a valid read of the serial port (looking for "$"). Otherwise I want the program to just sit and wait for the incoming "$". The way it's written now, I get one pass through the program and no more. I'm confused with the nesting of the REPEAT commands.
text.Start(12)
pst.StartRxTx(9,6,0,2_400)
BYTEFILL(@inbuf,0,bufsize)
repeat until inbuf[0] == $24
pst.StrIn(@inbuf) ' read the rxpin until CR encountered.
' repeat
WindSpeed
Temperature
WindDir
RainGuage
What I'm expecting is for the four routines to display Speed, Temp, Dir & Rain only when there is a valid read of the serial port (looking for "$"). Otherwise I want the program to just sit and wait for the incoming "$". The way it's written now, I get one pass through the program and no more. I'm confused with the nesting of the REPEAT commands.
Comments
-Phil
can only work if another cog overwrites inbuf[0], but I think that is not the case here.
so you need something like that:
or simpler:
Andy
This is the code for Main.