Waits string.
waitrecv <sub-string> <len> <pos>
Pauses until a string, which satisfies a condition, is received from the host, or until the timeout occurs.
The condition is:
The length of the string is <len>, and the string contains the <sub-string> beginning at the <pos>th(1-origin) character.
This command confirms whether the string is matched every time <len> byte is received.
For example, if <sub-string> is "def" and <len> is 9 and <pos> is 4, the string "abcdefghi" satisfies the condition.
If such a string is received, it is saved in the system variable "inputstr".
If the system variable "timeout" or "mtimeout" is greater than zero, the timeout occurs when <timeout>.<mtimeout> seconds have passed. If the timeout is less than or equal to zero, the timeout never occurs.
These commands return one of the following values in the system variable "result":
Value | Meaning |
---|---|
-1 | A string, which contains the <sub-string> beginning at the <pos>th character, has been received, and saved in the "inputstr", but its length is less than <len> because of the timeout. |
0 | Timeout. No string, which satisfies the condition, has been received. |
1 | A string, which satisfies the condition, has been received, and saved in the "inputstr". |
; Every byte is shown in hexadecimal setdebug 2 waitrecv '43 0D' 2 1 setdebug 0 ; In this mode non printable characters are shown as control keys e.g. ^A = 1, ^B = 2 etc. setdebug 1 waitrecv 'C^M' 2 1 setdebug 0 ; Normal mode setdebug 0 waitrecv 'C'#13 2 1