Basically the calling subprogram will not call the function correctly. I will paste part of the calling program, and the file which has the subroutines (small)
This program is the calling and as you see the important call has been commented out, because as soon as I remove the semicolon the program breaks
&ACCESS RVO1
&REL 900
&PARAM EDITMASK = *
DEF photo_stop(seatNum:IN, Action:IN, numCycles:IN, totalCycles, autoPic)
DECL AFTERPHOTOTYPE Action
INT seatNum, numCycles, totalCycles
BOOL autoPic
CHAR sndString[128]
BOOL bret
;FOLD INI;%{PE}%V3.2.0,%MKUKATPBASIS,%CINIT,%VCOMMON,%P
;FOLD OCCUBOT INI
;decl runtime parameter
DECL INT BN,TN,NOC,TID,POUT,PIN,OCC_INFO
DECL REAL WTIME
DECL BOOL NEW,OS,FRICT
GLOBAL INTERRUPT DECL 5 WHEN PLC_STOP_TEST_KRC==TRUE DO APP_FAULT ( )
;ENDFOLD (INI OCCUBOT)
;FOLD BAS INI;%{E}%V3.2.0,%MKUKATPBASIS,%CINIT,%VINIT,%P
GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS==TRUE DO IR_STOPM ( )
INTERRUPT ON 3
BAS (#INITMOV,0 )
;ENDFOLD (BAS INI)
;FOLD OCCUBOT INIT
SENSORINIT_ERR=FALSE
WAIT_TIME=0
IF (VARSTATE ("POUT")==#INITIALIZED) THEN
IF POUT<>0 THEN
SET_OUT=POUT
IF $OUT[SET_OUT] THEN
$OUT[SET_OUT]=FALSE
SET_OUT=1026
ENDIF
ENDIF
ELSE
POUT=0
PIN=0
WTIME=0
ENDIF
READ_IN=1026
;ENDFOLD
;FOLD USER INI;%{E}%V3.2.0,%MKUKATPUSER,%CINIT,%VINIT,%P
;MAKE YOUR MODIFICATIONS HERE
;ENDFOLD (USER INI)
;ENDFOLD (INI)
cmdString[]="Seat%d_PhotoReady_%s_%d_%d"
;;;; send command to camera
ChannelOpen()
bRet = strclear(sndString[])
offset = 0
IF Action==#STOP_ THEN
HALT
SWRITE(sndString[], state, offset, cmdString[], seatNum, "Stop",numCycles,totalCycles)
ELSE
SWRITE(sndString[], state, offset, cmdString[], seatNum, "Cont",numCycles,totalCycles)
ENDIF
;HALT
ChannelWrite(sndString[])
bRet = strclear(rcvString[])
; IF (NOT ChannelRead(rcvString[])) THEN
; HALT
; ENDIF
---------------------------------------------------------------------------
ChannelOpen() , ChannelWrite(sndString[]) works but not ChannelRead(rcvString[])
and below is the the file with the subprograms and the function that doesn't work
DEF serialCommMgr( )
END
GLOBAL DEF ChannelOpen()
COPEN(:SER_3,HANDLE_)
IF (HANDLE_==0) THEN
HALT
ENDIF
END
GLOBAL DEF ChannelWrite(Str[]:IN)
CHAR Str[]
MW_T=#SYNC
MR_T=#ABS
CWRITE(HANDLE_, SW_T, MW_T, "%S", Str[] )
HALT
IF (SW_T.RET1<>#CMD_OK) THEN
HALT
ENDIF
END
GLOBAL DEFFCT BOOL ChannelRead(Str[]:OUT)
CHAR Str[]
INT numTries, i, temp
IF readSerialTimeout*60 < TIMEOUT_ THEN
numTries = 1
ELSE
numTries = readSerialTimeout*60/TIMEOUT_
ENDIF
FOR i=1 TO numTries
HALT
OFFSET_=0
MW_T=#SYNC
MR_T=#ABS
CREAD(HANDLE_, SR_T, MR_T, TIMEOUT_, OFFSET_, "%S", Str[])
SWITCH SR_T.RET1
CASE #CMD_ABORT
RETURN FALSE
CASE #CMD_OK
RETURN TRUE
CASE #CMD_TIMEOUT
IF i>= numTries THEN
RETURN FALSE
ENDIF
CASE #DATA_OK
RETURN TRUE
CASE #DATA_BLK
RETURN TRUE
CASE #DATA_END
RETURN TRUE
CASE #FMT_ERR
RETURN FALSE
ENDSWITCH
ENDFOR
ENDFCT
GLOBAL DEF ChannelClose()
CCLOSE (HANDLE_, SC_T)
IF(SC_T.RET1<>#CMD_OK) THEN
HALT
ENDIF
END
I get the following errors: instruction inadmissible
Active commands inhibited
Just to reiterate this is the call that does not work
IF (NOT ChannelRead(rcvString[])) THEN
HALT
ENDIF