| 1 |
_scpi_error_codes_and_messages = { |
| 2 |
|
| 3 |
-100: ("COMMAND_ERR", "A generic command error occurred"), |
| 4 |
-101: ("INVALID_CHARACTER", "Command contains an invalid character"), |
| 5 |
-102: ("SYNTAX_ERR", "An unrecognized command was encountered"), |
| 6 |
-103: ("INVALID_SEPERATOR", "A separator was expected but not passed"), |
| 7 |
-104: ("DATA_TYPE_ERR", "An invalid data type was passed"), |
| 8 |
-105: ("GET_NOT_ALLOWED", "This command does not accept queries"), |
| 9 |
-108: ("PARAM_NOT_ALLOWED", "Too many parameters were passed"), |
| 10 |
-109: ("MISSING_PARAM", "One or more parameters are missing"), |
| 11 |
-110: ("COMMAND_HEADER_ERR", "A generic error was detected in the header"), |
| 12 |
-111: ("HEADER_SEPERATOR_ERR", "An invalid separator was encountered in the header"), |
| 13 |
-112: ("PRGM_MNEMONIC_TOO_LONG", "The header contains more too many characters (> 12)"), |
| 14 |
-113: ("UNDEFINED_HEADER", "The command is unrecognized"), |
| 15 |
-114: ("HEADER_SUFFIX_OUT_OF_RANGE", "The parameter passed is out of range for this header"), |
| 16 |
-115: ("UNEXPECTED_NUMBER_OF_PARAMS", "The number of parameters received does not correspond to the number expected"), |
| 17 |
-120: ('NUMERIC_DATA_ERROR', 'A generic numeric data error occurred'), |
| 18 |
-121: ('INVALID_CHAR_IN_NUMBER', 'An invalid character was encountered for the numeric data type'), |
| 19 |
-123: ('EXPONENT_TOO_LARGE', 'The magnitude of the exponent was larger than 32,000'), |
| 20 |
-124: ('DECIMAL_TOO_LONG', 'Decimal data contained too many digits'), |
| 21 |
-128: ('NUMERIC_NOT_ALLOWED', 'Numeric data is not accepted in this context'), |
| 22 |
-130: ('SUFFIX_ERROR', 'A generic error occurred parsing the command suffix'), |
| 23 |
-131: ('BAD_SUFFIX', 'There is a syntax error in the suffix or it is inappropriate for this device'), |
| 24 |
-134: ('SUFFIX_TOO_LONG', 'The suffix contains too many characters (> 12)'), |
| 25 |
-138: ('SUFFIX_NOT_ALLOWED', 'A suffix is not allowed in this context'), |
| 26 |
-140: ('CHAR_DATA_ERROR', 'A generic character error occurred'), |
| 27 |
-141: ('INVALID_CHAR_DATA', 'An invalid character was encountered'), |
| 28 |
-144: ('CHAR_DATA_TOO_LONG', 'The character data contains too many characters (> 12)'), |
| 29 |
-148: ('CHAR_NOT_ALLOWED', 'A character is not allowed in this context'), |
| 30 |
-150: ('STRING_DATA', 'A generic string error occurred'), |
| 31 |
-151: ('STRING_INVALID', 'The string is invalid'), |
| 32 |
-158: ('STRING_NOT_ALLOWED', 'A string is not allower in this context'), |
| 33 |
-160: ('BLOCK_DATA', 'A generic block data occurred'), |
| 34 |
-161: ('BAD_BLOCK', 'An invalid data block was encountered'), |
| 35 |
-168: ('BLOCK_NOT_ALLOWED', 'Block data is not allowed in this context'), |
| 36 |
-170: ('EXPR_ERROR', 'A generic expression error occurred'), |
| 37 |
-171: ('INVALID_EXPRESSION', 'The expression data element was invalid'), |
| 38 |
-178: ('EXPR_NOT_ALLOWED', 'An expression is not allowed in this context'), |
| 39 |
-180: ('MACRO_ERROR', 'A generic macro error occurred'), |
| 40 |
-181: ('VALID_ONLY_INSIDE_MACRO', 'A macro placeholder was encountered outside of a macro definition'), |
| 41 |
-183: ('INVALID_WITHIN_MACRO', 'There is a syntax error in the macro'), |
| 42 |
-184: ('MACRO_PARM', 'A command in the macro had the wrong number or type of parameters'), |
| 43 |
|
| 44 |
-200: ('EXEC_ERROR', 'A generic execution error occurred.'), |
| 45 |
-201: ('INVALID_WHILE_IN_LOCAL', 'The command is not executable when the device is in local'), |
| 46 |
-202: ('SETTINGS_LOST', 'A setting was lost due to RTL'), |
| 47 |
-203: ('COMMAND_PROTECTED', 'The command is password protected or disabled'), |
| 48 |
-210: ('TRIGGER_ERROR', 'A generic trigger error occurred'), |
| 49 |
-211: ('TRIGGER_IGNORED', 'The device ignored the command'), |
| 50 |
-212: ('ARM_IGNORED', 'The device ignored the arming signal'), |
| 51 |
-213: ('INIT_IGNORED', 'The device ignored the init command because another measurement was in progress'), |
| 52 |
-214: ('TRIGGER_DEADLOCK', 'The trigger is in a deadlocked state'), |
| 53 |
-215: ('ARM_DEADLOCK', 'The arming source is in a deadlocked state'), |
| 54 |
-220: ('PARAM_ERROR', 'A generic parameter error occurred'), |
| 55 |
-221: ('SETTINGS_CONFLICT', 'The command could not be executed because of a settings conflict'), |
| 56 |
-222: ('DATA_OUT_OF_RANGE', 'The interpreted value is outside the legal range'), |
| 57 |
-223: ('TOO_MUCH_DATA', 'The device could not handle all of the data'), |
| 58 |
-224: ('ILLEGAL_PARAM_VALUE', 'An invalid parameter was passed'), |
| 59 |
-225: ('OUT_OF_MEMORY', 'The device has insufficient memory to perform the command'), |
| 60 |
-226: ('LIST_LENGTH', 'Lists not of equal lengths'), |
| 61 |
-230: ('DATA_CORRUPT_OR_STALE', 'Data is invalid'), |
| 62 |
-231: ('DATA_QUESTIONABLE', 'The measurement accuracy is suspect'), |
| 63 |
-232: ('INVALID_FORMAT', 'The data is of an invalid format'), |
| 64 |
-233: ('INVALID_VERSION', 'The data is of an invalid version'), |
| 65 |
-240: ('HARDWARE_ERROR', 'A generic hardware error occurred'), |
| 66 |
-241: ('HARDWARE_MISSING', 'The command could not be executed because of missing device hardware'), |
| 67 |
-250: ('MASS_STORAGE_ERROR', 'A generic mass storage error occurred'), |
| 68 |
-251: ('MISSING_MASS_STORAGE', 'There is no mass storage to execute this command'), |
| 69 |
-252: ('MISSING_MEDIA', 'Media required to run this command is not present'), |
| 70 |
-253: ('CORRUPT_MEDIA', 'Media required to run this command is corrupt'), |
| 71 |
-254: ('MEDIA_FULL', 'Media required to run this command is full'), |
| 72 |
-255: ('DIRECTORY_FULL', 'The specified directory is full'), |
| 73 |
-256: ('FILE_NOT_FOUND', 'The file was not found'), |
| 74 |
-257: ('FILE_NAME_ERROR', 'Encountered an error in the filename'), |
| 75 |
-258: ('MEDIA_PROTECTED', 'The command could not be executed because the media is protected'), |
| 76 |
-260: ('EXPRESSION_ERROR', 'An error occurred with an expression program data element'), |
| 77 |
-261: ('MATH_ERROR', 'A mathematical error occrred'), |
| 78 |
-270: ('MACRO_EXECUTION', 'An error occurred when executing a macro'), |
| 79 |
-271: ('MACRO_SYNTAX', 'There was a syntax error in the macro'), |
| 80 |
-272: ('MACRO_EXEC', 'There was an error in the macro definition'), |
| 81 |
-273: ('BAD_MACRO_NAME', 'The macro has an invalid name'), |
| 82 |
-274: ('MACRO_PARAM_ERROR', 'The macro definition improperly used a macro parameter placeholder'), |
| 83 |
-275: ('MACRO_TOO_LONG', 'The macro was too long to for the device to handle'), |
| 84 |
-276: ('MACRO_RECURSION', 'The macro was infinitely recursive'), |
| 85 |
-277: ('CANT_REDEFINE_MACRO', 'The macro label is already defined'), |
| 86 |
-278: ('MACRO_NOT_FOUND', 'The specified macro is not defined'), |
| 87 |
-280: ('PROGRAM_ERROR', 'A generic program error occurred'), |
| 88 |
-281: ('CANT_CREATE_PROGRAM', 'An attempt to create a program was unsuccesful'), |
| 89 |
-282: ('ILLEGAL_PROGRAM_NAME', 'The program name is invalid'), |
| 90 |
-283: ('ILLEGAL_VAR_NAME', 'The variable does not exist'), |
| 91 |
-284: ('PROGRAM_RUNNING', 'The operation is illegal while the program is running'), |
| 92 |
-285: ('PROGRAM_SYNTAX', 'A syntax error was encountered in the program'), |
| 93 |
-286: ('PROGRAM_RUNTIME', 'A program runtime error occurred'), |
| 94 |
-290: ('MEMORY_USE', 'A user request has resulted in a memory error'), |
| 95 |
-291: ('OUT_OF_MEMORY', 'Out of memory'), |
| 96 |
-292: ('NAME_NOT_FOUND', 'The referenced name does not exist'), |
| 97 |
-293: ('NAME_ALREADY_EXISTS', 'The referenced name already exists'), |
| 98 |
-294: ('INCOMPATIBLE_TYPE', 'The type or structure of the memory item is inadequate'), |
| 99 |
|
| 100 |
-300: ('DEVICE_SPECIFIC_ERROR', 'A generic device error occurred'), |
| 101 |
-310: ('SYSTEM_ERROR', 'A system error occurred'), |
| 102 |
-311: ('MEMORY_ERROR', 'A physical fault in the device`s memory occurred'), |
| 103 |
-312: ('PUD_MEMORY_LOST', 'Protected user data saved by a *PUD command was lost'), |
| 104 |
-313: ('CAL_MEMORY_LOST', 'Calibration data saved by a *CAL? command was lost'), |
| 105 |
-314: ('SAV_RCL_MEMORY_LOST', 'Data saved by the *SAV? command has been lost'), |
| 106 |
-315: ('CONFIG_MEMORY_LOST', 'Configuration data has been lost'), |
| 107 |
-320: ('STORAGE_FAULT', 'The firmware detected a fault when using data storage'), |
| 108 |
-321: ('OUT_OF_MEMORY', 'An internal operation needed more memory than was available'), |
| 109 |
-330: ('SELF_TEST_FAILED', 'The instrument self test failed'), |
| 110 |
-340: ('CAL_FAILED', 'The device experienced a calibration error'), |
| 111 |
-350: ('QUEUE_OVERFLOW', 'An error occurred, but there were too many errors in the error queue to record it'), |
| 112 |
-360: ('COMMUNICATION_ERROR', 'A generic communication error occurred'), |
| 113 |
-361: ('PARITY_ERROR', 'The received data had an invalid parity bit'), |
| 114 |
-362: ('FRAMING_ERROR', 'A stop bit was not detected'), |
| 115 |
-363: ('INPUT_BUFFER_OVERRUN', 'The serial port input buffers overflowed'), |
| 116 |
-365: ('TIMEOUT_ERROR', 'A timeout error occurred'), |
| 117 |
|
| 118 |
-400: ('QUERY_ERROR', 'A generic query error occurred'), |
| 119 |
-410: ('QUERY_INTERRUPTED', 'An interrupted query occurred'), |
| 120 |
-420: ('QUERY_UNTERMINATED', 'The query was unterminated'), |
| 121 |
-430: ('QUERY_DEADLOCKED', 'The query encountered a deadlock error'), |
| 122 |
-440: ('RESPONSE_NOT_ALLOWED', 'A query was received after an indefinite query was executed'), |
| 123 |
|
| 124 |
-500: ('POWER_ON', 'The device detected an off to on transition in its power supply'), |
| 125 |
-600: ('USER_REQUEST', 'The device detected the activation of a user request local control'), |
| 126 |
-700: ('REQUEST_CONTROL', 'The device requested to be the active IEEE 488.1 controller-in-charge'), |
| 127 |
-800: ('OPERATION_COMPLETE', 'The instrument has completed all pending operations'), |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
class SCPIError(Exception): |
| 132 |
def __init__(self, errno: int) -> None: |
| 133 |
abbreviation, description = _scpi_error_codes_and_messages.get( |
| 134 |
errno, ("UNKNOWN_ERR", "An unknown error occurred.") |
| 135 |
) |
| 136 |
|
| 137 |
super().__init__( |
| 138 |
f"{abbreviation} ({errno}): {description}" |
| 139 |
) |
| 140 |
self.error_code = errno |
| 141 |
self.abbreviation = abbreviation |
| 142 |
self.description = description |