Hello
i'm currently do the commissioning on a LRMate 200iC / R30ia Mate
i have not written the program by myself and it contains some Karel routines. I encounter a random problem with one of these
and i'm not very comfortable with it. So i try to explain clearly as possible ..
this routine is running cyclically in a "repeat until" loop in order to "listen an RS232 port (see the routine below!)
which receives 4 digits codes from a C# program.
the issue: randomly (let's say 2 3 times a day), on the instruction SET_INT_REG(28,rval,status) , the program is aborted with INTP311 "uninitialized data".
My opinion is that on this instruction READ RS232 (buffer_in::4) then CNV_STR_INT(reception, rval)
the format of the data rval sometimes is bad then it is not valid for the SET_INT_REG instruction..
My question is: is someone could help me to write a test statement to control the validity of the data rval before use the SET_INT_REG(28,rval,status)
then if the quality of the data is bad, it is not taken in account..??
Thanks in advance for help
BELOW THE ROUTINE
----------------------------------------------------------------------------------
fPROGRAM COM_IN1
%COMMENT = 'RECEPTION sur RS232'
%NOLOCKGROUP
%NOPAUSE = ERROR + COMMAND + TPENABLE
%NOABORT = ERROR
VAR
RS232 : FILE
message,prog,reception,buffer_in,port : STRING [127]
status,nb_buf,rval : INTEGER
r_flag : BOOLEAN
BEGIN
-----------------------------------------------------------------------
IF UNINIT(port) THEN
port = 'P2:'
ENDIF
CLOSE FILE RS232
reception = ''
OPEN FILE RS232 ('RW',port)
REPEAT
--BYTES_AHEAD(RS232, nb_buf,status)
--IF STATUS <> 0 THEN
--WRITE TPDISPLAY ('debut reception',cr)
READ RS232 (buffer_in::4) -- lire et charger dans buffer_in
reception = buffer_in
CNV_STR_INT(reception, rval) -- Conversion String to Real
SET_INT_REG(28,rval,status) -- Affectation dans le Registre 28 --------> !! INTP311 !!
message = SUB_STR (reception, 1,1)
CNV_STR_INT(message, rval) -- Conversion String to Real
SET_INT_REG(24,rval,status) -- Affectation dans le Registre 28
prog = SUB_STR (reception, 2,3)
CNV_STR_INT(prog, rval) -- Conversion String to Real
SET_INT_REG(25,rval,status) -- Affectation dans le Registre 28
WRITE TPDISPLAY ('Reception sur la COM : ',reception,cr)
--ENDIF
DELAY 2 -- Tempo 2 ms
---------------------------------------------------------
UNTIL (tpin[128] and tpin[135])= TRUE -- Les touches Prev & Next arrete la tache de fond
---------------------------------------------------------
CLOSE FILE RS232
END COM_IN1