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
20 NOTES on 9407 vs 8406:
22 .- Diferent response to :MS#
23 .- Diff RT0,1, .. codification
36 #define IEQ45_TIMEOUT 5
126 int Sync(
int fd,
char *matchedObject);
155 char firmwareVersion[] =
":V#";
156 char MountInfo[] =
":MountInfo#";
161 IDLog(
"Testing telescope's connection using :V# command...\n");
167 for (i = 0; i < 2; i++)
169 if (write(in_fd, firmwareVersion,
sizeof(firmwareVersion)) < 0)
172 if (nbytes_read != 1)
178 IDLog(
"Initializating telescope's using :MountInfo# command...\n");
181 for (i = 0; i < 2; i++)
183 if (write(in_fd, MountInfo,
sizeof(MountInfo)) < 0)
186 if (nbytes_read == 1)
199 char *texto_sin_espacio;
200 for (texto_sin_espacio = texto_recibe; *texto_recibe; texto_recibe++)
202 if (isspace(*texto_recibe))
204 *texto_sin_espacio++ = *texto_recibe;
206 *texto_sin_espacio =
'\0';
211 char temp_string[16];
213 int nbytes_write = 0, nbytes_read = 0;
215 tcflush(
fd, TCIFLUSH);
223 temp_string[nbytes_read - 1] =
'\0';
233 IDLog(
"unable to process [%s]\n", temp_string);
238 tcflush(
fd, TCIFLUSH);
244 char temp_string[16];
247 int nbytes_write = 0, nbytes_read = 0;
249 tcflush(
fd, TCIFLUSH);
256 temp_string[nbytes_read - 1] =
'\0';
259 if (strchr(temp_string,
'.'))
261 if (sscanf(temp_string,
"%f", &temp_number) != 1)
264 *value = (int)temp_number;
267 else if (sscanf(temp_string,
"%d", value) != 1)
277 int nbytes_write = 0, nbytes_read = 0;
287 tcflush(
fd, TCIFLUSH);
292 term = strchr(data,
'#');
315 nbytes_read = sscanf(date,
"%d%*c%d%*c%d", &mm, &dd, &yy);
321 strncpy(mell_prefix,
"19", 3);
323 strncpy(mell_prefix,
"20", 3);
326 snprintf(date, 16,
"%s%02d/%02d/%02d", mell_prefix, yy, mm, dd);
333 char temp_string[16];
335 int nbytes_write = 0, nbytes_read = 0;
348 tcflush(
fd, TCIFLUSH);
353 temp_string[nbytes_read - 1] =
'\0';
355 nbytes_read = sscanf(temp_string,
"(%d)", &tMode);
369 int nbytes_write = 0, nbytes_read = 0;
403 tcflush(
fd, TCIFLUSH);
408 siteName[nbytes_read - 1] =
'\0';
410 term = strchr(siteName,
' ');
414 term = strchr(siteName,
'<');
416 strcpy(siteName,
"unused site");
419 IDLog(
"Requested site name: %s\n", siteName);
427 char temp_string[16];
429 int nbytes_write = 0, nbytes_read = 0;
438 tcflush(
fd, TCIFLUSH);
443 temp_string[nbytes_read - 1] =
'\0';
445 if (sscanf(temp_string,
"%d%*c%d", dd, mm) < 2)
449 fprintf(stderr,
"Requested site latitude in String %s\n", temp_string);
450 fprintf(stderr,
"Requested site latitude %d:%d\n", *dd, *mm);
458 char temp_string[16];
460 int nbytes_write = 0, nbytes_read = 0;
470 tcflush(
fd, TCIFLUSH);
475 temp_string[nbytes_read - 1] =
'\0';
477 if (sscanf(temp_string,
"%d%*c%d", ddd, mm) < 2)
481 fprintf(stderr,
"Requested site longitude in String %s\n", temp_string);
482 fprintf(stderr,
"Requested site longitude %d:%d\n", *ddd, *mm);
491 char temp_string[16];
493 int nbytes_write = 0, nbytes_read = 0;
503 tcflush(
fd, TCIFLUSH);
508 temp_string[nbytes_read] =
'\0';
512 if (sscanf(temp_string,
"%f#", &Freq) < 1)
515 *value = (double)Freq;
518 fprintf(stderr,
"Tracking frequency value is %f\n", Freq);
526 char temp_string[128];
528 int nbytes_write = 0, nbytes_read = 0;
536 tcflush(
fd, TCIFLUSH);
541 *value = nbytes_read - 1;
548 char temp_string[16];
550 int nbytes_write = 0, nbytes_read = 0;
559 tcflush(
fd, TCIFLUSH);
564 temp_string[1] =
'\0';
566 if (temp_string[0] ==
'0')
568 else if (temp_string[0] ==
'1')
570 else if (temp_string[0] ==
'2')
578 char temp_string[16];
580 int nbytes_write = 0, nbytes_read = 0;
591 temp_string[nbytes_read - 1] =
'\0';
593 if (sscanf(temp_string,
"%f", &temp) < 1)
596 *value = (double)temp;
604 char CR[1] = { (char)0x0D };
605 float RA = 0.0, DEC = 0.0;
609 error_type = write(
fd, CR, 1);
613 tcflush(
fd, TCIFLUSH);
615 nbytes_read = sscanf(coords,
" %g %g", &RA, &DEC);
620 IDLog(
"Error in Sky commander number format [%s], exiting.\n", coords);
634 char CR[1] = { (char)0x51 };
635 float RA = 0.0, DEC = 0.0;
640 error_type = write(
fd, CR, 1);
645 tcflush(
fd, TCIFLUSH);
649 if (coords[0] ==
'Q')
656 nbytes_read = sscanf(coords,
" %g %g", &RA, &DEC);
664 IDLog(
"Error in Intelliscope number format [%s], exiting.\n", coords);
669 *
ra = RA * 0.0390625;
670 *
dec = DEC * 0.0390625;
683 int nbytes_write = 0, nbytes_read = 0;
690 tcflush(
fd, TCIFLUSH);
695 if (bool_return[0] ==
'0')
698 IDLog(
"%s Failed.\n", data);
704 IDLog(
"%s Successful\n", data);
712 char temp_string[16];
714 int nbytes_write = 0;
716 snprintf(temp_string,
sizeof(temp_string),
"%s%d#",
cmd, data);
729 char temp_string[16];
731 snprintf(temp_string,
sizeof(temp_string),
":Sh%02d#",
min);
738 char temp_string[16];
740 snprintf(temp_string,
sizeof(temp_string),
":So%02d*#",
max);
747 char temp_string[16];
749 if (slewRate < 2 || slewRate > 8)
752 snprintf(temp_string,
sizeof(temp_string),
":Sw%d#", slewRate);
760 char temp_string[16];
764 frac_m = (s / 60.0) * 10.;
767 snprintf(temp_string,
sizeof(temp_string),
":Sr %02d:%02d:%02d#", h, m, s);
769 snprintf(temp_string,
sizeof(temp_string),
":Sr %02d:%02d.%01d#", h, m, frac_m);
778 char temp_string[16];
787 snprintf(temp_string,
sizeof(temp_string),
":Sd -%02d*%02d#", d, m);
789 snprintf(temp_string,
sizeof(temp_string),
":Sd %+03d*%02d#", d, m);
795 snprintf(temp_string,
sizeof(temp_string),
":Sd -%02d:%02d:%02d#", d, m, s);
797 snprintf(temp_string,
sizeof(temp_string),
":Sd %+03d:%02d:%02d#", d, m, s);
808 char temp_string[16];
810 snprintf(temp_string,
sizeof(temp_string),
"%s %02d:%02d:%02d#",
cmd, x, y, z);
819 int nbytes_write = 0;
843 tcflush(
fd, TCIFLUSH);
849 char temp_string[32];
850 char dumpPlanetaryUpdateString[64];
853 int nbytes_write = 0, nbytes_read = 0;
856 snprintf(temp_string,
sizeof(temp_string),
":SC %02d/%02d/%02d#", mm, dd, yy);
866 tcflush(
fd, TCIFLUSH);
871 bool_return[1] =
'\0';
873 if (bool_return[0] ==
'0')
885 char temp_string[16];
887 snprintf(temp_string,
sizeof(temp_string),
":SG %+03d#", (
int)hours);
897 char temp_string[32];
901 snprintf(temp_string,
sizeof(temp_string),
":Sg%03d:%02d#", d, m);
909 char temp_string[32];
913 snprintf(temp_string,
sizeof(temp_string),
":St%+03d:%02d:%02d#", d, m, s);
921 char temp_string[16];
925 snprintf(temp_string,
sizeof(temp_string),
":Sz%03d:%02d#", d, m);
933 char temp_string[16];
937 snprintf(temp_string,
sizeof(temp_string),
":Sa%+02d*%02d#", d, m);
944 char temp_string[16];
949 snprintf(temp_string,
sizeof(temp_string),
":SM %s#", siteName);
952 snprintf(temp_string,
sizeof(temp_string),
":SN %s#", siteName);
955 snprintf(temp_string,
sizeof(temp_string),
":SO %s#", siteName);
958 snprintf(temp_string,
sizeof(temp_string),
":SP %s#", siteName);
970 int nbytes_write = 0;
1002 tcflush(
fd, TCIFLUSH);
1009 int nbytes_write = 0;
1033 tcflush(
fd, TCIFLUSH);
1040 int nbytes_write = 0;
1073 tcflush(
fd, TCIFLUSH);
1081 int nbytes_write = 0;
1096 snprintf(speed_str, 8,
":F%d#", speed);
1107 tcflush(
fd, TCIFLUSH);
1113 char temp_string[16];
1115 snprintf(temp_string,
sizeof(temp_string),
":ST %04.1f#", trackF);
1128 int nbytes_write = 0, nbytes_read = 0;
1138 if (nbytes_read < 1)
1142 tcflush(
fd, TCIFLUSH);
1144 if (slewNum[0] ==
'1')
1146 else if (slewNum[0] ==
'0')
1154 int nbytes_write = 0;
1178 tcflush(
fd, TCIFLUSH);
1184 int nbytes_write = 0;
1189 sprintf(
cmd,
":Mgn%04d#", duration_msec);
1192 sprintf(
cmd,
":Mgs%04d#", duration_msec);
1195 sprintf(
cmd,
":Mge%04d#", duration_msec);
1198 sprintf(
cmd,
":Mgw%04d#", duration_msec);
1206 tcflush(
fd, TCIFLUSH);
1213 int nbytes_write = 0;
1252 tcflush(
fd, TCIFLUSH);
1261 int nbytes_write = 0;
1266 tcflush(
fd, TCIFLUSH);
1273 int nbytes_write = 0, nbytes_read = 0;
1284 if (nbytes_read < 1)
1287 matchedObject[nbytes_read - 1] =
'\0';
1293 tcflush(
fd, TCIFLUSH);
1301 int nbytes_write = 0;
1334 tcflush(
fd, TCIFLUSH);
1340 char temp_string[16];
1342 int nbytes_write = 0;
1347 snprintf(temp_string,
sizeof(temp_string),
":LS%d#", NNNN);
1350 snprintf(temp_string,
sizeof(temp_string),
":LC%d#", NNNN);
1353 snprintf(temp_string,
sizeof(temp_string),
":LM%d#", NNNN);
1364 tcflush(
fd, TCIFLUSH);
1370 char temp_string[16];
1374 snprintf(temp_string,
sizeof(temp_string),
":LsD%d#", subCatalog);
1377 snprintf(temp_string,
sizeof(temp_string),
":LoD%d#", subCatalog);
1390 char temp_string[16];
1393 int nbytes_write = 0, nbytes_read = 0;
1404 if (nbytes_read < 1)
1407 temp_string[nbytes_read - 1] =
'\0';
1410 if (temp_string[5] ==
'.')
1422 int nbytes_write = 0;
1428 IDLog(
"Setting tracking mode to sidereal.\n");
1437 IDLog(
"Setting tracking mode to LUNAR.\n");
1446 IDLog(
"Setting tracking mode to SOLAR.\n");
1455 IDLog(
"Setting tracking mode to custom.\n");
1468 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.