Instrument Neutral Distributed Interface INDI  2.0.2
ieq45driver8406.c
Go to the documentation of this file.
1 #if 0
2  IEQ45 Driver
3  Copyright (C) 2011 Nacho Mas (mas.ignacio@gmail.com). Only litle changes
4  from lx200basic made it by Jasem Mutlaq (mutlaqja@ikarustech.com)
5 
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.
10 
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.
15 
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
19 
20 #endif
21 
22 #include "ieq45driver.h"
23 
24 #include "indicom.h"
25 #include "indidevapi.h"
26 
27 #ifndef _WIN32
28 #include <termios.h>
29 #endif
30 
31 #define IEQ45_TIMEOUT 5 /* FD timeout in seconds */
32 
34 
35 /**************************************************************************
36  Diagnostics
37  **************************************************************************/
38 int check_IEQ45_connection(int fd);
39 
40 /**************************************************************************
41  Get Commands: store data in the supplied buffer. Return 0 on success or -1 on failure
42  **************************************************************************/
43 
44 /* Get Double from Sexagisemal */
45 int getCommandSexa(int fd, double *value, const char *cmd);
46 /* Get String */
47 int getCommandString(int fd, char *data, const char *cmd);
48 /* Get Int */
49 int getCommandInt(int fd, int *value, const char *cmd);
50 /* Get tracking frequency */
51 int getTrackFreq(int fd, double *value);
52 /* Get site Latitude */
53 int getSiteLatitude(int fd, int *dd, int *mm);
54 /* Get site Longitude */
55 int getSiteLongitude(int fd, int *ddd, int *mm);
56 /* Get Calender data */
57 int getCalendarDate(int fd, char *date);
58 /* Get site Name */
59 int getSiteName(int fd, char *siteName, int siteNum);
60 /* Get Number of Bars */
61 int getNumberOfBars(int fd, int *value);
62 /* Get Home Search Status */
63 int getHomeSearchStatus(int fd, int *status);
64 /* Get OTA Temperature */
65 int getOTATemp(int fd, double *value);
66 /* Get time format: 12 or 24 */
67 int getTimeFormat(int fd, int *format);
68 
69 /**************************************************************************
70  Set Commands
71  **************************************************************************/
72 
73 /* Set Int */
74 int setCommandInt(int fd, int data, const char *cmd);
75 /* Set Sexigesimal */
76 int setCommandXYZ(int fd, int x, int y, int z, const char *cmd);
77 /* Common routine for Set commands */
78 int setStandardProcedure(int fd, char *writeData);
79 /* Set Slew Mode */
80 int setSlewMode(int fd, int slewMode);
81 /* Set Alignment mode */
82 int setAlignmentMode(int fd, unsigned int alignMode);
83 /* Set Object RA */
84 int setObjectRA(int fd, double ra);
85 /* set Object DEC */
86 int setObjectDEC(int fd, double dec);
87 /* Set Calender date */
88 int setCalenderDate(int fd, int dd, int mm, int yy);
89 /* Set UTC offset */
90 int setUTCOffset(int fd, double hours);
91 /* Set Track Freq */
92 int setTrackFreq(int fd, double trackF);
93 /* Set current site longitude */
94 int setSiteLongitude(int fd, double Long);
95 /* Set current site latitude */
96 int setSiteLatitude(int fd, double Lat);
97 /* Set Object Azimuth */
98 int setObjAz(int fd, double az);
99 /* Set Object Altitude */
100 int setObjAlt(int fd, double alt);
101 /* Set site name */
102 int setSiteName(int fd, char *siteName, int siteNum);
103 /* Set maximum slew rate */
104 int setMaxSlewRate(int fd, int slewRate);
105 /* Set focuser motion */
106 int setFocuserMotion(int fd, int motionType);
107 /* Set focuser speed mode */
108 int setFocuserSpeedMode(int fd, int speedMode);
109 /* Set minimum elevation limit */
110 int setMinElevationLimit(int fd, int min);
111 /* Set maximum elevation limit */
112 int setMaxElevationLimit(int fd, int max);
113 
114 /**************************************************************************
115  Motion Commands
116  **************************************************************************/
117 /* Slew to the selected coordinates */
118 int Slew(int fd);
119 /* Synchronize to the selected coordinates and return the matching object if any */
120 int Sync(int fd, char *matchedObject);
121 /* Abort slew in all axes */
122 int abortSlew(int fd);
123 /* Move into one direction, two valid directions can be stacked */
124 int MoveTo(int fd, int direction);
125 /* Half movement in a particular direction */
126 int HaltMovement(int fd, int direction);
127 /* Select the tracking mode */
128 int selectTrackingMode(int fd, int trackMode);
129 /* Select Astro-Physics tracking mode */
130 int selectAPTrackingMode(int fd, int trackMode);
131 /* Send Pulse-Guide command (timed guide move), two valid directions can be stacked */
132 int SendPulseCmd(int fd, int direction, int duration_msec);
133 
134 /**************************************************************************
135  Other Commands
136  **************************************************************************/
137 /* Ensures IEQ45 RA/DEC format is long */
138 int checkIEQ45Format(int fd);
139 /* Select a site from the IEQ45 controller */
140 int selectSite(int fd, int siteNum);
141 /* Select a catalog object */
142 int selectCatalogObject(int fd, int catalog, int NNNN);
143 /* Select a sub catalog */
144 int selectSubCatalog(int fd, int catalog, int subCatalog);
145 
147 {
148  int i = 0;
149  char firmwareDate[14] = ":FirmWareDate#";
150  char MountAlign[64];
151  int nbytes_read = 0;
152 
153 #ifdef INDI_DEBUG
154  IDLog("Testing telescope's connection using FirmwareDate command...\n");
155 #endif
156 
157  if (in_fd <= 0)
158  return -1;
159 
160  for (i = 0; i < 2; i++)
161  {
162  if (write(in_fd, firmwareDate, 14) < 0)
163  return -1;
164  tty_read(in_fd, MountAlign, 1, IEQ45_TIMEOUT, &nbytes_read);
165  if (nbytes_read == 1)
166  return 0;
167  usleep(50000);
168  }
169 
170  return -1;
171 }
172 
173 /**********************************************************************
174 * GET
175 **********************************************************************/
176 void remove_spaces(char *texto_recibe)
177 {
178  char *texto_sin_espacio;
179  for (texto_sin_espacio = texto_recibe; *texto_recibe; texto_recibe++)
180  {
181  if (isspace(*texto_recibe))
182  continue;
183  *texto_sin_espacio++ = *texto_recibe;
184  }
185  *texto_sin_espacio = '\0';
186 }
187 
188 int getCommandSexa(int fd, double *value, const char *cmd)
189 {
190  char temp_string[16];
191  int error_type;
192  int nbytes_write = 0, nbytes_read = 0;
193 
194  tcflush(fd, TCIFLUSH);
195  if ((error_type = tty_write_string(fd, cmd, &nbytes_write)) != TTY_OK)
196  return error_type;
197 
198  /*if ( (read_ret = portRead(temp_string, -1, IEQ45_TIMEOUT)) < 1)
199  return read_ret;*/
200  tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
201 
202  temp_string[nbytes_read - 1] = '\0';
203 
204  /*IDLog("getComandSexa: %s\n", temp_string);*/
205  //IEQ45 sometimes send a malformed RA/DEC (intermediate spaces)
206  //so I clean before:
207  remove_spaces(temp_string);
208  if (f_scansexa(temp_string, value))
209  {
210 #ifdef INDI_DEBUG
211  IDLog("unable to process [%s]\n", temp_string);
212 #endif
213  return -1;
214  }
215 
216  tcflush(fd, TCIFLUSH);
217  return 0;
218 }
219 
220 int getCommandInt(int fd, int *value, const char *cmd)
221 {
222  char temp_string[16];
223  float temp_number;
224  int error_type;
225  int nbytes_write = 0, nbytes_read = 0;
226 
227  tcflush(fd, TCIFLUSH);
228 
229  if ((error_type = tty_write_string(fd, cmd, &nbytes_write)) != TTY_OK)
230  return error_type;
231 
232  tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
233 
234  temp_string[nbytes_read - 1] = '\0';
235 
236  /* Float */
237  if (strchr(temp_string, '.'))
238  {
239  if (sscanf(temp_string, "%f", &temp_number) != 1)
240  return -1;
241 
242  *value = (int)temp_number;
243  }
244  /* Int */
245  else if (sscanf(temp_string, "%d", value) != 1)
246  return -1;
247 
248  return 0;
249 }
250 
251 int getCommandString(int fd, char *data, const char *cmd)
252 {
253  char *term;
254  int error_type;
255  int nbytes_write = 0, nbytes_read = 0;
256 
257  /*if (portWrite(cmd) < 0)
258  return -1;*/
259 
260  if ((error_type = tty_write_string(fd, cmd, &nbytes_write)) != TTY_OK)
261  return error_type;
262 
263  /*read_ret = portRead(data, -1, IEQ45_TIMEOUT);*/
264  error_type = tty_read_section(fd, data, '#', IEQ45_TIMEOUT, &nbytes_read);
265  tcflush(fd, TCIFLUSH);
266 
267  if (error_type != TTY_OK)
268  return error_type;
269 
270  term = strchr(data, '#');
271  if (term)
272  *term = '\0';
273 
274 #ifdef INDI_DEBUG
275 /*IDLog("Requested data: %s\n", data);*/
276 #endif
277 
278  return 0;
279 }
280 
281 int getCalendarDate(int fd, char *date)
282 {
283  int dd, mm, yy;
284  int error_type;
285  int nbytes_read = 0;
286  char mell_prefix[3];
287 
288  if ((error_type = getCommandString(fd, date, ":GC#")))
289  return error_type;
290 
291  /* Meade format is MM/DD/YY */
292 
293  nbytes_read = sscanf(date, "%d%*c%d%*c%d", &mm, &dd, &yy);
294  if (nbytes_read < 3)
295  return -1;
296 
297  /* We consider years 50 or more to be in the last century, anything less in the 21st century.*/
298  if (yy > 50)
299  strncpy(mell_prefix, "19", 3);
300  else
301  strncpy(mell_prefix, "20", 3);
302 
303  /* We need to have in in YYYY/MM/DD format */
304  snprintf(date, 16, "%s%02d/%02d/%02d", mell_prefix, yy, mm, dd);
305 
306  return (0);
307 }
308 
309 int getTimeFormat(int fd, int *format)
310 {
311  char temp_string[16];
312  int error_type;
313  int nbytes_write = 0, nbytes_read = 0;
314  int tMode;
315 
316  /*if (portWrite(":Gc#") < 0)
317  return -1;*/
318 
319  if ((error_type = tty_write_string(fd, ":Gc#", &nbytes_write)) != TTY_OK)
320  return error_type;
321 
322  /*read_ret = portRead(temp_string, -1, IEQ45_TIMEOUT);*/
323  if ((error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read)) != TTY_OK)
324  return error_type;
325 
326  tcflush(fd, TCIFLUSH);
327 
328  if (nbytes_read < 1)
329  return error_type;
330 
331  temp_string[nbytes_read - 1] = '\0';
332 
333  nbytes_read = sscanf(temp_string, "(%d)", &tMode);
334 
335  if (nbytes_read < 1)
336  return -1;
337  else
338  *format = tMode;
339 
340  return 0;
341 }
342 
343 int getSiteName(int fd, char *siteName, int siteNum)
344 {
345  char *term;
346  int error_type;
347  int nbytes_write = 0, nbytes_read = 0;
348 
349  switch (siteNum)
350  {
351  case 1:
352  /*if (portWrite(":GM#") < 0)
353  return -1;*/
354  if ((error_type = tty_write_string(fd, ":GM#", &nbytes_write)) != TTY_OK)
355  return error_type;
356  break;
357  case 2:
358  /*if (portWrite(":GN#") < 0)
359  return -1;*/
360  if ((error_type = tty_write_string(fd, ":GN#", &nbytes_write)) != TTY_OK)
361  return error_type;
362  break;
363  case 3:
364  /*if (portWrite(":GO#") < 0)
365  return -1;*/
366  if ((error_type = tty_write_string(fd, ":GO#", &nbytes_write)) != TTY_OK)
367  return error_type;
368  break;
369  case 4:
370  /*if (portWrite(":GP#") < 0)
371  return -1;*/
372  if ((error_type = tty_write_string(fd, ":GP#", &nbytes_write)) != TTY_OK)
373  return error_type;
374  break;
375  default:
376  return -1;
377  }
378 
379  /*read_ret = portRead(siteName, -1, IEQ45_TIMEOUT);*/
380  error_type = tty_read_section(fd, siteName, '#', IEQ45_TIMEOUT, &nbytes_read);
381  tcflush(fd, TCIFLUSH);
382 
383  if (nbytes_read < 1)
384  return error_type;
385 
386  siteName[nbytes_read - 1] = '\0';
387 
388  term = strchr(siteName, ' ');
389  if (term)
390  *term = '\0';
391 
392  term = strchr(siteName, '<');
393  if (term)
394  strcpy(siteName, "unused site");
395 
396 #ifdef INDI_DEBUG
397  IDLog("Requested site name: %s\n", siteName);
398 #endif
399 
400  return 0;
401 }
402 
403 int getSiteLatitude(int fd, int *dd, int *mm)
404 {
405  char temp_string[16];
406  int error_type;
407  int nbytes_write = 0, nbytes_read = 0;
408 
409  /*if (portWrite(":Gt#") < 0)
410  return -1;*/
411  if ((error_type = tty_write_string(fd, ":Gt#", &nbytes_write)) != TTY_OK)
412  return error_type;
413 
414  /*read_ret = portRead(temp_string, -1, IEQ45_TIMEOUT);*/
415  error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
416  tcflush(fd, TCIFLUSH);
417 
418  if (nbytes_read < 1)
419  return error_type;
420 
421  temp_string[nbytes_read - 1] = '\0';
422 
423  if (sscanf(temp_string, "%d%*c%d", dd, mm) < 2)
424  return -1;
425 
426 #ifdef INDI_DEBUG
427  fprintf(stderr, "Requested site latitude in String %s\n", temp_string);
428  fprintf(stderr, "Requested site latitude %d:%d\n", *dd, *mm);
429 #endif
430 
431  return 0;
432 }
433 
434 int getSiteLongitude(int fd, int *ddd, int *mm)
435 {
436  char temp_string[16];
437  int error_type;
438  int nbytes_write = 0, nbytes_read = 0;
439 
440  if ((error_type = tty_write_string(fd, ":Gg#", &nbytes_write)) != TTY_OK)
441  return error_type;
442 
443  /*if (portWrite(":Gg#") < 0)
444  return -1;*/
445  error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
446  /*read_ret = portRead(temp_string, -1, IEQ45_TIMEOUT);*/
447 
448  tcflush(fd, TCIFLUSH);
449 
450  if (nbytes_read < 1)
451  return error_type;
452 
453  temp_string[nbytes_read - 1] = '\0';
454 
455  if (sscanf(temp_string, "%d%*c%d", ddd, mm) < 2)
456  return -1;
457 
458 #ifdef INDI_DEBUG
459  fprintf(stderr, "Requested site longitude in String %s\n", temp_string);
460  fprintf(stderr, "Requested site longitude %d:%d\n", *ddd, *mm);
461 #endif
462 
463  return 0;
464 }
465 
466 int getTrackFreq(int fd, double *value)
467 {
468  float Freq;
469  char temp_string[16];
470  int error_type;
471  int nbytes_write = 0, nbytes_read = 0;
472 
473  if ((error_type = tty_write_string(fd, ":GT#", &nbytes_write)) != TTY_OK)
474  return error_type;
475 
476  /*if (portWrite(":GT#") < 0)
477  return -1;*/
478 
479  /*read_ret = portRead(temp_string, -1, IEQ45_TIMEOUT);*/
480  error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
481  tcflush(fd, TCIFLUSH);
482 
483  if (nbytes_read < 1)
484  return error_type;
485 
486  temp_string[nbytes_read] = '\0';
487 
488  /*fprintf(stderr, "Telescope tracking freq str: %s\n", temp_string);*/
489 
490  if (sscanf(temp_string, "%f#", &Freq) < 1)
491  return -1;
492 
493  *value = (double)Freq;
494 
495 #ifdef INDI_DEBUG
496  fprintf(stderr, "Tracking frequency value is %f\n", Freq);
497 #endif
498 
499  return 0;
500 }
501 
502 int getNumberOfBars(int fd, int *value)
503 {
504  char temp_string[128];
505  int error_type;
506  int nbytes_write = 0, nbytes_read = 0;
507 
508  if ((error_type = tty_write_string(fd, ":D#", &nbytes_write)) != TTY_OK)
509  return error_type;
510  /*if (portWrite(":D#") < 0)
511  return -1;*/
512 
513  error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
514  tcflush(fd, TCIFLUSH);
515 
516  if (nbytes_read < 0)
517  return error_type;
518 
519  *value = nbytes_read - 1;
520 
521  return 0;
522 }
523 
524 int getHomeSearchStatus(int fd, int *status)
525 {
526  char temp_string[16];
527  int error_type;
528  int nbytes_write = 0, nbytes_read = 0;
529 
530  if ((error_type = tty_write_string(fd, ":h?#", &nbytes_write)) != TTY_OK)
531  return error_type;
532  /*if (portWrite(":h?#") < 0)
533  return -1;*/
534 
535  /*read_ret = portRead(temp_string, 1, IEQ45_TIMEOUT);*/
536  error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
537  tcflush(fd, TCIFLUSH);
538 
539  if (nbytes_read < 1)
540  return error_type;
541 
542  temp_string[1] = '\0';
543 
544  if (temp_string[0] == '0')
545  *status = 0;
546  else if (temp_string[0] == '1')
547  *status = 1;
548  else if (temp_string[0] == '2')
549  *status = 1;
550 
551  return 0;
552 }
553 
554 int getOTATemp(int fd, double *value)
555 {
556  char temp_string[16];
557  int error_type;
558  int nbytes_write = 0, nbytes_read = 0;
559  float temp;
560 
561  if ((error_type = tty_write_string(fd, ":fT#", &nbytes_write)) != TTY_OK)
562  return error_type;
563 
564  error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
565 
566  if (nbytes_read < 1)
567  return error_type;
568 
569  temp_string[nbytes_read - 1] = '\0';
570 
571  if (sscanf(temp_string, "%f", &temp) < 1)
572  return -1;
573 
574  *value = (double)temp;
575 
576  return 0;
577 }
578 
579 int updateSkyCommanderCoord(int fd, double *ra, double *dec)
580 {
581  char coords[16];
582  char CR[1] = { (char)0x0D };
583  float RA = 0.0, DEC = 0.0;
584  int error_type;
585  int nbytes_read = 0;
586 
587  error_type = write(fd, CR, 1);
588 
589  error_type = tty_read(fd, coords, 16, IEQ45_TIMEOUT, &nbytes_read);
590  /*read_ret = portRead(coords, 16, IEQ45_TIMEOUT);*/
591  tcflush(fd, TCIFLUSH);
592 
593  nbytes_read = sscanf(coords, " %g %g", &RA, &DEC);
594 
595  if (nbytes_read < 2)
596  {
597 #ifdef INDI_DEBUG
598  IDLog("Error in Sky commander number format [%s], exiting.\n", coords);
599 #endif
600  return error_type;
601  }
602 
603  *ra = RA;
604  *dec = DEC;
605 
606  return 0;
607 }
608 
609 int updateIntelliscopeCoord(int fd, double *ra, double *dec)
610 {
611  char coords[16];
612  char CR[1] = { (char)0x51 }; /* "Q" */
613  float RA = 0.0, DEC = 0.0;
614  int error_type;
615  int nbytes_read = 0;
616 
617  /*IDLog ("Sending a Q\n");*/
618  error_type = write(fd, CR, 1);
619  /* We start at 14 bytes in case its a Sky Wizard,
620  but read one more later it if it's a intelliscope */
621  /*read_ret = portRead (coords, 14, IEQ45_TIMEOUT);*/
622  error_type = tty_read(fd, coords, 14, IEQ45_TIMEOUT, &nbytes_read);
623  tcflush(fd, TCIFLUSH);
624  /*IDLog ("portRead() = [%s]\n", coords);*/
625 
626  /* Remove the Q in the response from the Intelliscope but not the Sky Wizard */
627  if (coords[0] == 'Q')
628  {
629  coords[0] = ' ';
630  /* Read one more byte if Intelliscope to get the "CR" */
631  error_type = tty_read(fd, coords, 1, IEQ45_TIMEOUT, &nbytes_read);
632  /*read_ret = portRead (coords, 1, IEQ45_TIMEOUT);*/
633  }
634  nbytes_read = sscanf(coords, " %g %g", &RA, &DEC);
635  /*IDLog ("sscanf() RA = [%f]\n", RA * 0.0390625);*/
636  /*IDLog ("sscanf() DEC = [%f]\n", DEC * 0.0390625);*/
637 
638  /*IDLog ("Intelliscope output [%s]", coords);*/
639  if (nbytes_read < 2)
640  {
641 #ifdef INDI_DEBUG
642  IDLog("Error in Intelliscope number format [%s], exiting.\n", coords);
643 #endif
644  return -1;
645  }
646 
647  *ra = RA * 0.0390625;
648  *dec = DEC * 0.0390625;
649 
650  return 0;
651 }
652 
653 /**********************************************************************
654 * SET
655 **********************************************************************/
656 
657 int setStandardProcedure(int fd, char *data)
658 {
659  char bool_return[2];
660  int error_type;
661  int nbytes_write = 0, nbytes_read = 0;
662 
663  if ((error_type = tty_write_string(fd, data, &nbytes_write)) != TTY_OK)
664  return error_type;
665 
666  error_type = tty_read(fd, bool_return, 1, IEQ45_TIMEOUT, &nbytes_read);
667  /*read_ret = portRead(boolRet, 1, IEQ45_TIMEOUT);*/
668  tcflush(fd, TCIFLUSH);
669 
670  if (nbytes_read < 1)
671  return error_type;
672 
673  if (bool_return[0] == '0')
674  {
675 #ifdef INDI_DEBUG
676  IDLog("%s Failed.\n", data);
677 #endif
678  return -1;
679  }
680 
681 #ifdef INDI_DEBUG
682  IDLog("%s Successful\n", data);
683 #endif
684 
685  return 0;
686 }
687 
688 int setCommandInt(int fd, int data, const char *cmd)
689 {
690  char temp_string[16];
691  int error_type;
692  int nbytes_write = 0;
693 
694  snprintf(temp_string, sizeof(temp_string), "%s%d#", cmd, data);
695 
696  if ((error_type = tty_write_string(fd, temp_string, &nbytes_write)) != TTY_OK)
697  return error_type;
698 
699  /* if (portWrite(temp_string) < 0)
700  return -1;*/
701 
702  return 0;
703 }
704 
706 {
707  char temp_string[16];
708 
709  snprintf(temp_string, sizeof(temp_string), ":Sh%02d#", min);
710 
711  return (setStandardProcedure(fd, temp_string));
712 }
713 
715 {
716  char temp_string[16];
717 
718  snprintf(temp_string, sizeof(temp_string), ":So%02d*#", max);
719 
720  return (setStandardProcedure(fd, temp_string));
721 }
722 
723 int setMaxSlewRate(int fd, int slewRate)
724 {
725  char temp_string[16];
726 
727  if (slewRate < 2 || slewRate > 8)
728  return -1;
729 
730  snprintf(temp_string, sizeof(temp_string), ":Sw%d#", slewRate);
731 
732  return (setStandardProcedure(fd, temp_string));
733 }
734 
735 int setObjectRA(int fd, double ra)
736 {
737  int h, m, s, frac_m;
738  char temp_string[16];
739 
740  getSexComponents(ra, &h, &m, &s);
741 
742  frac_m = (s / 60.0) * 10.;
743 
745  snprintf(temp_string, sizeof(temp_string), ":Sr %02d:%02d:%02d#", h, m, s);
746  else
747  snprintf(temp_string, sizeof(temp_string), ":Sr %02d:%02d.%01d#", h, m, frac_m);
748 
749  /*IDLog("Set Object RA String %s\n", temp_string);*/
750  return (setStandardProcedure(fd, temp_string));
751 }
752 
753 int setObjectDEC(int fd, double dec)
754 {
755  int d, m, s;
756  char temp_string[16];
757 
758  getSexComponents(dec, &d, &m, &s);
759 
760  switch (controller_format)
761  {
762  case IEQ45_SHORT_FORMAT:
763  /* case with negative zero */
764  if (!d && dec < 0)
765  snprintf(temp_string, sizeof(temp_string), ":Sd -%02d*%02d#", d, m);
766  else
767  snprintf(temp_string, sizeof(temp_string), ":Sd %+03d*%02d#", d, m);
768  break;
769 
770  case IEQ45_LONG_FORMAT:
771  /* case with negative zero */
772  if (!d && dec < 0)
773  snprintf(temp_string, sizeof(temp_string), ":Sd -%02d:%02d:%02d#", d, m, s);
774  else
775  snprintf(temp_string, sizeof(temp_string), ":Sd %+03d:%02d:%02d#", d, m, s);
776  break;
777  }
778 
779  /*IDLog("Set Object DEC String %s\n", temp_string);*/
780 
781  return (setStandardProcedure(fd, temp_string));
782 }
783 
784 int setCommandXYZ(int fd, int x, int y, int z, const char *cmd)
785 {
786  char temp_string[16];
787 
788  snprintf(temp_string, sizeof(temp_string), "%s %02d:%02d:%02d#", cmd, x, y, z);
789 
790  return (setStandardProcedure(fd, temp_string));
791 }
792 
793 int setAlignmentMode(int fd, unsigned int alignMode)
794 {
795  /*fprintf(stderr , "Set alignment mode %d\n", alignMode);*/
796  int error_type;
797  int nbytes_write = 0;
798 
799  switch (alignMode)
800  {
801  case IEQ45_ALIGN_POLAR:
802  if ((error_type = tty_write_string(fd, ":AP#", &nbytes_write)) != TTY_OK)
803  return error_type;
804  /*if (portWrite(":AP#") < 0)
805  return -1;*/
806  break;
807  case IEQ45_ALIGN_ALTAZ:
808  if ((error_type = tty_write_string(fd, ":AA#", &nbytes_write)) != TTY_OK)
809  return error_type;
810  /*if (portWrite(":AA#") < 0)
811  return -1;*/
812  break;
813  case IEQ45_ALIGN_LAND:
814  if ((error_type = tty_write_string(fd, ":AL#", &nbytes_write)) != TTY_OK)
815  return error_type;
816  /*if (portWrite(":AL#") < 0)
817  return -1;*/
818  break;
819  }
820 
821  tcflush(fd, TCIFLUSH);
822  return 0;
823 }
824 
825 int setCalenderDate(int fd, int dd, int mm, int yy)
826 {
827  char temp_string[32];
828  char dumpPlanetaryUpdateString[64];
829  char bool_return[2];
830  int error_type;
831  int nbytes_write = 0, nbytes_read = 0;
832  yy = yy % 100;
833 
834  snprintf(temp_string, sizeof(temp_string), ":SC %02d/%02d/%02d#", mm, dd, yy);
835 
836  if ((error_type = tty_write_string(fd, temp_string, &nbytes_write)) != TTY_OK)
837  return error_type;
838 
839  /*if (portWrite(temp_string) < 0)
840  return -1;*/
841 
842  /*read_ret = portRead(boolRet, 1, IEQ45_TIMEOUT);*/
843  error_type = tty_read(fd, bool_return, 1, IEQ45_TIMEOUT, &nbytes_read);
844  tcflush(fd, TCIFLUSH);
845 
846  if (nbytes_read < 1)
847  return error_type;
848 
849  bool_return[1] = '\0';
850 
851  if (bool_return[0] == '0')
852  return -1;
853 
854  /* Read dumped data */
855  error_type = tty_read_section(fd, dumpPlanetaryUpdateString, '#', IEQ45_TIMEOUT, &nbytes_read);
856  error_type = tty_read_section(fd, dumpPlanetaryUpdateString, '#', 5, &nbytes_read);
857 
858  return 0;
859 }
860 
861 int setUTCOffset(int fd, double hours)
862 {
863  char temp_string[16];
864 
865  snprintf(temp_string, sizeof(temp_string), ":SG %+03d#", (int)hours);
866 
867  /*IDLog("UTC string is %s\n", temp_string);*/
868 
869  return (setStandardProcedure(fd, temp_string));
870 }
871 
872 int setSiteLongitude(int fd, double Long)
873 {
874  int d, m, s;
875  char temp_string[32];
876 
877  getSexComponents(Long, &d, &m, &s);
878 
879  snprintf(temp_string, sizeof(temp_string), ":Sg%03d:%02d#", d, m);
880 
881  return (setStandardProcedure(fd, temp_string));
882 }
883 
884 int setSiteLatitude(int fd, double Lat)
885 {
886  int d, m, s;
887  char temp_string[32];
888 
889  getSexComponents(Lat, &d, &m, &s);
890 
891  snprintf(temp_string, sizeof(temp_string), ":St%+03d:%02d:%02d#", d, m, s);
892 
893  return (setStandardProcedure(fd, temp_string));
894 }
895 
896 int setObjAz(int fd, double az)
897 {
898  int d, m, s;
899  char temp_string[16];
900 
901  getSexComponents(az, &d, &m, &s);
902 
903  snprintf(temp_string, sizeof(temp_string), ":Sz%03d:%02d#", d, m);
904 
905  return (setStandardProcedure(fd, temp_string));
906 }
907 
908 int setObjAlt(int fd, double alt)
909 {
910  int d, m, s;
911  char temp_string[16];
912 
913  getSexComponents(alt, &d, &m, &s);
914 
915  snprintf(temp_string, sizeof(temp_string), ":Sa%+02d*%02d#", d, m);
916 
917  return (setStandardProcedure(fd, temp_string));
918 }
919 
920 int setSiteName(int fd, char *siteName, int siteNum)
921 {
922  char temp_string[16];
923 
924  switch (siteNum)
925  {
926  case 1:
927  snprintf(temp_string, sizeof(temp_string), ":SM %s#", siteName);
928  break;
929  case 2:
930  snprintf(temp_string, sizeof(temp_string), ":SN %s#", siteName);
931  break;
932  case 3:
933  snprintf(temp_string, sizeof(temp_string), ":SO %s#", siteName);
934  break;
935  case 4:
936  snprintf(temp_string, sizeof(temp_string), ":SP %s#", siteName);
937  break;
938  default:
939  return -1;
940  }
941 
942  return (setStandardProcedure(fd, temp_string));
943 }
944 
945 int setSlewMode(int fd, int slewMode)
946 {
947  int error_type;
948  int nbytes_write = 0;
949 
950  switch (slewMode)
951  {
952  case IEQ45_SLEW_MAX:
953  if ((error_type = tty_write_string(fd, ":RS#", &nbytes_write)) != TTY_OK)
954  return error_type;
955  /*if (portWrite(":RS#") < 0)
956  return -1;*/
957  break;
958  case IEQ45_SLEW_FIND:
959  if ((error_type = tty_write_string(fd, ":RM#", &nbytes_write)) != TTY_OK)
960  return error_type;
961  /*if (portWrite(":RM#") < 0)
962  return -1;*/
963  break;
964  case IEQ45_SLEW_CENTER:
965  if ((error_type = tty_write_string(fd, ":RC#", &nbytes_write)) != TTY_OK)
966  return error_type;
967  /*if (portWrite(":RC#") < 0)
968  return -1;*/
969  break;
970  case IEQ45_SLEW_GUIDE:
971  if ((error_type = tty_write_string(fd, ":RG#", &nbytes_write)) != TTY_OK)
972  return error_type;
973  /*if (portWrite(":RG#") < 0)
974  return -1;*/
975  break;
976  default:
977  break;
978  }
979 
980  tcflush(fd, TCIFLUSH);
981  return 0;
982 }
983 
984 int setFocuserMotion(int fd, int motionType)
985 {
986  int error_type;
987  int nbytes_write = 0;
988 
989  switch (motionType)
990  {
991  case IEQ45_FOCUSIN:
992  if ((error_type = tty_write_string(fd, ":F+#", &nbytes_write)) != TTY_OK)
993  return error_type;
994 #ifdef INDI_DEBUG
995 /*IDLog("Focus IN Command\n");*/
996 #endif
997  /*if (portWrite(":F+#") < 0)
998  return -1;*/
999  break;
1000  case IEQ45_FOCUSOUT:
1001  if ((error_type = tty_write_string(fd, ":F-#", &nbytes_write)) != TTY_OK)
1002  return error_type;
1003 #ifdef INDI_DEBUG
1004 /*IDLog("Focus OUT Command\n");*/
1005 #endif
1006  /*if (portWrite(":F-#") < 0)
1007  return -1;*/
1008  break;
1009  }
1010 
1011  tcflush(fd, TCIFLUSH);
1012  return 0;
1013 }
1014 
1015 int setFocuserSpeedMode(int fd, int speedMode)
1016 {
1017  int error_type;
1018  int nbytes_write = 0;
1019 
1020  switch (speedMode)
1021  {
1022  case IEQ45_HALTFOCUS:
1023  if ((error_type = tty_write_string(fd, ":FQ#", &nbytes_write)) != TTY_OK)
1024  return error_type;
1025 #ifdef INDI_DEBUG
1026 /*IDLog("Halt Focus Command\n");*/
1027 #endif
1028  /* if (portWrite(":FQ#") < 0)
1029  return -1;*/
1030  break;
1031  case IEQ45_FOCUSSLOW:
1032  if ((error_type = tty_write_string(fd, ":FS#", &nbytes_write)) != TTY_OK)
1033  return error_type;
1034 #ifdef INDI_DEBUG
1035 /*IDLog("Focus Slow (FS) Command\n");*/
1036 #endif
1037  /*if (portWrite(":FS#") < 0)
1038  return -1;*/
1039  break;
1040  case IEQ45_FOCUSFAST:
1041  if ((error_type = tty_write_string(fd, ":FF#", &nbytes_write)) != TTY_OK)
1042  return error_type;
1043 #ifdef INDI_DEBUG
1044 /*IDLog("Focus Fast (FF) Command\n");*/
1045 #endif
1046  /*if (portWrite(":FF#") < 0)
1047  return -1;*/
1048  break;
1049  }
1050 
1051  tcflush(fd, TCIFLUSH);
1052  return 0;
1053 }
1054 
1055 int setGPSFocuserSpeed(int fd, int speed)
1056 {
1057  char speed_str[8];
1058  int error_type;
1059  int nbytes_write = 0;
1060 
1061  if (speed == 0)
1062  {
1063  /*if (portWrite(":FQ#") < 0)
1064  return -1;*/
1065  if ((error_type = tty_write_string(fd, ":FQ#", &nbytes_write)) != TTY_OK)
1066  return error_type;
1067 #ifdef INDI_DEBUG
1068 /*IDLog("GPS Focus HALT Command (FQ) \n");*/
1069 #endif
1070 
1071  return 0;
1072  }
1073 
1074  snprintf(speed_str, 8, ":F%d#", speed);
1075 
1076  if ((error_type = tty_write_string(fd, speed_str, &nbytes_write)) != TTY_OK)
1077  return error_type;
1078 
1079 #ifdef INDI_DEBUG
1080 /*IDLog("GPS Focus Speed command %s \n", speed_str);*/
1081 #endif
1082  /*if (portWrite(speed_str) < 0)
1083  return -1;*/
1084 
1085  tcflush(fd, TCIFLUSH);
1086  return 0;
1087 }
1088 
1089 int setTrackFreq(int fd, double trackF)
1090 {
1091  char temp_string[16];
1092 
1093  snprintf(temp_string, sizeof(temp_string), ":ST %04.1f#", trackF);
1094 
1095  return (setStandardProcedure(fd, temp_string));
1096 }
1097 
1098 /**********************************************************************
1099 * Misc
1100 *********************************************************************/
1101 
1102 int Slew(int fd)
1103 {
1104  char slewNum[2];
1105  int error_type;
1106  int nbytes_write = 0, nbytes_read = 0;
1107 
1108  if ((error_type = tty_write_string(fd, ":MS#", &nbytes_write)) != TTY_OK)
1109  return error_type;
1110 
1111  error_type = tty_read(fd, slewNum, 1, IEQ45_TIMEOUT, &nbytes_read);
1112 
1113  if (nbytes_read < 1)
1114  return error_type;
1115 
1116  /* We don't need to read the string message, just return corresponding error code */
1117  tcflush(fd, TCIFLUSH);
1118 
1119  if (slewNum[0] == '0')
1120  return 0;
1121  else if (slewNum[0] == '1')
1122  return 1;
1123  else
1124  return 2;
1125 }
1126 
1127 int MoveTo(int fd, int direction)
1128 {
1129  int nbytes_write = 0;
1130 
1131  switch (direction)
1132  {
1133  case IEQ45_NORTH:
1134  tty_write_string(fd, ":Mn#", &nbytes_write);
1135  /*portWrite(":Mn#");*/
1136  break;
1137  case IEQ45_WEST:
1138  tty_write_string(fd, ":Mw#", &nbytes_write);
1139  /*portWrite(":Mw#");*/
1140  break;
1141  case IEQ45_EAST:
1142  tty_write_string(fd, ":Me#", &nbytes_write);
1143  /*portWrite(":Me#");*/
1144  break;
1145  case IEQ45_SOUTH:
1146  tty_write_string(fd, ":Ms#", &nbytes_write);
1147  /*portWrite(":Ms#");*/
1148  break;
1149  default:
1150  break;
1151  }
1152 
1153  tcflush(fd, TCIFLUSH);
1154  return 0;
1155 }
1156 
1157 int SendPulseCmd(int fd, int direction, int duration_msec)
1158 {
1159  int nbytes_write = 0;
1160  char cmd[20];
1161  switch (direction)
1162  {
1163  case IEQ45_NORTH:
1164  sprintf(cmd, ":Mgn%04d#", duration_msec);
1165  break;
1166  case IEQ45_SOUTH:
1167  sprintf(cmd, ":Mgs%04d#", duration_msec);
1168  break;
1169  case IEQ45_EAST:
1170  sprintf(cmd, ":Mge%04d#", duration_msec);
1171  break;
1172  case IEQ45_WEST:
1173  sprintf(cmd, ":Mgw%04d#", duration_msec);
1174  break;
1175  default:
1176  return 1;
1177  }
1178 
1179  tty_write_string(fd, cmd, &nbytes_write);
1180 
1181  tcflush(fd, TCIFLUSH);
1182  return 0;
1183 }
1184 
1185 int HaltMovement(int fd, int direction)
1186 {
1187  int error_type;
1188  int nbytes_write = 0;
1189 
1190  switch (direction)
1191  {
1192  case IEQ45_NORTH:
1193  /*if (portWrite(":Qn#") < 0)
1194  return -1;*/
1195  if ((error_type = tty_write_string(fd, ":Qn#", &nbytes_write)) != TTY_OK)
1196  return error_type;
1197  break;
1198  case IEQ45_WEST:
1199  /*if (portWrite(":Qw#") < 0)
1200  return -1;*/
1201  if ((error_type = tty_write_string(fd, ":Qw#", &nbytes_write)) != TTY_OK)
1202  return error_type;
1203  break;
1204  case IEQ45_EAST:
1205  /*if (portWrite(":Qe#") < 0)
1206  return -1;*/
1207  if ((error_type = tty_write_string(fd, ":Qe#", &nbytes_write)) != TTY_OK)
1208  return error_type;
1209  break;
1210  case IEQ45_SOUTH:
1211  if ((error_type = tty_write_string(fd, ":Qs#", &nbytes_write)) != TTY_OK)
1212  return error_type;
1213  /*if (portWrite(":Qs#") < 0)
1214  return -1;*/
1215  break;
1216  case IEQ45_ALL:
1217  /*if (portWrite(":Q#") < 0)
1218  return -1;*/
1219  if ((error_type = tty_write_string(fd, ":Q#", &nbytes_write)) != TTY_OK)
1220  return error_type;
1221  break;
1222  default:
1223  return -1;
1224  break;
1225  }
1226 
1227  tcflush(fd, TCIFLUSH);
1228  return 0;
1229 }
1230 
1231 int abortSlew(int fd)
1232 {
1233  /*if (portWrite(":Q#") < 0)
1234  return -1;*/
1235  int error_type;
1236  int nbytes_write = 0;
1237 
1238  if ((error_type = tty_write_string(fd, ":Q#", &nbytes_write)) != TTY_OK)
1239  return error_type;
1240 
1241  tcflush(fd, TCIFLUSH);
1242  return 0;
1243 }
1244 
1245 int Sync(int fd, char *matchedObject)
1246 {
1247  int error_type;
1248  int nbytes_write = 0, nbytes_read = 0;
1249 
1250  // if ( (error_type = tty_write_string(fd, ":CM#", &nbytes_write)) != TTY_OK)
1251  if ((error_type = tty_write_string(fd, ":CMR#", &nbytes_write)) != TTY_OK)
1252  return error_type;
1253 
1254  /*portWrite(":CM#");*/
1255 
1256  /*read_ret = portRead(matchedObject, -1, IEQ45_TIMEOUT);*/
1257  error_type = tty_read_section(fd, matchedObject, '#', IEQ45_TIMEOUT, &nbytes_read);
1258 
1259  if (nbytes_read < 1)
1260  return error_type;
1261 
1262  matchedObject[nbytes_read - 1] = '\0';
1263 
1264  /*IDLog("Matched Object: %s\n", matchedObject);*/
1265 
1266  /* Sleep 10ms before flushing. This solves some issues with IEQ45 compatible devices. */
1267  usleep(10000);
1268  tcflush(fd, TCIFLUSH);
1269 
1270  return 0;
1271 }
1272 
1273 int selectSite(int fd, int siteNum)
1274 {
1275  int error_type;
1276  int nbytes_write = 0;
1277 
1278  switch (siteNum)
1279  {
1280  case 1:
1281  if ((error_type = tty_write_string(fd, ":W1#", &nbytes_write)) != TTY_OK)
1282  return error_type;
1283  /*if (portWrite(":W1#") < 0)
1284  return -1;*/
1285  break;
1286  case 2:
1287  if ((error_type = tty_write_string(fd, ":W2#", &nbytes_write)) != TTY_OK)
1288  return error_type;
1289  /*if (portWrite(":W2#") < 0)
1290  return -1;*/
1291  break;
1292  case 3:
1293  if ((error_type = tty_write_string(fd, ":W3#", &nbytes_write)) != TTY_OK)
1294  return error_type;
1295  /*if (portWrite(":W3#") < 0)
1296  return -1;*/
1297  break;
1298  case 4:
1299  if ((error_type = tty_write_string(fd, ":W4#", &nbytes_write)) != TTY_OK)
1300  return error_type;
1301  /*if (portWrite(":W4#") < 0)
1302  return -1;*/
1303  break;
1304  default:
1305  return -1;
1306  break;
1307  }
1308 
1309  tcflush(fd, TCIFLUSH);
1310  return 0;
1311 }
1312 
1313 int selectCatalogObject(int fd, int catalog, int NNNN)
1314 {
1315  char temp_string[16];
1316  int error_type;
1317  int nbytes_write = 0;
1318 
1319  switch (catalog)
1320  {
1321  case IEQ45_STAR_C:
1322  snprintf(temp_string, sizeof(temp_string), ":LS%d#", NNNN);
1323  break;
1324  case IEQ45_DEEPSKY_C:
1325  snprintf(temp_string, sizeof(temp_string), ":LC%d#", NNNN);
1326  break;
1327  case IEQ45_MESSIER_C:
1328  snprintf(temp_string, sizeof(temp_string), ":LM%d#", NNNN);
1329  break;
1330  default:
1331  return -1;
1332  }
1333 
1334  if ((error_type = tty_write_string(fd, temp_string, &nbytes_write)) != TTY_OK)
1335  return error_type;
1336  /*if (portWrite(temp_string) < 0)
1337  return -1;*/
1338 
1339  tcflush(fd, TCIFLUSH);
1340  return 0;
1341 }
1342 
1343 int selectSubCatalog(int fd, int catalog, int subCatalog)
1344 {
1345  char temp_string[16];
1346  switch (catalog)
1347  {
1348  case IEQ45_STAR_C:
1349  snprintf(temp_string, sizeof(temp_string), ":LsD%d#", subCatalog);
1350  break;
1351  case IEQ45_DEEPSKY_C:
1352  snprintf(temp_string, sizeof(temp_string), ":LoD%d#", subCatalog);
1353  break;
1354  case IEQ45_MESSIER_C:
1355  return 1;
1356  default:
1357  return 0;
1358  }
1359 
1360  return (setStandardProcedure(fd, temp_string));
1361 }
1362 
1364 {
1365  char temp_string[16];
1367  int error_type;
1368  int nbytes_write = 0, nbytes_read = 0;
1369 
1370  if ((error_type = tty_write_string(fd, ":GR#", &nbytes_write)) != TTY_OK)
1371  return error_type;
1372 
1373  /*if (portWrite(":GR#") < 0)
1374  return -1;*/
1375 
1376  /*read_ret = portRead(temp_string, -1, IEQ45_TIMEOUT);*/
1377  error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
1378 
1379  if (nbytes_read < 1)
1380  return error_type;
1381 
1382  temp_string[nbytes_read - 1] = '\0';
1383 
1384  /* Check whether it's short or long */
1385  if (temp_string[5] == '.')
1386  {
1388  return 0;
1389  }
1390  else
1391  return 0;
1392 }
1393 
1394 int selectTrackingMode(int fd, int trackMode)
1395 {
1396  int error_type;
1397  int nbytes_write = 0;
1398 
1399  switch (trackMode)
1400  {
1401  case IEQ45_TRACK_SIDERAL:
1402 #ifdef INDI_DEBUG
1403  IDLog("Setting tracking mode to sidereal.\n");
1404 #endif
1405  if ((error_type = tty_write_string(fd, ":RT2#", &nbytes_write)) != TTY_OK)
1406  return error_type;
1407  /*if (portWrite(":TQ#") < 0)
1408  return -1;*/
1409  break;
1410  case IEQ45_TRACK_LUNAR:
1411 #ifdef INDI_DEBUG
1412  IDLog("Setting tracking mode to LUNAR.\n");
1413 #endif
1414  if ((error_type = tty_write_string(fd, ":RT0#", &nbytes_write)) != TTY_OK)
1415  return error_type;
1416  /*if (portWrite(":TL#") < 0)
1417  return -1;*/
1418  break;
1419  case IEQ45_TRACK_SOLAR:
1420 #ifdef INDI_DEBUG
1421  IDLog("Setting tracking mode to SOLAR.\n");
1422 #endif
1423  if ((error_type = tty_write_string(fd, ":RT1#", &nbytes_write)) != TTY_OK)
1424  return error_type;
1425  /*if (portWrite(":TM#") < 0)
1426  return -1;*/
1427  break;
1428  case IEQ45_TRACK_ZERO:
1429 #ifdef INDI_DEBUG
1430  IDLog("Setting tracking mode to ZERO.\n");
1431 #endif
1432  if ((error_type = tty_write_string(fd, ":RT9#", &nbytes_write)) != TTY_OK)
1433  return error_type;
1434  /*if (portWrite(":TM#") < 0)
1435  return -1;*/
1436  break;
1437 
1438  default:
1439  return -1;
1440  break;
1441  }
1442 
1443  tcflush(fd, TCIFLUSH);
1444  return 0;
1445 }
double max(void)
double min(void)
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 controller_format
int SendPulseCmd(int fd, int direction, int duration_msec)
int abortSlew(int fd)
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 Slew(int fd)
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)
#define IEQ45_TIMEOUT
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)
@ IEQ45_FOCUSIN
Definition: ieq45driver.h:64
@ IEQ45_FOCUSOUT
Definition: ieq45driver.h:65
@ IEQ45_ALIGN_ALTAZ
Definition: ieq45driver.h:36
@ IEQ45_ALIGN_LAND
Definition: ieq45driver.h:37
@ IEQ45_ALIGN_POLAR
Definition: ieq45driver.h:35
@ IEQ45_DEEPSKY_C
Definition: ieq45driver.h:77
@ IEQ45_STAR_C
Definition: ieq45driver.h:76
@ IEQ45_FOCUSSLOW
Definition: ieq45driver.h:70
@ IEQ45_HALTFOCUS
Definition: ieq45driver.h:69
@ IEQ45_FOCUSFAST
Definition: ieq45driver.h:71
@ IEQ45_TRACK_ZERO
Definition: ieq45driver.h:103
@ IEQ45_TRACK_LUNAR
Definition: ieq45driver.h:101
@ IEQ45_TRACK_SIDERAL
Definition: ieq45driver.h:100
@ IEQ45_TRACK_SOLAR
Definition: ieq45driver.h:102
@ IEQ45_EAST
Definition: ieq45driver.h:44
@ IEQ45_SOUTH
Definition: ieq45driver.h:45
@ IEQ45_WEST
Definition: ieq45driver.h:43
@ IEQ45_NORTH
Definition: ieq45driver.h:42
@ IEQ45_ALL
Definition: ieq45driver.h:46
@ IEQ45_MESSIER_C
Definition: ieq45driver.h:95
@ IEQ45_SLEW_GUIDE
Definition: ieq45driver.h:30
@ IEQ45_SLEW_FIND
Definition: ieq45driver.h:28
@ IEQ45_SLEW_CENTER
Definition: ieq45driver.h:29
@ IEQ45_SLEW_MAX
Definition: ieq45driver.h:27
@ IEQ45_LONG_FORMAT
Definition: ieq45driver.h:52
@ IEQ45_SHORT_FORMAT
Definition: ieq45driver.h:51
double ra
double dec
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
Definition: indicom.c:566
int f_scansexa(const char *str0, double *dp)
convert sexagesimal string str AxBxC to double. x can be anything non-numeric. Any missing A,...
Definition: indicom.c:205
void IDLog(const char *fmt,...)
Definition: indicom.c:316
void getSexComponents(double value, int *d, int *m, int *s)
Definition: indicom.c:254
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
Definition: indicom.c:482
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
Definition: indicom.c:474
Implementations for common driver routines.
@ TTY_OK
Definition: indicom.h:150
Interface to the reference INDI C API device implementation on the Device Driver side.
int fd
Definition: intelliscope.c:43
__u8 cmd[4]
Definition: pwc-ioctl.h:2