2
Intelliscope INDI driver
3
Copyright (C) 2005 Douglas Philipson (dougp AT intermind DOT net)
5
Based on code by Jasem Mutlaq (mutlaqja@ikarustech.com)
7
This library is free software; you can redistribute it and/or
8
modify it under the terms of the GNU Lesser General Public
9
License as published by the Free Software Foundation; either
10
version 2.1 of the License, or (at your option) any later version.
12
This library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Lesser General Public License for more details.
17
You should have received a copy of the GNU Lesser General Public
18
License along with this library; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33
#include "indidevapi.h"
35
#include "lx200driver.h"
37
#define mydev "Intelliscope"
38
#define BASIC_GROUP "Main Control"
40
#define currentRA eq[0].value
41
#define currentDEC eq[1].value
43
static void ISPoll(void *);
44
static void ISInit(void);
45
static void connectTelescope(void);
49
static ISwitch PowerS[] = {{"CONNECT" , "Connect" , ISS_OFF, 0, 0},{"DISCONNECT", "Disconnect", ISS_ON, 0, 0}};
50
ISwitchVectorProperty PowerSP = { mydev, "CONNECTION" , "Connection", BASIC_GROUP, IP_RW, ISR_1OFMANY, 0, IPS_IDLE, PowerS, NARRAY(PowerS), "", 0};
52
static IText PortT[] = {{"PORT", "Port", 0, 0, 0, 0}};
53
static ITextVectorProperty PortTP = { mydev, "DEVICE_PORT", "Ports", BASIC_GROUP, IP_RW, 0, IPS_IDLE, PortT, NARRAY(PortT), "", 0};
55
/* equatorial position */
57
{"RA", "RA H:M:S", "%10.6m", 0., 24., 0., 0., 0, 0, 0},
58
{"DEC", "Dec D:M:S", "%10.6m", -90., 90., 0., 0., 0, 0, 0},
60
INumberVectorProperty eqNum = {
61
mydev, "EQUATORIAL_EOD_COORD", "Equatorial JNow", BASIC_GROUP, IP_RO, 0, IPS_IDLE,
62
eq, NARRAY(eq), "", 0};
74
IEAddTimer (POLLMS, ISPoll, NULL);
78
void ISGetProperties (const char *dev)
85
IDDefSwitch(&PowerSP, NULL);
86
IDDefText(&PortTP, NULL);
87
IDDefNumber(&eqNum, NULL);
90
void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
96
if (!strcmp(name, PowerSP.name))
98
IUResetSwitch(&PowerSP);
99
IUUpdateSwitch(&PowerSP, states, names, n);
105
void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
110
dev=dev; names=names; n=n;
112
if (!strcmp(name, PortTP.name))
114
IUSaveText(&PortT[0], texts[0]);
116
IDSetText(&PortTP, NULL);
121
void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
123
dev=dev;name=name;values=values;names=names;n=n;
126
void ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
131
INDI_UNUSED(blobsizes);
133
INDI_UNUSED(formats);
137
void ISSnoopDevice (XMLEle *root)
142
void ISPoll (void *p)
146
if (PowerS[0].s == ISS_ON)
153
if (updateIntelliscopeCoord(fd, ¤tRA, ¤tDEC) < 0)
156
IDSetNumber(&eqNum, "Unknown error while reading telescope coordinates");
157
IDLog("Unknown error while reading telescope coordinates\n");
161
IDSetNumber(&eqNum, NULL);
169
IEAddTimer(POLLMS, ISPoll, NULL);
172
void connectTelescope(void)
178
if (tty_connect(PortT[0].text, 9600, 8, 0, 1, &fd) != TTY_OK)
180
PowerSP.s = IPS_ALERT;
181
IUResetSwitch(&PowerSP);
182
IDSetSwitch(&PowerSP, "Error connecting to port %s", PortT[0].text);
187
IDSetSwitch(&PowerSP, "Intelliscope is online.");
192
IUResetSwitch(&PowerSP);
193
eqNum.s = PortTP.s = PowerSP.s = IPS_IDLE;
194
IDSetSwitch(&PowerSP, "Intelliscope is offline.");
195
IDSetText(&PortTP, NULL);
196
IDSetNumber(&eqNum, NULL);