| 1 | /*
 | 
|---|
| 2 |     LX200 Driver
 | 
|---|
| 3 |     Copyright (C) 2003 Jasem Mutlaq (mutlaqja@ikarustech.com)
 | 
|---|
| 4 | 
 | 
|---|
| 5 |     This library is free software; you can redistribute it and/or
 | 
|---|
| 6 |     modify it under the terms of the GNU Lesser General Public
 | 
|---|
| 7 |     License as published by the Free Software Foundation; either
 | 
|---|
| 8 |     version 2.1 of the License, or (at your option) any later version.
 | 
|---|
| 9 | 
 | 
|---|
| 10 |     This library is distributed in the hope that it will be useful,
 | 
|---|
| 11 |     but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 12 |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
|---|
| 13 |     Lesser General Public License for more details.
 | 
|---|
| 14 | 
 | 
|---|
| 15 |     You should have received a copy of the GNU Lesser General Public
 | 
|---|
| 16 |     License along with this library; if not, write to the Free Software
 | 
|---|
| 17 |     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
|---|
| 18 | 
 | 
|---|
| 19 | */
 | 
|---|
| 20 | 
 | 
|---|
| 21 | #ifndef LX200DRIVER_H
 | 
|---|
| 22 | #define LX200DRIVER_H
 | 
|---|
| 23 | 
 | 
|---|
| 24 |   /* Slew speeds */
 | 
|---|
| 25 | enum TSlew { LX200_SLEW_MAX, LX200_SLEW_FIND, LX200_SLEW_CENTER, LX200_SLEW_GUIDE};
 | 
|---|
| 26 |   /* Alignment modes */
 | 
|---|
| 27 | enum TAlign {  LX200_ALIGN_POLAR, LX200_ALIGN_ALTAZ, LX200_ALIGN_LAND };
 | 
|---|
| 28 |   /* Directions */
 | 
|---|
| 29 | enum TDirection { LX200_NORTH, LX200_WEST, LX200_EAST, LX200_SOUTH, LX200_ALL};
 | 
|---|
| 30 |   /* Formats of Right ascention and Declenation */
 | 
|---|
| 31 | enum TFormat { LX200_SHORT_FORMAT, LX200_LONG_FORMAT};
 | 
|---|
| 32 |   /* Time Format */
 | 
|---|
| 33 | enum TTimeFormat { LX200_24, LX200_AM, LX200_PM};
 | 
|---|
| 34 |   /* Focus operation */
 | 
|---|
| 35 | enum TFocusMotion { LX200_FOCUSIN, LX200_FOCUSOUT };
 | 
|---|
| 36 | enum TFocusSpeed  { LX200_HALTFOCUS = 0, LX200_FOCUSSLOW, LX200_FOCUSFAST};
 | 
|---|
| 37 |   /* Library catalogs */
 | 
|---|
| 38 | enum TCatalog { LX200_STAR_C, LX200_DEEPSKY_C};
 | 
|---|
| 39 |   /* Frequency mode */
 | 
|---|
| 40 | enum StarCatalog { LX200_STAR, LX200_SAO, LX200_GCVS };
 | 
|---|
| 41 |   /* Deep Sky Catalogs */
 | 
|---|
| 42 | enum DeepSkyCatalog { LX200_NGC, LX200_IC, LX200_UGC, LX200_CALDWELL, LX200_ARP, LX200_ABELL, LX200_MESSIER_C};
 | 
|---|
| 43 |   /* Mount tracking frequency, in Hz */
 | 
|---|
| 44 | enum TFreq { LX200_TRACK_DEFAULT, LX200_TRACK_LUNAR, LX200_TRACK_MANUAL};
 | 
|---|
| 45 | 
 | 
|---|
| 46 | #define MaxReticleDutyCycle             15
 | 
|---|
| 47 | #define MaxFocuserSpeed                 4
 | 
|---|
| 48 | 
 | 
|---|
| 49 | /* GET formatted sexagisemal value from device, return as double */
 | 
|---|
| 50 | #define getLX200RA(fd, x)                               getCommandSexa(fd, x, "#:GR#")
 | 
