3 Copyright (C) 2011 Onno Hommes (ohommes@alumni.cmu.edu)
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.
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.
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
70 IDLog(
"Testing telescope's connection...\n");
78 if (write(
fd, ack, 4) < 0)
89 tcflush(
fd, TCIFLUSH);
100 char ack[4] =
":S?#";
112 if (write(
fd, ack, 4) >= 0)
118 if (nbytes_read == 2)
129 tcflush(
fd, TCIFLUSH);
135 char temp_string[16];
137 int nbytes_write = 0, nbytes_read = 0;
143 temp_string[nbytes_read - 1] =
'\0';
148 IDLog(
"unable to process [%s]\n", temp_string);
158 tcflush(
fd, TCIFLUSH);
164 int nbytes_write = 0, nbytes_read = 0;
171 data[nbytes_read - 1] =
'\0';
176 tcflush(
fd, TCIFLUSH);
189 if ((sscanf(date,
"%d%*c%d%*c%d", &mm, &dd, &yy)) > 2)
194 strncpy(century,
"19", 3);
196 strncpy(century,
"20", 3);
199 snprintf(date, 16,
"%s%02d/%02d/%02d", century, yy, mm, dd);
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,...)
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.
int getCommandString(int fd, char *data, const char *cmd)
int check_magellan_connection(int fd)
int getCommandSexa(int fd, double *value, const char *cmd)
int getCalendarDate(int fd, char *date)
#define CONNECTION_RETRIES
#define CENTURY_THRESHOLD