3 Copyright (C) 2011 Nacho Mas (mas.ignacio@gmail.com). Only litle changes
4 from lx200basic made it by Jasem Mutlaq (mutlaqja@ikarustech.com)
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT
ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License
for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with
this library;
if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 #define IEQ45_TIMEOUT 5
120 int Sync(
int fd,
char *matchedObject);
149 char firmwareDate[14] =
":FirmWareDate#";
154 IDLog(
"Testing telescope's connection using FirmwareDate command...\n");
160 for (i = 0; i < 2; i++)
162 if (write(in_fd, firmwareDate, 14) < 0)
165 if (nbytes_read == 1)
178 char *texto_sin_espacio;
179 for (texto_sin_espacio = texto_recibe; *texto_recibe; texto_recibe++)
181 if (isspace(*texto_recibe))
183 *texto_sin_espacio++ = *texto_recibe;
185 *texto_sin_espacio =
'\0';
190 char temp_string[16];
192 int nbytes_write = 0, nbytes_read = 0;
194 tcflush(
fd, TCIFLUSH);
202 temp_string[nbytes_read - 1] =
'\0';
211 IDLog(
"unable to process [%s]\n", temp_string);
216 tcflush(
fd, TCIFLUSH);
222 char temp_string[16];
225 int nbytes_write = 0, nbytes_read = 0;
227 tcflush(
fd, TCIFLUSH);
234 temp_string[nbytes_read - 1] =
'\0';
237 if (strchr(temp_string,
'.'))
239 if (sscanf(temp_string,
"%f", &temp_number) != 1)
242 *value = (int)temp_number;
245 else if (sscanf(temp_string,
"%d", value) != 1)
255 int nbytes_write = 0, nbytes_read = 0;
265 tcflush(
fd, TCIFLUSH);
270 term = strchr(data,
'#');
293 nbytes_read = sscanf(date,
"%d%*c%d%*c%d", &mm, &dd, &yy);
299 strncpy(mell_prefix,
"19", 3);
301 strncpy(mell_prefix,
"20", 3);
304 snprintf(date, 16,
"%s%02d/%02d/%02d", mell_prefix, yy, mm, dd);
311 char temp_string[16];
313 int nbytes_write = 0, nbytes_read = 0;
326 tcflush(
fd, TCIFLUSH);
331 temp_string[nbytes_read - 1] =
'\0';
333 nbytes_read = sscanf(temp_string,
"(%d)", &tMode);
347 int nbytes_write = 0, nbytes_read = 0;
381 tcflush(
fd, TCIFLUSH);
386 siteName[nbytes_read - 1] =
'\0';
388 term = strchr(siteName,
' ');
392 term = strchr(siteName,
'<');
394 strcpy(siteName,
"unused site");
397 IDLog(
"Requested site name: %s\n", siteName);
405 char temp_string[16];
407 int nbytes_write = 0, nbytes_read = 0;
416 tcflush(
fd, TCIFLUSH);
421 temp_string[nbytes_read - 1] =
'\0';
423 if (sscanf(temp_string,
"%d%*c%d", dd, mm) < 2)
427 fprintf(stderr,
"Requested site latitude in String %s\n", temp_string);
428 fprintf(stderr,
"Requested site latitude %d:%d\n", *dd, *mm);
436 char temp_string[16];
438 int nbytes_write = 0, nbytes_read = 0;
448 tcflush(
fd, TCIFLUSH);
453 temp_string[nbytes_read - 1] =
'\0';
455 if (sscanf(temp_string,
"%d%*c%d", ddd, mm) < 2)
459 fprintf(stderr,
"Requested site longitude in String %s\n", temp_string);
460 fprintf(stderr,
"Requested site longitude %d:%d\n", *ddd, *mm);
469 char temp_string[16];
471 int nbytes_write = 0, nbytes_read = 0;
481 tcflush(
fd, TCIFLUSH);
486 temp_string[nbytes_read] =
'\0';
490 if (sscanf(temp_string,
"%f#", &Freq) < 1)
493 *value = (double)Freq;
496 fprintf(stderr,
"Tracking frequency value is %f\n", Freq);
504 char temp_string[128];
506 int nbytes_write = 0, nbytes_read = 0;
514 tcflush(
fd, TCIFLUSH);
519 *value = nbytes_read - 1;
526 char temp_string[16];
528 int nbytes_write = 0, nbytes_read = 0;
537 tcflush(
fd, TCIFLUSH);
542 temp_string[1] =
'\0';
544 if (temp_string[0] ==
'0')
546 else if (temp_string[0] ==
'1')
548 else if (temp_string[0] ==
'2')
556 char temp_string[16];
558 int nbytes_write = 0, nbytes_read = 0;
569 temp_string[nbytes_read - 1] =
'\0';
571 if (sscanf(temp_string,
"%f", &temp) < 1)
574 *value = (double)temp;
582 char CR[1] = { (char)0x0D };
583 float RA = 0.0, DEC = 0.0;
587 error_type = write(
fd, CR, 1);
591 tcflush(
fd, TCIFLUSH);
593 nbytes_read = sscanf(coords,
" %g %g", &RA, &DEC);
598 IDLog(
"Error in Sky commander number format [%s], exiting.\n", coords);
612 char CR[1] = { (char)0x51 };
613 float RA = 0.0, DEC = 0.0;
618 error_type = write(
fd, CR, 1);
623 tcflush(
fd, TCIFLUSH);
627 if (coords[0] ==
'Q')
634 nbytes_read = sscanf(coords,
" %g %g", &RA, &DEC);
642 IDLog(
"Error in Intelliscope number format [%s], exiting.\n", coords);
647 *
ra = RA * 0.0390625;
648 *
dec = DEC * 0.0390625;
661 int nbytes_write = 0, nbytes_read = 0;
668 tcflush(
fd, TCIFLUSH);
673 if (bool_return[0] ==
'0')
676 IDLog(
"%s Failed.\n", data);
682 IDLog(
"%s Successful\n", data);
690 char temp_string[16];
692 int nbytes_write = 0;
694 snprintf(temp_string,
sizeof(temp_string),
"%s%d#",
cmd, data);
707 char temp_string[16];
709 snprintf(temp_string,
sizeof(temp_string),
":Sh%02d#",
min);
716 char temp_string[16];
718 snprintf(temp_string,
sizeof(temp_string),
":So%02d*#",
max);
725 char temp_string[16];
727 if (slewRate < 2 || slewRate > 8)
730 snprintf(temp_string,
sizeof(temp_string),
":Sw%d#", slewRate);
738 char temp_string[16];
742 frac_m = (s / 60.0) * 10.;
745 snprintf(temp_string,
sizeof(temp_string),
":Sr %02d:%02d:%02d#", h, m, s);
747 snprintf(temp_string,
sizeof(temp_string),
":Sr %02d:%02d.%01d#", h, m, frac_m);
756 char temp_string[16];
765 snprintf(temp_string,
sizeof(temp_string),
":Sd -%02d*%02d#", d, m);
767 snprintf(temp_string,
sizeof(temp_string),
":Sd %+03d*%02d#", d, m);
773 snprintf(temp_string,
sizeof(temp_string),
":Sd -%02d:%02d:%02d#", d, m, s);
775 snprintf(temp_string,
sizeof(temp_string),
":Sd %+03d:%02d:%02d#", d, m, s);
786 char temp_string[16];
788 snprintf(temp_string,
sizeof(temp_string),
"%s %02d:%02d:%02d#",
cmd, x, y, z);
797 int nbytes_write = 0;
821 tcflush(
fd, TCIFLUSH);
827 char temp_string[32];
828 char dumpPlanetaryUpdateString[64];
831 int nbytes_write = 0, nbytes_read = 0;
834 snprintf(temp_string,
sizeof(temp_string),
":SC %02d/%02d/%02d#", mm, dd, yy);
844 tcflush(
fd, TCIFLUSH);
849 bool_return[1] =
'\0';
851 if (bool_return[0] ==
'0')
863 char temp_string[16];
865 snprintf(temp_string,
sizeof(temp_string),
":SG %+03d#", (
int)hours);
875 char temp_string[32];
879 snprintf(temp_string,
sizeof(temp_string),
":Sg%03d:%02d#", d, m);
887 char temp_string[32];
891 snprintf(temp_string,
sizeof(temp_string),
":St%+03d:%02d:%02d#", d, m, s);
899 char temp_string[16];
903 snprintf(temp_string,
sizeof(temp_string),
":Sz%03d:%02d#", d, m);
911 char temp_string[16];
915 snprintf(temp_string,
sizeof(temp_string),
":Sa%+02d*%02d#", d, m);
922 char temp_string[16];
927 snprintf(temp_string,
sizeof(temp_string),
":SM %s#", siteName);
930 snprintf(temp_string,
sizeof(temp_string),
":SN %s#", siteName);
933 snprintf(temp_string,
sizeof(temp_string),
":SO %s#", siteName);
936 snprintf(temp_string,
sizeof(temp_string),
":SP %s#", siteName);
948 int nbytes_write = 0;
980 tcflush(
fd, TCIFLUSH);
987 int nbytes_write = 0;
1011 tcflush(
fd, TCIFLUSH);
1018 int nbytes_write = 0;
1051 tcflush(
fd, TCIFLUSH);
1059 int nbytes_write = 0;
1074 snprintf(speed_str, 8,
":F%d#", speed);
1085 tcflush(
fd, TCIFLUSH);
1091 char temp_string[16];
1093 snprintf(temp_string,
sizeof(temp_string),
":ST %04.1f#", trackF);
1106 int nbytes_write = 0, nbytes_read = 0;
1113 if (nbytes_read < 1)
1117 tcflush(
fd, TCIFLUSH);
1119 if (slewNum[0] ==
'0')
1121 else if (slewNum[0] ==
'1')
1129 int nbytes_write = 0;
1153 tcflush(
fd, TCIFLUSH);
1159 int nbytes_write = 0;
1164 sprintf(
cmd,
":Mgn%04d#", duration_msec);
1167 sprintf(
cmd,
":Mgs%04d#", duration_msec);
1170 sprintf(
cmd,
":Mge%04d#", duration_msec);
1173 sprintf(
cmd,
":Mgw%04d#", duration_msec);
1181 tcflush(
fd, TCIFLUSH);
1188 int nbytes_write = 0;
1227 tcflush(
fd, TCIFLUSH);
1236 int nbytes_write = 0;
1241 tcflush(
fd, TCIFLUSH);
1248 int nbytes_write = 0, nbytes_read = 0;
1259 if (nbytes_read < 1)
1262 matchedObject[nbytes_read - 1] =
'\0';
1268 tcflush(
fd, TCIFLUSH);
1276 int nbytes_write = 0;
1309 tcflush(
fd, TCIFLUSH);
1315 char temp_string[16];
1317 int nbytes_write = 0;
1322 snprintf(temp_string,
sizeof(temp_string),
":LS%d#", NNNN);
1325 snprintf(temp_string,
sizeof(temp_string),
":LC%d#", NNNN);
1328 snprintf(temp_string,
sizeof(temp_string),
":LM%d#", NNNN);
1339 tcflush(
fd, TCIFLUSH);
1345 char temp_string[16];
1349 snprintf(temp_string,
sizeof(temp_string),
":LsD%d#", subCatalog);
1352 snprintf(temp_string,
sizeof(temp_string),
":LoD%d#", subCatalog);
1365 char temp_string[16];
1368 int nbytes_write = 0, nbytes_read = 0;
1379 if (nbytes_read < 1)
1382 temp_string[nbytes_read - 1] =
'\0';
1385 if (temp_string[5] ==
'.')
1397 int nbytes_write = 0;
1403 IDLog(
"Setting tracking mode to sidereal.\n");
1412 IDLog(
"Setting tracking mode to LUNAR.\n");
1421 IDLog(
"Setting tracking mode to SOLAR.\n");
1430 IDLog(
"Setting tracking mode to ZERO.\n");
1443 tcflush(
fd, TCIFLUSH);
int setFocuserMotion(int fd, int motionType)
int setAlignmentMode(int fd, unsigned int alignMode)
int setSlewMode(int fd, int slewMode)
int setObjAlt(int fd, double alt)
int setMinElevationLimit(int fd, int min)
void remove_spaces(char *texto_recibe)
int getHomeSearchStatus(int fd, int *status)
int setObjAz(int fd, double az)
int selectTrackingMode(int fd, int trackMode)
int setMaxSlewRate(int fd, int slewRate)
int getSiteName(int fd, char *siteName, int siteNum)
int check_IEQ45_connection(int fd)
int setObjectDEC(int fd, double dec)
int setMaxElevationLimit(int fd, int max)
int selectSite(int fd, int siteNum)
int setCalenderDate(int fd, int dd, int mm, int yy)
int getCommandInt(int fd, int *value, const char *cmd)
int setStandardProcedure(int fd, char *writeData)
int setSiteLatitude(int fd, double Lat)
int selectSubCatalog(int fd, int catalog, int subCatalog)
int getNumberOfBars(int fd, int *value)
int SendPulseCmd(int fd, int direction, int duration_msec)
int getCommandSexa(int fd, double *value, const char *cmd)
int Sync(int fd, char *matchedObject)
int setTrackFreq(int fd, double trackF)
int setFocuserSpeedMode(int fd, int speedMode)
int getCalendarDate(int fd, char *date)
int updateSkyCommanderCoord(int fd, double *ra, double *dec)
int MoveTo(int fd, int direction)
int getTimeFormat(int fd, int *format)
int setCommandInt(int fd, int data, const char *cmd)
int getCommandString(int fd, char *data, const char *cmd)
int getSiteLongitude(int fd, int *ddd, int *mm)
int getSiteLatitude(int fd, int *dd, int *mm)
int getOTATemp(int fd, double *value)
int getTrackFreq(int fd, double *value)
int setCommandXYZ(int fd, int x, int y, int z, const char *cmd)
int setSiteName(int fd, char *siteName, int siteNum)
int setUTCOffset(int fd, double hours)
int checkIEQ45Format(int fd)
int setGPSFocuserSpeed(int fd, int speed)
int updateIntelliscopeCoord(int fd, double *ra, double *dec)
int setSiteLongitude(int fd, double Long)
int setObjectRA(int fd, double ra)
int HaltMovement(int fd, int direction)
int selectCatalogObject(int fd, int catalog, int NNNN)
int selectAPTrackingMode(int fd, int trackMode)
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
int f_scansexa(const char *str0, double *dp)
convert sexagesimal string str AxBxC to double. x can be anything non-numeric. Any missing A,...
void IDLog(const char *fmt,...)
void getSexComponents(double value, int *d, int *m, int *s)
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
Implementations for common driver routines.
Interface to the reference INDI C API device implementation on the Device Driver side.