|---|
| 51 | #define getLX200DEC(fd, x)                              getCommandSexa(fd, x, "#:GD#")
 | 
|---|
| 52 | #define getObjectRA(fd, x)                              getCommandSexa(fd, x, "#:Gr#")
 | 
|---|
| 53 | #define getObjectDEC(fd, x)                             getCommandSexa(fd, x, "#:Gd#")
 | 
|---|
| 54 | #define getLocalTime12(fd, x)                           getCommandSexa(fd, x, "#:Ga#")
 | 
|---|
| 55 | #define getLocalTime24(fd, x)                           getCommandSexa(fd, x, "#:GL#")
 | 
|---|
| 56 | #define getSDTime(fd, x)                                getCommandSexa(fd, x, "#:GS#")
 | 
|---|
| 57 | #define getLX200Alt(fd, x)                              getCommandSexa(fd, x, "#:GA#")
 | 
|---|
| 58 | #define getLX200Az(fd, x)                               getCommandSexa(fd, x, "#:GZ#")
 | 
|---|
| 59 | 
 | 
|---|
| 60 | /* GET String from device and store in supplied buffer x */
 | 
|---|
| 61 | #define getObjectInfo(fd, x)                            getCommandString(fd, x, "#:LI#")
 | 
|---|
| 62 | #define getVersionDate(fd, x)                           getCommandString(fd, x, "#:GVD#")
 | 
|---|
| 63 | #define getVersionTime(fd, x)                           getCommandString(fd, x, "#:GVT#")
 | 
|---|
| 64 | #define getFullVersion(fd, x)                           getCommandString(fd, x, "#:GVF#")
 | 
|---|
| 65 | #define getVersionNumber(fd, x)                         getCommandString(fd, x, "#:GVN#")
 | 
|---|
| 66 | #define getProductName(fd, x)                           getCommandString(fd, x, "#:GVP#")
 | 
|---|
| 67 | #define turnGPS_StreamOn(fd)                            getCommandString(fd, x, "#:gps#")
 | 
|---|
| 68 | 
 | 
|---|
| 69 | /* GET Int from device and store in supplied pointer to integer x */
 | 
|---|
| 70 | #define getUTCOffset(fd, x)                             getCommandInt(fd, x, "#:GG#")
 | 
|---|
| 71 | #define getMaxElevationLimit(fd, x)                     getCommandInt(fd, x, "#:Go#")
 | 
|---|
| 72 | #define getMinElevationLimit(fd, x)                     getCommandInt(fd, x, "#:Gh#")
 | 
|---|
| 73 | 
 | 
|---|
| 74 | /* Generic set, x is an integer */
 | 
|---|
| 75 | #define setReticleDutyFlashCycle(fd, x)                 setCommandInt(fd, x, "#:BD")
 | 
|---|
| 76 | #define setReticleFlashRate(fd, x)                      setCommandInt(fd, x, "#:B")
 | 
|---|
| 77 | #define setFocuserSpeed(fd, x)                          setCommandInt(fd, x, "#:F")
 | 
|---|
| 78 | #define setSlewSpeed(fd, x)                             setCommandInt(fd, x, "#:Sw")
 | 
|---|
| 79 | 
 | 
|---|
| 80 | /* Set X:Y:Z */
 | 
|---|
| 81 | #define setLocalTime(fd, x,y,z)                         setCommandXYZ(fd, x,y,z, "#:SL")
 | 
|---|
| 82 | #define setSDTime(fd, x,y,z)                            setCommandXYZ(fd, x,y,z, "#:SS")
 | 
|---|
| 83 | 
 | 
|---|
| 84 | /* GPS Specefic */
 | 
|---|
| 85 | #define turnGPSOn(fd)                                   write(fd, "#:g+#", 5)
 | 
|---|
| 86 | #define turnGPSOff(fd)                                  write(fd, "#:g-#", 5)
 | 
|---|
| 87 | #define alignGPSScope(fd)                               write(fd, "#:Aa#", 5)
 | 
|---|
| 88 | #define gpsSleep(fd)                                    write(fd, "#:hN#", 5)
 | 
