Instruction Inadmissible, active command inhibitted, Cread

  • 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

  • First: Put that code into actual code boxes, please.


    Second: What line is causing the issue? I don't have time to search through 100+ lines of code trying to guess at the one you are referring to.


    Third: "breaks the program". Breaks it HOW? Is there a compilation error? Or is this a runtime execution error?


    Fourth: Details of the error message. COMPLETE details, including the Line and Column number reported for where the error is reported, and the EXACT FULL TEXT of the error message.

  • The problem is on the last 3 lines of this section of code in the first box below. They are commented out because the program will not compile otherwise (what i mean by break). It gets the red mark meaning there's an error.


    The second box is the whole file with the subroutines. All the subprograms work, but not the function called "ChannelRead"


    Sorry for the improper post. Any further clarification needed and I methods to make this clearer and I'll gladly include.

    In separate file I have these subprograms and function. The function "Channelread" is what doesn't seem to work.


    and in the attachment I did a test where I called the function from the subroutine and I got the "instruction inadmissible" and "Active command inhibited" error.

  • So, if you Open (not Select!) the main routine, and un-comment lines 11-13, and save the changes, you have an immediate compilation error? Before you try to execute the main routine? What is the text of the compilation error?


    Normally, this only occurs if there is a syntax error in the called function. Does SerialCommMgr show any compilation errors?

  • Your help was the key in getting this solved. What happened was that I was only making the changes when I stopped with a halt command. Doing this doesn't compile correctly. When you asked me about that I actually did things differently. I did not run the program. I opened the subroutine, made the changes on it, saved it, closed it, and ran it.

    It worked. If you hadn't asked the right question I might still be struggling with it.

Advertising from our partners