00001 /************************************************************************* 00002 ***** PTU BINARY OPCODES INCLUDE FILE ***** 00003 ***** ***** 00004 ***** (C)1997, Directed Perception, Inc. ***** 00005 ***** All Rights Reserved. ***** 00006 ***** ***** 00007 ***** Licensed users may freely distribute compiled code including ***** 00008 ***** this code and data. Source data and code may NOT be ***** 00009 ***** distributed without the prior written consent from ***** 00010 ***** Directed Perception, Inc. ***** 00011 ***** Directed Perception, Inc. reserves the right to make ***** 00012 ***** changes without further notice to any content herein to ***** 00013 ***** improve reliability, function or design. Directed Perception ***** 00014 ***** shall not assume any liability arising from the application ***** 00015 ***** or use of this code, data or function. ***** 00016 ***** ***** 00017 ************************************************************************** 00018 00019 CHANGE HISTORY: 00020 8/10/98: v1.08.09. In firmware_version_OK, removed addressing to string constant. 00021 7/15/97: v1.08.00. Compiles with MSVC v1.52. Unified with Win16/32 00022 PTU interface calls. 00023 6/20/97: #define of ALL misdefined. Fixed to equal PAN+TILT 00024 11/2/95: v1.07.07d. Firmware version check bug fixed. 00025 7/11/95: v1.07.06d. Updated opcode structure and added new support. 00026 2/19/95: v1.07.04d. Generalized for Windows, DOS, & UNIX. 00027 Added networking. 00028 10/12/94: v1.07.03d. Pre-release working version. 00029 XON/XOFF removed from PTU firmware to allow for binary mode. 00030 00031 00032 **************************************************************************/ 00033 00034 00035 /*** Conditionally include the required serial interface declarations. ***/ 00036 /*** If your compiler doesn't have the macro symbol defined, you can ***/ 00037 /*** manually select the right include file yourself. ***/ 00038 #if defined(_WIN32) 00039 #include "W32Socket.H" 00040 00041 #elif defined(_WIN16) 00042 #include "..\include\W16SERIA.H" 00043 #elif defined(_DOS) 00044 #include "..\include\DOSSERIA.H" 00045 #elif defined(_UNIX) 00046 #include "linuxser.h" 00047 #endif 00048 00049 #ifdef _UNIX 00050 #include "../include/opcodes.h" 00051 #else 00052 #include "opcodes.h" 00053 #endif 00054 00055 /* return status codes */ 00056 #define PTU_OK 0 00057 #define PTU_ILLEGAL_COMMAND_ARGUMENT 1 00058 #define PTU_ILLEGAL_COMMAND 2 00059 #define PTU_ILLEGAL_POSITION_ARGUMENT 3 00060 #define PTU_ILLEGAL_SPEED_ARGUMENT 4 00061 #define PTU_ACCEL_TABLE_EXCEEDED 5 00062 #define PTU_DEFAULTS_EEPROM_FAULT 6 00063 #define PTU_SAVED_DEFAULTS_CORRUPTED 7 00064 #define PTU_LIMIT_HIT 8 00065 #define PTU_CABLE_DISCONNECTED 9 00066 #define PTU_ILLEGAL_UNIT_ID 10 00067 #define PTU_ILLEGAL_POWER_MODE 11 00068 #define PTU_RESET_FAILED 12 00069 #define PTU_NOT_RESPONDING 13 00070 #define PTU_FIRMWARE_VERSION_TOO_LOW 14 00071 00072 /******************************************************************** 00073 ***** ***** 00074 ***** For all of these commands, a non-zero return status ***** 00075 ***** indicates an error, and it returns that error code. ***** 00076 ***** ***** 00077 ********************************************************************/ 00078 00079 /* open_host_port(<portname>) ==> <portstream> */ 00080 extern portstream_fd open_host_port(char *); 00081 00082 /* close_host_port(<portstream>) ==> <status> */ 00083 extern char close_host_port(portstream_fd); 00084 00085 00086 00087 typedef short int PTU_PARM_PTR; 00088 00089 /* reset_PTU_parser(<timeout_in_msec>) ==> [PTU_OK|PTU_NOT_RESPONDING] */ 00090 extern char reset_PTU_parser(long); 00091 00092 /* set_desired([PAN|TILT], 00093 [POSITION|SPEED|ACCELERATION|BASE|UPPER|LOWER], 00094 [<position>|<speed>|<acceleration>], 00095 [RELATIVE|ABSOLUTE]) ==> <status> 00096 set_desired([PAN|TILT], 00097 HOLD_POWER_LEVEL, 00098 <power mode>, 00099 NULL) ==> <status> 00100 set_desired([PAN|TILT], 00101 [HOLD_POWER_LEVEL,MOVE_POWER_LEVEL], 00102 [PTU_REG_POWER|PTU_LOW_POWER|PTU_OFF_POWER], 00103 NULL) ==> <status> */ 00104 char set_desired(char, char, PTU_PARM_PTR *, char); 00105 00106 00107 /* get_current([PAN|TILT], 00108 [POSITION|SPEED|ACCELERATION|BASE|UPPER|LOWER| 00109 HOLD_POWER_LEVEL|MOVE_POWER_LEVEL|RESOLUTION]) ==> <value> */ 00110 extern long get_current(char, char); 00111 00112 00113 /* get_desired([PAN|TILT], 00114 [POSITION|SPEED|ACCELERATION|BASE|UPPER|LOWER| 00115 HOLD_POWER_LEVEL|MOVE_POWER_LEVEL|RESOLUTION]) ==> <value> */ 00116 extern long get_desired(char, char); 00117 00118 00119 /* set_mode(COMMAND_EXECUTION_MODE, 00120 [EXECUTE_IMMEDIATELY|EXECUTE_UPON_IMMEDIATE_OR_AWAIT]) ==> <status> 00121 set_mode(ASCII_VERBOSE_MODE, [VERBOSE|TERSE|QUERY_MODE]) ==> <status> 00122 set_mode(ASCII_ECHO_MODE, [ON_MODE|OFF_MODE|QUERY_MODE]) ==> <status> 00123 set_mode(POSITION_LIMITS_MODE, [ON_MODE|OFF_MODE|QUERY_MODE]) ==> <status> 00124 set_mode(DEFAULTS,[SAVE_CURRENT_SETTINGS|RESTORE_SAVED_SETTINGS| 00125 RESTORE_FACTORY_SETTINGS]) ==> <status> */ 00126 extern char set_mode(char,char); 00127 00128 00129 /* halt([ALL|PAN|TILT]) ==> <status> */ 00130 extern char halt(char); 00131 00132 00133 /* await_completion() ==> <status> */ 00134 extern char await_completion(void); 00135 00136 00137 /* reset_PTU() ==> <status> */ 00138 extern char reset_ptu(void); 00139 00140 00141 /* firmware_version() ==> <version ID string> */ 00142 extern char* firmware_version(void); 00143 00144 00145 /*** multiple unit support ***/ 00146 typedef unsigned short int UID_fd; 00147 00148 /* in general, should not be used or required... */ 00149 extern char select_host_port(portstream_fd); 00150 00151 /* select_unit(<portstream>, <unit ID>) ==> <status> */ 00152 extern char select_unit(UID_fd); 00153 00154 extern char set_unit_id(UID_fd); // This call should be made only 00155 // when one unit is on the current 00156 // host serial port 00157 00158 00159 /********************* function call constants ***********************/ 00160 00161 #define PAN 1 00162 #define TILT 2 00163 00164 #define POSITION 1 00165 #define SPEED 2 00166 #define ACCELERATION 3 00167 #define BASE 4 00168 #define UPPER_SPEED_LIMIT 5 00169 #define LOWER_SPEED_LIMIT 6 00170 #define MINIMUM_POSITION 7 00171 #define MAXIMUM_POSITION 8 00172 #define HOLD_POWER_LEVEL 9 00173 #define MOVE_POWER_LEVEL 10 00174 #define RESOLUTION 11 00175 00176 /* specifies changes relative to current position */ 00177 /* (Had to add conditional compilation since WIN32 already defines these values */ 00178 #ifndef RELATIVE 00179 #define RELATIVE 1 00180 #endif 00181 #ifndef ABSOLUTE 00182 #define ABSOLUTE 2 00183 #endif 00184 00185 00186 #define QUERY NULL 00187 00188 /* power modes */ 00189 #define PTU_HI_POWER 1 00190 #define PTU_REG_POWER 2 00191 #define PTU_LOW_POWER 3 00192 #define PTU_OFF_POWER 4 00193 00194 /* PTU mode types */ 00195 #define COMMAND_EXECUTION_MODE 1 00196 #define ASCII_VERBOSE_MODE 2 00197 #define ASCII_ECHO_MODE 3 00198 #define POSITION_LIMITS_MODE 4 00199 #define DEFAULTS 5 00200 #define SPEED_CONTROL_MODE 6 /* v1.9.7 and higher */ 00201 00202 #define EXECUTE_IMMEDIATELY 1 /* default */ 00203 #define EXECUTE_UPON_IMMEDIATE_OR_AWAIT 2 00204 00205 #define VERBOSE 1 00206 #define TERSE 0 /* default */ 00207 00208 #define ON_MODE 1 /* default */ 00209 #define OFF_MODE 0 00210 00211 #define SAVE_CURRENT_SETTINGS 0 00212 #define RESTORE_SAVED_SETTINGS 1 00213 #define RESTORE_FACTORY_SETTINGS 2 00214 00215 #define QUERY_MODE 3 00216 00217 #define ALL 3 00218