PDA

View Full Version : Debugin conditional routine



Macgman2000
- 14th May 2013, 16:13
Hello,

I have a serial data stream that has 1 of 2 possible preambles.
%10001000
%01001000

I am currently using this command:
debugin [wait(%01001000), mydata2, mydata3 ]

The problem is I am stuck in this loop if my preamble is different? I want to be able to fall through for 2 different preambles. Is there a trick command for this? I want to always monitor for serial data.

Thanks!
Nick

Darrel Taylor
- 14th May 2013, 16:58
You can only have 1 WAIT() at a time.
But you can do it manually ... nothing "Tricky".

If the variables for each preamble are the same you could ...


Wait4Preamble:
debugin [preamble]
IF (preamble != %10001000) AND (preamble != %01001000 ) THEN Wait4Preamble
debugin [mydata2, mydata3]

Or, if the variables are different ...


Wait4Preamble:
debugin [preamble]
IF preamble = %10001000 THEN
debugin [mydata0, mydata1]
ELSE
IF preamble = %01001000 THEN
debugin [mydata2, mydata3]
ELSE
GOTO Wait4Preamble
ENDIF
ENDIF

Macgman2000
- 14th May 2013, 17:23
Hello DT,

Thanks for the info. I did think of doing that, for whatever reason I must have over throught it. I was concerned about missing the next byte. It just ocurred to me that the wait state is not all that much different than a manual loop.

Thanks!
Nick

Art
- 14th May 2013, 19:57
That wait state likely is different actually, and happening at a low level.
It should be fast enough to catch the next byte,
You would find if you had to check for many possible different values, you'd run out of time.
How long you have depends on "character pacing", and nothing to do with baud rate.