Yes you can. But maybe you can give an example of what you want?
Ioannis
Yes you can. But maybe you can give an example of what you want?
Ioannis
My circuit has a serial data receiver; it "waits" for three different sets of characters (= commands) to perform different actions, one at the time.
If "READ" is received, it will do this; if "WRITE" is received, it will do that and so for the third command, "COPY".
Voilą how I imagine it should be working (this is obviously not the actual code, just the idea of what it should be doing):
I need to "wait" for either incoming command but there's where I'm stuck in the DEBUGIN/SERIN2 timeout loop.Code:START: DEBUGIN 1000,START,[WAIT("READ" OR "WRITE" OR "COPY")] IF "READ" DO... IF "WRITE" DO... IF "COPY" DO... ....
Due to my lack of knowledge, I have to make my circuit currently doing only one thing...frustrating![]()
Roger
My approach would be to just receive whatever comes in, then parse it later.
+ 1My approach would be to just receive whatever comes in, then parse it later.
though life would be easier if
"READ" became "*READ/n" ditto for the others {/n=chr 13
Code:buff var byte[5] DEBUGIN 1000,START,[WAIT("*" str buff\5\13] then see what you got
Warning I'm not a teacher
Great! I'll give it a try.
Thanks a lot![]()
Roger
Thanks again Richard
Code:'======= VARIABLES ================================================================================ InString VAR BYTE[3] LED VAR RC2 Counter VAR BYTE Blinks VAR BYTE '======= INITIALIZE VARIABLES ===================================================================== InString[0] = 0 InString[1] = 0 InString[2] = 0 LED = 0 Counter = 0 Blinks = 0 '======= PROGRAM ================================================================================== ' Wait for strings: ' *AAA# = 1 blink ' *BBB# = 2 blinks ' *CCC# = 3 blinks START: Blinks = 0 DEBUGIN 1000,START,[WAIT("*"), STR InString\3\35] ' InString starts with "*" and ends with "#" if InString[0] = 65 then if InString[1] = 65 then if InString[2] = 65 then Blinks = 1 ENDIF ENDIF ENDIF if InString[0] = 66 then if InString[1] = 66 then if InString[2] = 66 then Blinks = 2 ENDIF ENDIF ENDIF if InString[0] = 67 then if InString[1] = 67 then if InString[2] = 67 then Blinks = 3 ENDIF ENDIF ENDIF BLINK: FOR Counter = 1 to Blinks LED = 1 PAUSE 500 LED = 0 PAUSE 500 NEXT Counter GOTO START END
Roger
that will do it roger
this might be a little bit faster as only one value of instring[0] can ever be true at any one time
Code:select case InString[0] case = 65 ; ps you can use case = "A" to make it more readable if InString[1] = 65 then if InString[2] = 65 then Blinks = 1 ENDIF ENDIF case 66 if InString[1] = 66 then if InString[2] = 66 then Blinks = 2 ENDIF ENDIF case 67 if InString[1] = 67 then if InString[2] = 67 then Blinks = 3 ENDIF ENDIF END select
Last edited by richard; - 2nd January 2022 at 21:58.
Warning I'm not a teacher
Bookmarks