V+ Language Reference Guide, v17.x


ERROR real-valued function

Syntax

ERROR (source, select)

Function

Return the error number of a recent error that caused program execution to stop or caused a REACTE reaction.

Usage Considerations

Executing a REACTE statement clears any errors for the current task and prevents the ERROR function from returning errors as expected.

A FIFO buffer is available that receives all asynchronous errors that occur from the time an enable power request is issued (using ENABLE POWER or the MCP) until power is disabled for any reason. The FIFO is accessed using the ERROR( ) real-valued function.

The asynchronous FIFO is not valid while the robot is in the power-down initialization state. User programs should wait until STATE(1) <> 0 before calling ERROR( ) with a source parameter > 1000.

Parameters

source Real value, variable, or expression (interpreted as an integer) whose value selects the source of the error code as follows:
-2Return additional error code for current robot.
 
ERROR(-2, 0)returns the standard V+ error number.
ERROR(-2, 1)returns the motor mask for the current robot. This bit mask indicates the motor(s) referenced for the error number returned by the instruction ERROR(-2,0). The LSB indicates motor 1, etcetera. If the ERROR(-2, 1)=0, the error is not associated with a specific motor.
-1Return the number of the most recent error from the program in which the ERROR function is executed.
0Return the number of the most recent error from the program executing as task #0.
0 < source ≤ 27
 Return the number of the most recent error from the program executing as the corresponding task number.
1001 < source < 1021
 

Asynchronous FIFO element n-1000, where n equals

1 Most recent item
2 Next older item, etc.
 

Returns 0 if no more FIFO elements exist. Valid select parameter values for the FIFO are 0, 1, and 3.

The asynchronous FIFO is not valid while the robot is in power-down initialization state. User programs should wait until STATE(1) returns a nonzero value before using ERROR() with source > 1000.

select Optional real value, variable, or expression (interpreted as an integer) that selects the error information to be returned. (The value 0 is assumed if this parameter is omitted.)
 
0 Return the error number of the most recent program execution error (excluding I/O errors-see IOSTAT) for the specified program task.
1 If the most recent error (for the specified program task) had an error code in the range -1100 to -1199, return the variable part of the corresponding error message as a numeric value. If the most recent error had an error code in the range -1000 to -1099, return the variable portion of the corresponding error message as a bit mask indicating the joints or motors to which the error applies. Zero is returned if the error did not have a variable portion in its message. (Also see select = 3 below.)
2

Return the error number of the most recent error from an MCS instruction executed by the specified program task.

3 Return the number of the robot associated with the most recent error for the specified program task. Zero is returned if the error was not associated with a specific robot. (Also see select = 1.)
4

Return the error code corresponding to any pending RSC errors for the robot selected by the specified user task.

RSC errors may not be valid until 0.1 seconds after a REACTE routine receives an *E-STOP from robot* (-640) error. The REACTE routine can take any time-critical action, wait 0.1 seconds, and then use ERROR(task,4) to get a more definitive error number. If no RSC errors are pending, this function returns zero.

   

Details

A V+ task can access any errors that result in robot power being disabled. These errors include the asynchronous messages that previously were output only to the monitor window.

This function is especially useful in a REACTE subroutine program to determine why the REACTE was triggered.

NOTE: The ERROR function does not report errors reported by the IOSTAT function.

See System Messagesfor a list of all the V+ error messages and their error numbers.

As noted above, when the select parameter is 1, the value returned by this function should be interpreted as a 6-bit numeric value. The following program illustrates how the value should be interpreted.

Example Program: Return error message corresponding to an error code

.PROGRAM error.string(code, vcode, robot, $msg)
; ABSTRACT: Return error message corresponding to error code(s).
;
; INPUTS:        code      Basic error code e.g., from
;                          [e.g., from ERROR(n) or IOSTAT(lun)]
;                vcode     Variable part of the error code
;                          [e.g., from ERROR(n,1)]. 
;                robot     Number of the robot associated with the error
;                          [i.e., from ERROR(n,3)].
;
; OUTPUTS:       $msg      Corresponding error message may be null
;
        AUTO i, n
        $msg = ""                               ;Assume no error
        IF code < 0 THEN                        ;If there was an error...
            $msg = $ERROR(code)                 ;Get base message string
        ; Add bit numbers if applicable.
            IF (-1100 < code) AND (code <= -1000) THEN 
                n = 1                           ;Initialize bit mask
                FOR i = 1 TO 7                  ;For each of 7 bits
                    IF vcode BAND n THEN        ;If this bit is set,
                        $msg = $msg+$ENCODE(i)  ;add it to message
                    END
                    n = 2*n                     ;Shift the mask 1 bit
                END
           END
        ; Add numeric variable if applicable.
            IF (-1200 < code) AND (code <= -1100) THEN 
                $msg = $msg+$ENCODE(vcode) ;Add number
            END
        ; Add robot number if applicable.
            IF robot AND (SELECT(ROBOT,-1) > 1) THEN 
                $msg = $msg+" (Robot"+$ENCODE(robot)+")" 
            END
        END
        
        RETURN
.END

Revision History

V+ ReleaseModification
version 16.0Enhanced ERROR function to return additional errors for the current robot when source = -2. For details, see the sourceparameter.

Related Keywords

$ERROR string function

IOSTAT real-valued function

REACTE program instruction


Submit comments to: techpubs@adept.com
Last modified on: 3/27/2012
Copyright © 1994 - 2012. Adept Technology, Inc.