|---|
| 89 | #define gpsWakeUp(fd)                                   write(fd, "#:hW#", 5);
 | 
|---|
| 90 | #define gpsRestart(fd)                                  write(fd, "#:I#", 4);
 | 
|---|
| 91 | #define updateGPS_System(fd)                            setStandardProcedure(fd, "#:gT#")
 | 
|---|
| 92 | #define enableDecAltPec(fd)                             write(fd, "#:QA+#", 6)
 | 
|---|
| 93 | #define disableDecAltPec(fd)                            write(fd, "#:QA-#", 6)
 | 
|---|
| 94 | #define enableRaAzPec(fd)                               write(fd, "#:QZ+#", 6)
 | 
|---|
| 95 | #define disableRaAzPec(fd)                              write(fd, "#:QZ-#", 6)
 | 
|---|
| 96 | #define activateAltDecAntiBackSlash(fd)                 write(fd, "#$BAdd#", 7)
 | 
|---|
| 97 | #define activateAzRaAntiBackSlash(fd)                   write(fd, "#$BZdd#", 7)
 | 
|---|
| 98 | #define SelenographicSync(fd)                           write(fd, "#:CL#", 5); 
 | 
|---|
| 99 | 
 | 
|---|
| 100 | #define slewToAltAz(fd)                                 setStandardProcedure(fd, "#:MA#")
 | 
|---|
| 101 | #define toggleTimeFormat(fd)                            write(fd, "#:H#", 4)
 | 
|---|
| 102 | #define increaseReticleBrightness(fd)                   write(fd, "#:B+#", 5)
 | 
|---|
| 103 | #define decreaseReticleBrightness(fd)                   write(fd, "#:B-#", 5)
 | 
|---|
| 104 | #define turnFanOn(fd)                                   write(fd, "#:f+#", 5)
 | 
|---|
| 105 | #define turnFanOff(fd)                                  write(fd, "#:f-#", 5)
 | 
|---|
| 106 | #define seekHomeAndSave(fd)                             write(fd, "#:hS#", 5)
 | 
|---|
| 107 | #define seekHomeAndSet(fd)                              write(fd, "#:hF#", 5)
 | 
|---|
| 108 | #define turnFieldDeRotatorOn(fd)                        write(fd, "#:r+#", 5)
 | 
|---|
| 109 | #define turnFieldDeRotatorOff(fd)                       write(fd, "#:r-#", 5)
 | 
|---|
| 110 | #define slewToPark(fd)                                  write(fd, "#:hP#", 5)
 | 
|---|
| 111 | 
 | 
|---|
| 112 | #ifdef __cplusplus
 | 
