V+ Language Reference Guide, v
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
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 ENDRETURN .ENDRevision History
V+ Release Modification version 16.0 Enhanced 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.
