RobotStudio event

Checking data from serial channel

Is there a way to see if there is data in the serial buffer and if there is not then continue?  I have a While loop where I want to see if another piece of equipment has sent data.  If it has not then I want to do some other things.

WHILE TRUE DO
        szCMDResult := ReadStr(ReadData\Delim:="-");     
TEST szCMDResult
CASE szTest1:
ENDTEST
!Do something else
ENDWHILE

Thanks
  

Comments

  • So this is what I have come up with.  Please tell me if it is stupid and I am just missing something.

    I basically catch the error of a time out.

    WHILE TRUE DO
    szCMDResult := ReadStr(ReadData\Delim:="-"\Time:=2);
    TEST szCMDResult
    CASE szTest1:
    ENDTEST
    !Do something else
    ENDWHILE
    ......
            IF ERRNO = ERR_DEV_MAXTIME THEN
                TRYNEXT;
            ENDIF

    Any thoughts?