|---|
| 113 | extern "C" {
 | 
|---|
| 114 | #endif
 | 
|---|
| 115 | 
 | 
|---|
| 116 | /**************************************************************************
 | 
|---|
| 117 |  Basic I/O - OBSELETE
 | 
|---|
| 118 | **************************************************************************/
 | 
|---|
| 119 | /*int openPort(const char *portID);
 | 
|---|
| 120 | int portRead(char *buf, int nbytes, int timeout);
 | 
|---|
| 121 | int portWrite(const char * buf);
 | 
|---|
| 122 | int LX200readOut(int timeout);
 | 
|---|
| 123 | int Connect(const char* device);
 | 
|---|
| 124 | void Disconnect();*/
 | 
|---|
| 125 | 
 | 
|---|
| 126 | /**************************************************************************
 | 
|---|
| 127 |  Diagnostics
 | 
|---|
| 128 |  **************************************************************************/
 | 
|---|
| 129 | char ACK(int fd);
 | 
|---|
| 130 | /*int testTelescope();
 | 
|---|
| 131 | int testAP();*/
 | 
|---|
| 132 | int check_lx200_connection(int fd);
 | 
|---|
| 133 | 
 | 
|---|
| 134 | /**************************************************************************
 | 
|---|
| 135 |  Get Commands: store data in the supplied buffer. Return 0 on success or -1 on failure 
 | 
|---|
| 136 |  **************************************************************************/
 | 
|---|
| 137 |  
 | 
|---|
| 138 | /* Get Double from Sexagisemal */
 | 
|---|
| 139 | int getCommandSexa(int fd, double *value, const char *cmd);
 | 
|---|
| 140 | /* Get String */
 | 
|---|
| 141 | int getCommandString(int fd, char *data, const char* cmd);
 | 
|---|
| 142 | /* Get Int */
 | 
|---|
| 143 | int getCommandInt(int fd, int *value, const char* cmd);
 | 
|---|
| 144 | /* Get tracking frequency */
 | 
|---|
| 145 | int getTrackFreq(int fd, double * value);
 | 
|---|
| 146 | /* Get site Latitude */
 | 
|---|
| 147 | int getSiteLatitude(int fd, int *dd, int *mm);
 | 
|---|
| 148 | /* Get site Longitude */
 | 
|---|
| 149 | int getSiteLongitude(int fd, int *ddd, int *mm);
 | 
|---|
| 150 | /* Get Calender data */
 | 
|---|
| 151 | int getCalenderDate(int fd, char *date);
 | 
|---|
| 152 | /* Get site Name */
 | 
|---|
| 153 | int getSiteName(int fd, char *siteName, int siteNum);
 | 
|---|
| 154 | /* Get Number of Bars */
 | 
|---|
| 155 | int getNumberOfBars(int fd, int *value);
 | 
|---|
| 156 | /* Get Home Search Status */
 | 
|---|
| 157 | int getHomeSearchStatus(int fd, int *status);
 | 
|---|
| 158 | /* Get OTA Temperature */
 | 
|---|
| 159 | int getOTATemp(int fd, double * value);
 | 
|---|
| 160 | /* Get time format: 12 or 24 */
 | 
|---|
| 161 | int getTimeFormat(int fd, int *format);
 | 
|---|
| 162 | /* Get RA, DEC from Sky Commander controller */
 | 
|---|
| 163 | int updateSkyCommanderCoord(int fd, double *ra, double *dec);
 | 
|---|
| 164 | /* Get RA, DEC from Intelliscope/SkyWizard controllers */
 | 
|---|
| 165 | int updateIntelliscopeCoord (int fd, double *ra, double *dec);
 | 
|---|
| 166 | 
 | 
|---|
| 167 | /**************************************************************************
 | 
|---|
| 168 |  Set Commands
 | 
|---|
| 169 |  **************************************************************************/
 | 
|---|
| 170 | 
 | 
|---|
| 171 | /* Set Int */
 | 
|---|
| 172 | int setCommandInt(int fd, int data, const char *cmd);
 | 
|---|
| 173 | /* Set Sexigesimal */
 | 
|---|
| 174 | int setCommandXYZ(int fd, int x, int y, int z, const char *cmd);
 | 
|---|
| 175 | /* Common routine for Set commands */
 | 
|---|
| 176 | int setStandardProcedure(int fd, char * writeData);
 | 
|---|
| 177 | /* Set Slew Mode */
 | 
|---|
| 178 | int setSlewMode(int fd, int slewMode);
 | 
|---|
| 179 | /* Set Alignment mode */
 | 
|---|
| 180 | int setAlignmentMode(int fd, unsigned int alignMode);
 | 
|---|
| 181 | /* Set Object RA */
 | 
|---|
| 182 | int setObjectRA(int fd, double ra);
 | 
|---|
| 183 | /* set Object DEC */
 | 
|---|
| 184 | int setObjectDEC(int fd, double dec);
 | 
|---|
| 185 | /* Set Calender date */
 | 
|---|
| 186 | int setCalenderDate(int fd, int dd, int mm, int yy);
 | 
|---|
| 187 | /* Set UTC offset */
 | 
|---|
| 188 | int setUTCOffset(int fd, double hours);
 | 
|---|
| 189 | /* Set Track Freq */
 | 
|---|
| 190 | int setTrackFreq(int fd, double trackF);
 | 
|---|
| 191 | /* Set current site longitude */
 | 
|---|
| 192 | int setSiteLongitude(int fd, double Long);
 | 
|---|
| 193 | /* Set current site latitude */
 | 
|---|
| 194 | int setSiteLatitude(int fd, double Lat);
 | 
|---|
| 195 | /* Set Object Azimuth */
 | 
|---|
| 196 | int setObjAz(int fd, double az);
 | 
|---|
| 197 | /* Set Object Altitude */
 | 
|---|
| 198 | int setObjAlt(int fd, double alt);
 | 
|---|
| 199 | /* Set site name */
 | 
|---|
| 200 | int setSiteName(int fd, char * siteName, int siteNum);
 | 
|---|
| 201 | /* Set maximum slew rate */
 | 
|---|
| 202 | int setMaxSlewRate(int fd, int slewRate);
 | 
|---|
| 203 | /* Set focuser motion */
 | 
|---|
| 204 | int setFocuserMotion(int fd, int motionType);
 | 
|---|
| 205 | /* SET GPS Focuser raneg (1 to 4) */
 | 
|---|
| 206 | int setGPSFocuserSpeed (int fd, int speed);
 | 
|---|
| 207 | /* Set focuser speed mode */
 | 
|---|
| 208 | int setFocuserSpeedMode (int fd, int speedMode);
 | 
|---|
| 209 | /* Set minimum elevation limit */
 | 
|---|
| 210 | int setMinElevationLimit(int fd, int min);
 | 
|---|
| 211 | /* Set maximum elevation limit */
 | 
|---|
| 212 | int setMaxElevationLimit(int fd, int max);
 | 
|---|
| 213 | 
 | 
|---|
| 214 | /**************************************************************************
 | 
|---|
| 215 |  Motion Commands
 | 
|---|
| 216 |  **************************************************************************/
 | 
|---|
| 217 | /* Slew to the selected coordinates */
 | 
|---|
| 218 | int Slew(int fd);
 | 
|---|
| 219 | /* Synchronize to the selected coordinates and return the matching object if any */
 | 
|---|
| 220 | int Sync(int fd, char *matchedObject);
 | 
|---|
| 221 | /* Abort slew in all axes */
 | 
|---|
| 222 | int abortSlew(int fd);
 | 
|---|
| 223 | /* Move into one direction, two valid directions can be stacked */
 | 
|---|
| 224 | int MoveTo(int fd, int direction);
 | 
|---|
| 225 | /* Halt movement in a particular direction */
 | 
|---|
| 226 | int HaltMovement(int fd, int direction);
 | 
|---|
| 227 | /* Select the tracking mode */
 | 
|---|
| 228 | int selectTrackingMode(int fd, int trackMode);
 | 
|---|
| 229 | /* Select Astro-Physics tracking mode */
 | 
|---|
| 230 | int selectAPTrackingMode(int fd, int trackMode);
 | 
|---|
| 231 | /* Send Pulse-Guide command (timed guide move), two valid directions can be stacked */
 | 
|---|
| 232 | int SendPulseCmd(int fd, int direction, int duration_msec);
 | 
|---|
| 233 | 
 | 
|---|
| 234 | /**************************************************************************
 | 
|---|
| 235 |  Other Commands
 | 
|---|
| 236 |  **************************************************************************/
 | 
|---|
| 237 |  /* Ensures LX200 RA/DEC format is long */
 | 
|---|
| 238 | int checkLX200Format(int fd);
 | 
|---|
| 239 | /* Select a site from the LX200 controller */
 | 
|---|
| 240 | int selectSite(int fd, int siteNum);
 | 
|---|
| 241 | /* Select a catalog object */
 | 
|---|
| 242 | int selectCatalogObject(int fd, int catalog, int NNNN);
 | 
|---|
| 243 | /* Select a sub catalog */
 | 
|---|
| 244 | int selectSubCatalog(int fd, int catalog, int subCatalog);
 | 
|---|
| 245 | 
 | 
|---|
| 246 | #ifdef __cplusplus
 | 
|---|
| 247 | }
 | 
|---|
| 248 | #endif
 | 
|---|
| 249 | 
 | 
|---|
| 250 | #endif
 | 
|---|