Index: ORadio/libindi/libindi/BAOControl/Socket.h
===================================================================
--- /BAORadio/libindi/libindi/BAOControl/Socket.h	(revision 645)
+++ 	(revision )
@@ -1,62 +1,0 @@
-// Definition of the Socket class
-
-#ifndef Socket_class
-#define Socket_class
-
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <string>
-#include <arpa/inet.h>
-#include <iostream>
-#include "stdio.h"
-
-
-const int MAXHOSTNAME = 1000;
-const int MAXCONNECTIONS = 5;
-const int MAXRECV = 5000;
-
-
-
-class Socket
-{
- public:
-  Socket();
-  virtual ~Socket();
-
-
-  // Server initialization
-  bool create();
-  bool bind ( const int port );
-  bool listen() const;
-  bool accept ( Socket& ) const;
-
-  // Client initialization
-  bool connect ( const std::string host, const int port );
-
-  // Data Transimission
-  bool send ( const std::string ) const;
-  int recv ( std::string& ) const;
-
-
-  void set_non_blocking ( const bool );
-
-  bool is_valid() const { return m_sock != -1; }
-
-  bool shutdown();
-
- private:
-
-  int m_sock;
-  sockaddr_in m_addr;
-
-
-
-
-};
-
-
-#endif
Index: ORadio/libindi/libindi/BAOControl/result
===================================================================
--- /BAORadio/libindi/libindi/BAOControl/result	(revision 645)
+++ 	(revision )
@@ -1,27 +1,0 @@
-
-
-Results from query to  NASA/IPAC Extragalactic Database (NED),
-which is operated by the Jet Propulsion Laboratory, California Institute of
-Technology, under contract with the National Aeronautics and Space Administration.
-This work was (partially) supported by the US National Virtual Observatory
-development project, which is funded by the National Science Foundation
-under cooperative agreement AST0122449 with The Johns Hopkins University.
-
-
-
-queryDateTime:2011-12-04T07:23:36PST
-
-
-
-Main Information Table for MESSIER 031
-
-
-
-Equinox:J2000.0
-
-
-
-CoordSystem:Equatorial
-
-No.|Object Name|RA(deg)|DEC(deg)|Type|Velocity|Redshift|Redshift Flag|Magnitude and Filter|Distance (arcmin)|References|Notes|Photometry Points|Positions|Redshift Points|Diameter Points|Associations
-1|MESSIER 031| 10.68479 |  41.26906 |G|  -300|-0.001001 |    | 4.36||3357|17|132|8|26|7|0
Index: ORadio/libindi/libindi/BAOTest/ClientSocket.cpp
===================================================================
--- /BAORadio/libindi/libindi/BAOTest/ClientSocket.cpp	(revision 645)
+++ 	(revision )
@@ -1,64 +1,0 @@
-// Implementation of the ClientSocket class
-
-#include "ClientSocket.h"
-#include "SocketException.h"
-
-
-#include <iostream>
-#include <string>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-
-ClientSocket::ClientSocket ( std::string host, int port )
-{
-  if ( ! Socket::create() )
-    {
-      throw SocketException ( "Could not create client socket." );
-    }
-
-  if ( ! Socket::connect ( host, port ) )
-    {
-      throw SocketException ( "Could not bind to port." );
-    }
-}
-
-
-const ClientSocket& ClientSocket::operator << ( const std::string& s ) const
-{
-  if ( ! Socket::send ( s ) )
-    {
-     // throw SocketException ( "Could not write to socket." );
-    }
-
-  return *this;
-
-}
-
-
-const ClientSocket& ClientSocket::operator >> ( std::string& s ) const
-{
-  if ( ! Socket::recv ( s ) )
-    {
-    //   throw SocketException ( "Could not read from socket." );
-    }
-
-  return *this;
-}
-
-
-void ClientSocket::recv( std::string& s ) 
-{
-  if ( ! Socket::recv ( s ) )
-    {
-      sleep(1);
-
-      if (! Socket::shutdown() ) std::cout << "shutdown impossible.\n";
-
-      if (! Socket::create() ) std::cout << "create impossible.\n";
-
-      if (! Socket::connect((std::string)"192.168.0.1", 8000)) { std::cout << "connect impossible.\n"; Socket::shutdown(); } else {   std::cout << "Reconnexion reussie.\n"; }
-    }
-}
-
Index: ORadio/libindi/libindi/BAOTest/ClientSocket.h
===================================================================
--- /BAORadio/libindi/libindi/BAOTest/ClientSocket.h	(revision 645)
+++ 	(revision )
@@ -1,28 +1,0 @@
-// Definition of the ClientSocket class
-
-#ifndef ClientSocket_class
-#define ClientSocket_class
-
-#include "Socket.h"
-
-struct Position
-{
-   int x;
-   int y;
-};
-
-class ClientSocket : private Socket
-{
- public:
-
-  ClientSocket ( std::string host, int port );
-  virtual ~ClientSocket(){};
-
-  const ClientSocket& operator << ( const std::string& ) const;
-  const ClientSocket& operator >> ( std::string& ) const;
-
-void recv( std::string& s ); 
-};
-
-
-#endif
Index: ORadio/libindi/libindi/BAOTest/ServerSocket.cpp
===================================================================
--- /BAORadio/libindi/libindi/BAOTest/ServerSocket.cpp	(revision 645)
+++ 	(revision )
@@ -1,67 +1,0 @@
-// Implementation of the ServerSocket class
-
-#include "ServerSocket.h"
-#include "SocketException.h"
-
-
-ServerSocket::ServerSocket ( int port )
-{
-  if ( ! Socket::create() )
-    {
-      throw SocketException ( "Could not create server socket." );
-    }
-
-  if ( ! Socket::bind ( port ) )
-    {
-      throw SocketException ( "Could not bind to port." );
-    }
-
-  if ( ! Socket::listen() )
-    {
-      throw SocketException ( "Could not listen to socket." );
-    }
-//Socket::set_non_blocking(true);
-}
-
-ServerSocket::~ServerSocket()
-{
-}
-
-
-const ServerSocket& ServerSocket::operator << ( const std::string& s ) const
-{
-  if ( ! Socket::send ( s ) )
-    {
-      throw SocketException ( "Could not write to socket." );
-    }
-
-  return *this;
-
-}
-
-
-const ServerSocket& ServerSocket::operator >> ( std::string& s ) const
-{
-  if ( ! Socket::recv ( s ) )
-    {
-     throw SocketException ( "Could not read from socket." );
-    }
-
-  return *this;
-}
-
-void ServerSocket::accept ( ServerSocket& sock )
-{
-  if ( ! Socket::accept ( sock ) )
-    {
-      throw SocketException ( "Could not accept socket." );
-    }
-}
-
-void ServerSocket::recv( std::string& s ) 
-{
-  if ( ! Socket::recv ( s ) )
-    {
-    throw SocketException ( "Could  not read from socket." );
-    }
-}
Index: ORadio/libindi/libindi/BAOTest/ServerSocket.h
===================================================================
--- /BAORadio/libindi/libindi/BAOTest/ServerSocket.h	(revision 645)
+++ 	(revision )
@@ -1,27 +1,0 @@
-// Definition of the ServerSocket class
-
-#ifndef ServerSocket_class
-#define ServerSocket_class
-
-#include "Socket.h"
-
-
-class ServerSocket : private Socket
-{
- public:
-
-  ServerSocket ( int port );
-  ServerSocket (){};
-  virtual ~ServerSocket();
-
-  const ServerSocket& operator << ( const std::string& ) const;
-  const ServerSocket& operator >> ( std::string& ) const;
-
-  void recv( std::string& s );
-
-  void accept ( ServerSocket& );
-
-};
-
-
-#endif
Index: ORadio/libindi/libindi/BAOTest/Socket.cpp
===================================================================
--- /BAORadio/libindi/libindi/BAOTest/Socket.cpp	(revision 645)
+++ 	(revision )
@@ -1,226 +1,0 @@
-// Implementation of the Socket class.
-
-
-#include "Socket.h"
-#include "string.h"
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <iostream>
-#include <netinet/tcp.h>
-
-
-
-
-
-Socket::Socket() :
-        m_sock ( -1 )
-{
-
-    memset ( &m_addr,
-             0,
-             sizeof ( m_addr ) );
-
-}
-
-Socket::~Socket()
-{
-    if ( is_valid() )
-        ::close ( m_sock );
-}
-
-bool Socket::create()
-{
-    m_sock = socket ( AF_INET,
-                      SOCK_STREAM,
-                      0); //IPPROTO_TCP
-
-    if ( ! is_valid() )
-        return false;
-
-
-   //  TIME_WAIT - argh
-    int on = 1;
-
-    if ( setsockopt ( m_sock, SOL_SOCKET, SO_REUSEADDR, ( const char* ) &on, sizeof ( on ) ) == -1 ) return false;
-
-    if (setsockopt(m_sock, SOL_TCP, TCP_NODELAY, (const char*) &on, sizeof(on)) <0) return false;
-
-    return true;
-}
-
-
-bool Socket::shutdown()
-{
-  int ret = 0;
-
-  if ( is_valid() )
-      ret =  ::shutdown ( m_sock, 2 );
-  
-  m_sock=-1;
-
-  if ( ret == 0 ) return true;
-
-  return false;
-}
-
-
-bool Socket::bind ( const int port )
-{
-    if ( ! is_valid() ) return false;
-    
-    m_addr.sin_family = AF_INET;
-    m_addr.sin_addr.s_addr = INADDR_ANY;
-    m_addr.sin_port =  htons ( port );
-
-    int bind_return = ::bind ( m_sock,
-                               ( struct sockaddr * ) &m_addr,
-                               sizeof ( m_addr ) );
-
-
-    if ( bind_return == -1 ) return false;
-    
-    return true;
-}
-
-
-bool Socket::listen() const
-{
-    if ( ! is_valid() ) return false;
-    
-    int listen_return = ::listen ( m_sock, MAXCONNECTIONS );
-
-    if ( listen_return == -1 ) return false;
-    
-    return true;
-}
-
-
-bool Socket::accept ( Socket& new_socket ) const
-{
-    int addr_length = sizeof ( m_addr );
-    
-    new_socket.m_sock = ::accept ( m_sock, ( sockaddr * ) &m_addr, ( socklen_t * ) &addr_length );
-
-    if ( new_socket.m_sock <= 0 ) return false;
-        
-    return true;
-}
-
-
-bool Socket::send ( const std::string s ) const
-{
-    int status = ::send ( m_sock, s.c_str(), s.size(), MSG_NOSIGNAL);
-    
-    if ( status == -1 ) return false;
-        
-    return true;    
-}
-
-
-int Socket::recv ( std::string& s ) const
-{
-    int sel;
-    fd_set r;
-    struct timeval timeout;
-
-    if ( ! is_valid() ) return false;
-    
-    s="";
-
-    timeout.tv_sec = 0; // initialise le timeout, ici  les secondes
-    timeout.tv_usec = 1; // les microsecondes
-
-    FD_ZERO(&r); // initialise la liste de fd
-    FD_SET(m_sock, &r); // ajoute la socket dans la liste des fd
-    sel = select(m_sock + 1, &r, NULL, NULL, &timeout);
-    if (sel < 0) // select a rencontrÃ© un problÃšme
-    {
-        return -1;
-    }
-    else if (sel == 0) // timeout
-    {
-	return 1;
-    }
-    else // quelque chose est Ã  lire sur un file descriptor
-    {
-        if (FD_ISSET(m_sock, &r)) // si la socket est prÃªte Ã  Ãªtre lue
-        {
-            char buf [ MAXRECV + 1 ];
-
-            s = "";
-
-            memset ( buf, 0, MAXRECV + 1 );
-
-            int status = ::recv ( m_sock, buf, MAXRECV, 0 );
-
-            if ( status == -1 )
-            {
-	         // lÃ , nous ne sommes pas en prÃ©sence d'une vraie erreur
-		 // car le mode non-bloquant est activÃ© ici
-		 // (consulter la doc de la fct recv...)
-                 if (errno == EAGAIN )
-		 {
-	           return 0;
-		 }
-		 
-		 return -1;
-            }
-            else if ( status == 0 )
-            {
-                return 0;
-            }
-            else
-            {
-                s = buf;
-                return status;
-            }
-        }
-    }
-}
-
-
-
-bool Socket::connect ( const std::string host, const int port )
-{
-    if ( ! is_valid() ) return false;
-
-    memset ( &m_addr,
-             0,
-             sizeof ( m_addr ) );
-
-    m_addr.sin_family = AF_INET;
-    m_addr.sin_port = htons ( port );
-
-    int status = inet_pton ( AF_INET, host.c_str(), &m_addr.sin_addr );
-
-    if ( errno == EAFNOSUPPORT ) return false;
-
-
-    status = ::connect ( m_sock, ( sockaddr * ) &m_addr, sizeof ( m_addr ) );
-
-    if ( status == 0 ) return true;
-    
-    return false;
-}
-
-void Socket::set_non_blocking ( const bool b )
-{
-    int opts;
-
-    opts = fcntl ( m_sock,F_GETFL );
-
-    if ( opts < 0 )
-    {
-        return;
-    }
-
-    if ( b )
-        opts = ( opts | O_NONBLOCK );
-    else
-        opts = ( opts & ~O_NONBLOCK );
-
-    fcntl ( m_sock,
-            F_SETFL,opts );
-
-}
Index: ORadio/libindi/libindi/BAOTest/Socket.h
===================================================================
--- /BAORadio/libindi/libindi/BAOTest/Socket.h	(revision 645)
+++ 	(revision )
@@ -1,61 +1,0 @@
-// Definition of the Socket class
-
-#ifndef Socket_class
-#define Socket_class
-
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <string>
-#include <arpa/inet.h>
-#include <iostream>
-
-
-const int MAXHOSTNAME = 200;
-const int MAXCONNECTIONS = 5;
-const int MAXRECV = 5000;
-
-
-
-class Socket
-{
- public:
-  Socket();
-  virtual ~Socket();
-
-
-  // Server initialization
-  bool create();
-  bool bind ( const int port );
-  bool listen() const;
-  bool accept ( Socket& ) const;
-
-  // Client initialization
-  bool connect ( const std::string host, const int port );
-
-  // Data Transimission
-  bool send ( const std::string ) const;
-  int recv ( std::string& ) const;
-
-
-  void set_non_blocking ( const bool );
-
-  bool is_valid() const { return m_sock != -1; }
-
-  bool shutdown();
-
- private:
-
-  int m_sock;
-  sockaddr_in m_addr;
-
-
-
-
-};
-
-
-#endif
Index: ORadio/libindi/libindi/BAOTest/SocketException.h
===================================================================
--- /BAORadio/libindi/libindi/BAOTest/SocketException.h	(revision 645)
+++ 	(revision )
@@ -1,23 +1,0 @@
-// SocketException class
-
-
-#ifndef SocketException_class
-#define SocketException_class
-
-#include <string>
-
-class SocketException
-{
- public:
-  SocketException ( std::string s ) : m_s ( s ) {};
-  ~SocketException (){};
-
-  std::string description() { return m_s; }
-
- private:
-
-  std::string m_s;
-
-};
-
-#endif
Index: ORadio/libindi/libindi/BAOTest/simple_client_main.cpp
===================================================================
--- /BAORadio/libindi/libindi/BAOTest/simple_client_main.cpp	(revision 645)
+++ 	(revision )
@@ -1,42 +1,0 @@
-#include "ClientSocket.h"
-#include "SocketException.h"
-#include <iostream>
-#include <string>
-#include <stdio.h>
-
-int main ( int argc, int argv[] )
-{
-  try
-    {
-
-      ClientSocket client_socket ( "192.168.0.1", 8000 );
-
-      std::string reply;
-char chaine[20];
-int i=0;
-
-while(true)
-{
-i++;
-      try
-	{
-sprintf(chaine,"client %i-",i);
-	  client_socket << "Client : " << chaine << "\"\n";
-	  client_socket >> reply;
-	}
-      catch ( SocketException& e) {
-std::cout  << e.description() << "\n";
-break;
-}
-
-      std::cout <<  reply ;
-
-}
-    }
-  catch ( SocketException& e )
-    {
-      std::cout << "Exception was caught:" << e.description() << "\n";
-    }
-
-  return 0;
-}
Index: ORadio/libindi/libindi/BAOTest/simple_server_main.cpp
===================================================================
--- /BAORadio/libindi/libindi/BAOTest/simple_server_main.cpp	(revision 645)
+++ 	(revision )
@@ -1,40 +1,0 @@
-#include "ServerSocket.h"
-#include "SocketException.h"
-#include <string>
-
-int main ( int argc, int argv[] )
-{
-  std::cout << "running....\n";
-
-  try
-    {
-      // Create the socket
-      ServerSocket server ( 7624 );
-
-      while ( true )
-	{
-
-	  ServerSocket new_sock;
-	  server.accept ( new_sock );
-
-	  try
-	    {
-	      while ( true )
-		{
-		  std::string data;
-		  new_sock >> data;
-		  std::cout << data << "\n";
-		  new_sock << "du serveur\n";
-		}
-	    }
-	  catch ( SocketException& ) {}
-
-	}
-    }
-  catch ( SocketException& e )
-    {
-      std::cout << "Exception was caught:" << e.description() << "\nExiting.\n";
-    }
-
-  return 0;
-}
Index: /BAORadio/libindi/libindi/drivers/focuser/robofocus.cpp
===================================================================
--- /BAORadio/libindi/libindi/drivers/focuser/robofocus.cpp	(revision 646)
+++ /BAORadio/libindi/libindi/drivers/focuser/robofocus.cpp	(revision 646)
@@ -0,0 +1,1585 @@
+/*
+    RoboFocus
+    Copyright (C) 2006 Markus Wildi (markus.wildi@datacomm.ch)
+                  2011 Jasem Mutlaq (mutlaqja@ikarustech.com)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+*/
+
+#include "robofocus.h"
+#include "indicom.h"
+
+#include <termios.h>
+#include <string.h>
+#include <sys/time.h>
+
+#define RF_MAX_CMD   9
+#define RF_TIMEOUT   15
+#define RF_STEP_RES  5
+
+#define BACKLASH_READOUT 99999
+#define MAXTRAVEL_READOUT 99999
+
+#define currentSpeed            SpeedN[0].value
+#define currentPosition         PositionN[0].value
+#define currentTemperature      TemperatureN[0].value
+#define currentBacklash         SetBacklashN[0].value
+#define currentDuty             SettingsN[0].value
+#define currentDelay            SettingsN[1].value
+#define currentTicks            SettingsN[2].value
+#define currentRelativeMovement RelMovementN[0].value
+#define currentAbsoluteMovement AbsMovementN[0].value
+#define currentSetBacklash      SetBacklashN[0].value
+#define currentMinPosition      MinMaxPositionN[0].value
+#define currentMaxPosition      MinMaxPositionN[1].value
+#define currentMaxTravel        MaxTravelN[0].value
+
+std::auto_ptr<RoboFocus> roboFocus(0);
+
+ void ISInit()
+ {
+    static int isInit =0;
+
+    if (isInit == 1)
+        return;
+
+     isInit = 1;
+     if(roboFocus.get() == 0) roboFocus.reset(new RoboFocus());
+     //IEAddTimer(POLLMS, ISPoll, NULL);
+
+ }
+
+ void ISGetProperties(const char *dev)
+ {
+         ISInit();
+         roboFocus->ISGetProperties(dev);
+ }
+
+ void ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int num)
+ {
+         ISInit();
+         roboFocus->ISNewSwitch(dev, name, states, names, num);
+ }
+
+ void ISNewText(	const char *dev, const char *name, char *texts[], char *names[], int num)
+ {
+         ISInit();
+         roboFocus->ISNewText(dev, name, texts, names, num);
+ }
+
+ void ISNewNumber(const char *dev, const char *name, double values[], char *names[], int num)
+ {
+         ISInit();
+         roboFocus->ISNewNumber(dev, name, values, names, num);
+ }
+
+ void ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
+ {
+   INDI_UNUSED(dev);
+   INDI_UNUSED(name);
+   INDI_UNUSED(sizes);
+   INDI_UNUSED(blobsizes);
+   INDI_UNUSED(blobs);
+   INDI_UNUSED(formats);
+   INDI_UNUSED(names);
+   INDI_UNUSED(n);
+ }
+
+ void ISSnoopDevice (XMLEle *root)
+ {
+     ISInit();
+     roboFocus->ISSnoopDevice(root);
+ }
+
+
+RoboFocus::RoboFocus()
+{
+
+}
+
+RoboFocus::~RoboFocus()
+{
+
+}
+
+bool RoboFocus::initProperties()
+{
+    INDI::Focuser::initProperties();
+
+    // No speed for robofocus
+    FocusSpeedN[0].min = FocusSpeedN[0].max = FocusSpeedN[0].value = 1;
+
+    IUUpdateMinMax(FocusSpeedNP);
+
+    /* Port */
+    IUFillText(&PortT[0], "PORT", "Port", "/dev/ttyUSB0");
+    IUFillTextVector(&PortTP, PortT, 1, deviceName(), "DEVICE_PORT", "Ports", MAIN_CONTROL_TAB, IP_RW, 0, IPS_IDLE);
+
+
+    /* Focuser temperature */
+    IUFillNumber(&TemperatureN[0], "TEMPERATURE", "Celsius", "%6.2f", 0, 65000., 0., 10000.);
+    IUFillNumberVector(&TemperatureNP, TemperatureN, 1, deviceName(), "FOCUS_TEMPERATURE", "Temperature", MAIN_CONTROL_TAB, IP_RO, 0, IPS_IDLE);
+
+    /* Settings of the Robofocus */
+    IUFillNumber(&SettingsN[0], "Duty cycle", "Duty cycle", "%6.0f", 0., 255., 0., 1.0);
+    IUFillNumber(&SettingsN[1], "Step Delay", "Step delay", "%6.0f", 0., 255., 0., 1.0);
+    IUFillNumber(&SettingsN[2], "Motor Steps", "Motor steps per tick", "%6.0f", 0., 255., 0., 1.0);
+    IUFillNumberVector(&SettingsNP, SettingsN, 3, deviceName(), "FOCUS_SETTINGS", "Settings", OPTIONS_TAB, IP_RW, 0, IPS_IDLE);
+
+    /* Power Switches of the Robofocus */
+    IUFillSwitch(&PowerSwitchesS[0], "1", "Switch 1", ISS_OFF);
+    IUFillSwitch(&PowerSwitchesS[1], "2", "Switch 2", ISS_OFF);
+    IUFillSwitch(&PowerSwitchesS[2], "3", "Switch 3", ISS_OFF);
+    IUFillSwitch(&PowerSwitchesS[3], "4", "Switch 4", ISS_ON);
+    IUFillSwitchVector(&PowerSwitchesSP, PowerSwitchesS, 4, deviceName(), "SWTICHES", "Power", OPTIONS_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);
+
+    /* Robofocus should stay within these limits */
+    IUFillNumber(&MinMaxPositionN[0], "MINPOS", "Minimum Tick", "%6.0f", 1., 65000., 0., 100. );
+    IUFillNumber(&MinMaxPositionN[1], "MAXPOS", "Maximum Tick", "%6.0f", 1., 65000., 0., 55000.);
+    IUFillNumberVector(&MinMaxPositionNP, MinMaxPositionN, 2, deviceName(), "FOCUS_MINMAXPOSITION", "Extrama", OPTIONS_TAB, IP_RW, 0, IPS_IDLE);
+
+    IUFillNumber(&MaxTravelN[0], "MAXTRAVEL", "Maximum travel", "%6.0f", 1., 64000., 0., 10000.);
+    IUFillNumberVector(&MaxTravelNP, MaxTravelN, 1, deviceName(), "FOCUS_MAXTRAVEL", "Max. travel", OPTIONS_TAB, IP_RW, 0, IPS_IDLE );
+
+    /* Set Robofocus position register to the this position */
+    IUFillNumber(&SetRegisterPositionN[0], "SETPOS", "Position", "%6.0f", 0, 64000., 0., 0. );
+    IUFillNumberVector(&SetRegisterPositionNP, SetRegisterPositionN, 1, deviceName(), "FOCUS_REGISTERPOSITION", "Set register", OPTIONS_TAB, IP_RW, 0, IPS_IDLE);
+
+    /* Backlash */
+    IUFillNumber(&SetBacklashN[0], "SETBACKLASH", "Backlash", "%6.0f", -255., 255., 0., 0.);
+    IUFillNumberVector(&SetBacklashNP, SetBacklashN, 1, deviceName(), "FOCUS_BACKLASH", "Set Register", OPTIONS_TAB, IP_RW, 0, IPS_IDLE);
+
+    /* Robofocus` position (RO) */
+    IUFillNumber(&PositionN[0], "POSITION", "Tick", "%6.0f", 0, 65000., 0., 10000.);
+    IUFillNumberVector(&PositionNP, PositionN, 1, deviceName(), "FOCUS_POSITION", "Position", MAIN_CONTROL_TAB, IP_RO, 0, IPS_IDLE);
+
+
+    /* Relative and absolute movement */
+    IUFillNumber(&RelMovementN[0], "RELMOVEMENT", "Ticks", "%6.0f", -65000., 65000., 0., 100. );
+    IUFillNumberVector(&RelMovementNP, RelMovementN, 1, deviceName(), "FOCUS_RELMOVEMENT", "Relative GoTo", MAIN_CONTROL_TAB, IP_RW, 0, IPS_IDLE);
+
+    IUFillNumber(&AbsMovementN[0], "ABSMOVEMENT", "Tick", "%6.0f", 0, 65000., 0., 10000.);
+    IUFillNumberVector(&AbsMovementNP, AbsMovementN, 1, deviceName(), "FOCUS_ABSMOVEMENT", "Absolute GoTo", MAIN_CONTROL_TAB, IP_RW, 0, IPS_IDLE);
+
+
+    addDebugControl();
+
+    return true;
+
+}
+
+void RoboFocus::ISGetProperties(const char *dev)
+{
+    INDI::Focuser::ISGetProperties(dev);
+
+    defineText(&PortTP);
+
+
+}
+
+bool RoboFocus::updateProperties()
+{
+    INDI::Focuser::updateProperties();
+
+    if (isConnected())
+    {
+        defineNumber(&TemperatureNP);
+        defineSwitch(&PowerSwitchesSP);
+        defineNumber(&SettingsNP);
+        defineNumber(&MinMaxPositionNP);
+        defineNumber(&MaxTravelNP);
+        defineNumber(&SetRegisterPositionNP);
+        defineNumber(&SetBacklashNP);
+        defineNumber(&PositionNP);
+        defineNumber(&RelMovementNP);
+        defineNumber(&AbsMovementNP);
+    }
+    else
+    {
+
+        deleteProperty(TemperatureNP.name);
+        deleteProperty(SettingsNP.name);
+        deleteProperty(PowerSwitchesSP.name);
+        deleteProperty(MinMaxPositionNP.name);
+        deleteProperty(MaxTravelNP.name);
+        deleteProperty(SetRegisterPositionNP.name);
+        deleteProperty(SetBacklashNP.name);
+        deleteProperty(PositionNP.name);
+        deleteProperty(RelMovementNP.name);
+        deleteProperty(AbsMovementNP.name);
+
+    }
+
+    return true;
+
+}
+
+bool RoboFocus::Connect()
+{
+    int connectrc=0;
+    char errorMsg[MAXRBUF];
+    char firmeware[]="FV0000000";
+
+
+    if (isDebug())
+        IDLog("connecting to %s\n",PortT[0].text);
+
+    if ( (connectrc = tty_connect(PortT[0].text, 9600, 8, 0, 1, &PortFD)) != TTY_OK)
+    {
+        tty_error_msg(connectrc, errorMsg, MAXRBUF);
+
+        if (isDebug())
+            IDLog("Failed to connect o port %s. Error: %s", PortT[0].text, errorMsg);
+
+        IDMessage(deviceName(), "Failed to connect to port %s. Error: %s", PortT[0].text, errorMsg);
+
+        return false;
+
+    }
+
+    if((updateRFFirmware(firmeware)) < 0)
+    {
+      /* This would be the end*/
+        IDMessage( deviceName(), "Unknown error while reading Robofocus firmware\n");
+        return false;
+    }
+
+    IDMessage(deviceName(), "Robofocus is online. Getting focus parameters...");
+
+    GetFocusParams();
+
+    IDMessage(deviceName(), "RoboFocus paramaters readout complete, focuser ready for use.");
+
+    return true;
+}
+
+bool RoboFocus::Disconnect()
+{
+    tty_disconnect(PortFD);
+    IDMessage(deviceName(), "RoboFocus is offline.");
+    return true;
+}
+
+const char * RoboFocus::getDefaultName()
+{
+    return "RoboFocus";
+}
+
+unsigned char RoboFocus::CheckSum(char *rf_cmd)
+{
+
+  char substr[255] ;
+  unsigned char val= 0 ;
+  int i= 0 ;
+
+  for(i=0; i < 8; i++) {
+
+    substr[i]=rf_cmd[i] ;
+  }
+
+  val = CalculateSum( substr) ;
+  if( val==  (unsigned char) rf_cmd[8])
+  {
+
+  } else {
+
+      if (isDebug())
+          fprintf(stderr,  "Wrong (%s,%d), %x != %x\n",  rf_cmd, strlen(rf_cmd), val, (unsigned char) rf_cmd[8]) ;
+  }
+
+  return val ;
+}
+
+unsigned char RoboFocus::CalculateSum(char *rf_cmd)
+{
+
+  unsigned char val= 0 ;
+  int i=0 ;
+
+  for(i=0; i < 8; i++) {
+
+    val = val + (unsigned char) rf_cmd[i] ;
+  }
+
+  return val % 256 ;
+}
+
+int RoboFocus::SendCommand(char *rf_cmd)
+{
+
+  int nbytes_written=0, nbytes_read=0, check_ret=0, err_code=0;
+  char rf_cmd_cks[32],robofocus_error[MAXRBUF];
+
+  unsigned char val= 0 ;
+
+  val = CalculateSum( rf_cmd );
+
+  for(int i=0; i < 8; i++)
+  {
+
+    rf_cmd_cks[i]= rf_cmd[i] ;
+  }
+
+  rf_cmd_cks[8]=  (unsigned char) val ;
+  rf_cmd_cks[9]= 0 ;
+
+  if (isDebug())
+  {
+   fprintf(stderr, "WRITE: ") ;
+   for(int i=0; i < 9; i++)
+   {
+
+     fprintf(stderr, "0x%2x ", (unsigned char) rf_cmd_cks[i]) ;
+   }
+   fprintf(stderr, "\n") ;
+  }
+
+
+  tcflush(PortFD, TCIOFLUSH);
+
+   if  ( (err_code = tty_write(PortFD, rf_cmd_cks, RF_MAX_CMD, &nbytes_written) != TTY_OK))
+   {
+        tty_error_msg(err_code, robofocus_error, MAXRBUF);
+        if (isDebug())
+            IDLog("TTY error detected: %s\n", robofocus_error);
+        return -1;
+   }
+
+   nbytes_read= ReadResponse(rf_cmd, RF_MAX_CMD, RF_TIMEOUT) ;
+
+   if (nbytes_read < 1)
+     return nbytes_read;
+
+   check_ret= CheckSum(rf_cmd) ;
+
+   rf_cmd[ nbytes_read - 1] = 0 ;
+   return 0;
+
+}
+
+int RoboFocus::ReadResponse(char *buf, int nbytes, int timeout)
+{
+
+  char robofocus_error[MAXRBUF];
+  int bytesRead = 0;
+  int totalBytesRead = 0;
+  int err_code;
+
+
+  while (totalBytesRead < nbytes)
+  {
+      //IDLog("Nbytes: %d\n", nbytes);
+
+      if ( (err_code = tty_read(PortFD, buf+totalBytesRead, nbytes-totalBytesRead, timeout, &bytesRead)) != TTY_OK)
+      {
+              tty_error_msg(err_code, robofocus_error, MAXRBUF);
+              if (isDebug())
+              {
+                  IDLog("TTY error detected: %s\n", robofocus_error);
+                  IDMessage(deviceName(), "TTY error detected: %s\n", robofocus_error);
+              }
+              return false;
+      }
+
+      //IDLog("Bytes Read: %d\n", bytesRead);
+
+      if (bytesRead < 0 )
+      {
+          //IDLog("Bytesread < 1\n");
+          return -1;
+      }
+
+      if((  buf[0]== 'I')||  (  buf[0]== 'O'))
+      {
+
+        //fprintf(stderr, "Moving\n") ;
+
+        for(int i=0; i < 9; i++)
+        {
+            // Catch the F in stream of I's and O's
+            // The robofocus reply might get mixed with the movement strings. For example:
+            // 0x49 0x49 0x49 0x49 0x49 0x46 0x44 0x30 0x32
+            // The 0x46 above is the START for the rofofocus response string, but it's lost unless we catch it here
+            if (buf[i] == 0x46)
+            {
+                totalBytesRead = RF_MAX_CMD - i;
+                strncpy(buf, buf+totalBytesRead+1, totalBytesRead);
+                break;
+            }
+        }
+
+       // buf[0]=0 ;
+         usleep(100000) ;
+
+
+      }
+      else
+      {
+        //buf += bytesRead;
+        totalBytesRead += bytesRead;
+        //nbytes -= bytesRead;
+      }
+    }
+
+    tcflush(PortFD, TCIOFLUSH);
+
+   if (isDebug())
+   {
+       fprintf(stderr, "READ : (%s,%d), %d\n", buf, 9, totalBytesRead) ;
+        fprintf(stderr, "READ : ") ;
+        for(int i=0; i < 9; i++)
+        {
+
+         fprintf(stderr, "0x%2x ", (unsigned char)buf[i]) ;
+        }
+        fprintf(stderr, "\n") ;
+   }
+
+  return 9;
+}
+
+int RoboFocus::updateRFPosition(double *value)
+{
+
+  float temp ;
+  char rf_cmd[32] ;
+  int ret_read_tmp ;
+
+  strcpy(rf_cmd, "FG000000" ) ;
+
+  if ((ret_read_tmp= SendCommand(  rf_cmd)) < 0){
+
+    return ret_read_tmp;
+  }
+   if (sscanf(rf_cmd, "FD%6f", &temp) < 1){
+
+    return -1;
+  }
+
+  *value = (double) temp;
+
+  return 0;
+
+}
+
+int RoboFocus::updateRFTemperature(double *value)
+{
+
+  float temp ;
+  char rf_cmd[32] ;
+  int ret_read_tmp ;
+
+  strcpy(rf_cmd, "FT000000" ) ;
+
+  if ((ret_read_tmp= SendCommand( rf_cmd)) < 0)
+    return ret_read_tmp;
+
+
+  if (sscanf(rf_cmd, "FT%6f", &temp) < 1)
+    return -1;
+
+  *value = (double) temp/2.- 273.15;
+
+  return 0;
+}
+
+int RoboFocus::updateRFBacklash(double *value)
+{
+
+  float temp ;
+  char rf_cmd[32] ;
+  char vl_tmp[4] ;
+  int ret_read_tmp ;
+  int sign= 0 ;
+
+  if(*value== BACKLASH_READOUT) {
+
+    strcpy(rf_cmd, "FB000000" ) ;
+
+  } else {
+
+    rf_cmd[0]=  'F' ;
+    rf_cmd[1]=  'B' ;
+
+    if( *value > 0) {
+
+      rf_cmd[2]= '3' ;
+
+    } else {
+      *value= - *value ;
+      rf_cmd[2]= '2' ;
+    }
+    rf_cmd[3]= '0' ;
+    rf_cmd[4]= '0' ;
+
+    if(*value > 99) {
+      sprintf( vl_tmp, "%3d", (int) *value) ;
+
+    } else if(*value > 9) {
+      sprintf( vl_tmp, "0%2d", (int) *value) ;
+    } else {
+      sprintf( vl_tmp, "00%1d", (int) *value) ;
+    }
+    rf_cmd[5]= vl_tmp[0] ;
+    rf_cmd[6]= vl_tmp[1] ;
+    rf_cmd[7]= vl_tmp[2] ;
+  }
+
+  if ((ret_read_tmp= SendCommand( rf_cmd)) < 0)
+    return ret_read_tmp;
+
+
+  if (sscanf(rf_cmd, "FB%1d%5f", &sign, &temp) < 1)
+    return -1;
+
+  *value = (double) temp  ;
+
+  if(( sign== 2) && ( *value > 0)) {
+    *value = - (*value) ;
+  }
+  return 0;
+}
+
+int RoboFocus::updateRFFirmware(char *rf_cmd)
+{
+
+  int ret_read_tmp ;
+
+  strcpy(rf_cmd, "FV000000" ) ;
+
+  if ((ret_read_tmp= SendCommand( rf_cmd)) < 0)
+    return ret_read_tmp;
+
+  return 0;
+}
+
+int RoboFocus::updateRFMotorSettings(double *duty, double *delay, double *ticks)
+{
+
+  char rf_cmd[32] ;
+  int ret_read_tmp ;
+
+  if(( *duty== 0 ) && (*delay== 0) && (*ticks== 0) ){
+
+    strcpy(rf_cmd, "FC000000" ) ;
+
+  } else {
+
+    rf_cmd[0]=  'F' ;
+    rf_cmd[1]=  'C' ;
+    rf_cmd[2]= (char) *duty ;
+    rf_cmd[3]= (char) *delay ;
+    rf_cmd[4]= (char) *ticks ;
+    rf_cmd[5]= '0' ;
+    rf_cmd[6]= '0' ;
+    rf_cmd[7]= '0' ;
+    rf_cmd[8]=  0 ;
+
+  }
+
+  if ((ret_read_tmp= SendCommand( rf_cmd)) < 0)
+    return ret_read_tmp;
+
+  *duty=  (float) rf_cmd[2] ;
+  *delay= (float) rf_cmd[3] ;
+  *ticks= (float) rf_cmd[4] ;
+
+  return 0;
+}
+
+int RoboFocus::updateRFPositionRelativeInward(double *value)
+{
+
+  char rf_cmd[32] ;
+  int ret_read_tmp ;
+  float temp ;
+  rf_cmd[0]= 0 ;
+
+  if(*value > 9999) {
+    sprintf( rf_cmd, "FI0%5d", (int) *value) ;
+  } else if(*value > 999) {
+    sprintf( rf_cmd, "FI00%4d", (int) *value) ;
+  } else if(*value > 99) {
+    sprintf( rf_cmd, "FI000%3d", (int) *value) ;
+  } else if(*value > 9) {
+    sprintf( rf_cmd, "FI0000%2d", (int) *value) ;
+  } else {
+    sprintf( rf_cmd, "FI00000%1d", (int) *value) ;
+  }
+
+  if ((ret_read_tmp= SendCommand( rf_cmd)) < 0)
+    return ret_read_tmp;
+
+  if (sscanf(rf_cmd, "FD0%5f", &temp) < 1)
+    return -1;
+
+  *value = (double) temp  ;
+
+  return 0;
+}
+
+int RoboFocus::updateRFPositionRelativeOutward(double *value)
+{
+
+  char rf_cmd[32] ;
+  int ret_read_tmp ;
+  float temp ;
+
+  rf_cmd[0]= 0 ;
+
+  if(*value > 9999) {
+    sprintf( rf_cmd, "FO0%5d", (int) *value) ;
+  } else if(*value > 999) {
+    sprintf( rf_cmd, "FO00%4d", (int) *value) ;
+  } else if(*value > 99) {
+    sprintf( rf_cmd, "FO000%3d", (int) *value) ;
+  } else if(*value > 9) {
+    sprintf( rf_cmd, "FO0000%2d", (int) *value) ;
+  } else {
+    sprintf( rf_cmd, "FO00000%1d", (int) *value) ;
+  }
+
+  if ((ret_read_tmp= SendCommand( rf_cmd)) < 0)
+    return ret_read_tmp;
+
+  if (sscanf(rf_cmd, "FD0%5f", &temp) < 1)
+    return -1;
+
+  *value = (double) temp  ;
+
+  return 0;
+}
+
+int RoboFocus::updateRFPositionAbsolute(double *value)
+{
+
+  char rf_cmd[32] ;
+  int ret_read_tmp ;
+  float temp ;
+
+  rf_cmd[0]= 0 ;
+
+  if(*value > 9999) {
+    sprintf( rf_cmd, "FG0%5d", (int) *value) ;
+  } else if(*value > 999) {
+    sprintf( rf_cmd, "FG00%4d", (int) *value) ;
+  } else if(*value > 99) {
+    sprintf( rf_cmd, "FG000%3d", (int) *value) ;
+  } else if(*value > 9) {
+    sprintf( rf_cmd, "FG0000%2d", (int) *value) ;
+  } else {
+    sprintf( rf_cmd, "FG00000%1d", (int) *value) ;
+  }
+
+  if ((ret_read_tmp= SendCommand( rf_cmd)) < 0)
+    return ret_read_tmp;
+
+  if (sscanf(rf_cmd, "FD0%5f", &temp) < 1)
+    return -1;
+
+  *value = (double) temp  ;
+
+  return 0;
+}
+
+int RoboFocus::updateRFPowerSwitches(int s, int  new_sn, int *cur_s1LL, int *cur_s2LR, int *cur_s3RL, int *cur_s4RR)
+{
+
+  char rf_cmd[32] ;
+  char rf_cmd_tmp[32] ;
+  int ret_read_tmp ;
+  int i = 0 ;
+
+
+    /* Get first the status */
+    strcpy(rf_cmd_tmp, "FP000000" ) ;
+
+    if ((ret_read_tmp= SendCommand( rf_cmd_tmp)) < 0)
+      return ret_read_tmp ;
+
+    for(i= 0; i < 9; i++) {
+      rf_cmd[i]= rf_cmd_tmp[i] ;
+    }
+
+
+    if( rf_cmd[new_sn + 4]== '2') {
+      rf_cmd[new_sn + 4]= '1' ;
+    } else {
+      rf_cmd[new_sn + 4]= '2' ;
+    }
+
+
+ /*    if( s== ISS_ON) { */
+
+/*       rf_cmd[new_sn + 4]= '2' ; */
+/*     } else { */
+/*       rf_cmd[new_sn + 4]= '1' ; */
+/*     } */
+
+    rf_cmd[8]= 0 ;
+
+  if ((ret_read_tmp= SendCommand( rf_cmd)) < 0)
+    return ret_read_tmp ;
+
+
+  *cur_s1LL= *cur_s2LR= *cur_s3RL= *cur_s4RR= ISS_OFF ;
+
+  if(rf_cmd[4]== '2' ) {
+    *cur_s1LL= ISS_ON ;
+  }
+
+  if(rf_cmd[5]== '2' ) {
+    *cur_s2LR= ISS_ON ;
+  }
+
+  if(rf_cmd[6]== '2' ) {
+    *cur_s3RL= ISS_ON ;
+  }
+
+  if(rf_cmd[7]== '2' ) {
+    *cur_s4RR= ISS_ON ;
+  }
+  return 0 ;
+}
+
+
+int RoboFocus::updateRFMaxPosition(double *value)
+{
+
+  float temp ;
+  char rf_cmd[32] ;
+  char vl_tmp[6] ;
+  int ret_read_tmp ;
+  char waste[1] ;
+
+  if(*value== MAXTRAVEL_READOUT) {
+
+    strcpy(rf_cmd, "FL000000" ) ;
+
+  } else {
+
+    rf_cmd[0]=  'F' ;
+    rf_cmd[1]=  'L' ;
+    rf_cmd[2]=  '0' ;
+
+    if(*value > 9999) {
+      sprintf( vl_tmp, "%5d", (int) *value) ;
+
+    } else if(*value > 999) {
+
+      sprintf( vl_tmp, "0%4d", (int) *value) ;
+
+    } else if(*value > 99) {
+      sprintf( vl_tmp, "00%3d", (int) *value) ;
+
+    } else if(*value > 9) {
+      sprintf( vl_tmp, "000%2d", (int) *value) ;
+    } else {
+      sprintf( vl_tmp, "0000%1d", (int) *value) ;
+    }
+    rf_cmd[3]= vl_tmp[0] ;
+    rf_cmd[4]= vl_tmp[1] ;
+    rf_cmd[5]= vl_tmp[2] ;
+    rf_cmd[6]= vl_tmp[3] ;
+    rf_cmd[7]= vl_tmp[4] ;
+    rf_cmd[8]= 0 ;
+  }
+
+  if ((ret_read_tmp= SendCommand( rf_cmd)) < 0)
+    return ret_read_tmp;
+
+
+  if (sscanf(rf_cmd, "FL%1c%5f", waste, &temp) < 1)
+    return -1;
+
+  *value = (double) temp  ;
+
+  return 0;
+}
+
+int RoboFocus::updateRFSetPosition(double *value)
+{
+
+  char rf_cmd[32] ;
+  char vl_tmp[6] ;
+  int ret_read_tmp ;
+
+  rf_cmd[0]=  'F' ;
+  rf_cmd[1]=  'S' ;
+  rf_cmd[2]=  '0' ;
+
+  if(*value > 9999) {
+    sprintf( vl_tmp, "%5d", (int) *value) ;
+  } else if(*value > 999) {
+    sprintf( vl_tmp, "0%4d", (int) *value) ;
+  } else if(*value > 99) {
+    sprintf( vl_tmp, "00%3d", (int) *value) ;
+  } else if(*value > 9) {
+    sprintf( vl_tmp, "000%2d", (int) *value) ;
+  } else {
+    sprintf( vl_tmp, "0000%1d", (int) *value) ;
+  }
+  rf_cmd[3]= vl_tmp[0] ;
+  rf_cmd[4]= vl_tmp[1] ;
+  rf_cmd[5]= vl_tmp[2] ;
+  rf_cmd[6]= vl_tmp[3] ;
+  rf_cmd[7]= vl_tmp[4] ;
+  rf_cmd[8]= 0 ;
+
+  if ((ret_read_tmp= SendCommand( rf_cmd)) < 0)
+    return ret_read_tmp;
+
+  return 0;
+}
+
+bool RoboFocus::ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
+{
+    if(strcmp(dev,deviceName())==0)
+    {
+        // ===================================
+        // Port Name
+        // ===================================
+        if (!strcmp(name, PortTP.name) )
+        {
+          if (IUUpdateText(&PortTP, texts, names, n) < 0)
+                return false;
+
+          PortTP.s = IPS_OK;
+          IDSetText (&PortTP, NULL);
+          return true;
+        }
+
+    }
+
+     return INDI::Focuser::ISNewText(dev, name, texts, names, n);
+}
+
+bool RoboFocus::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
+{
+    if(strcmp(dev,deviceName())==0)
+    {
+        if (!strcmp (name, PowerSwitchesSP.name))
+        {
+          int ret= -1 ;
+          int nset= 0 ;
+          int i= 0 ;
+          int new_s= -1 ;
+          int new_sn= -1 ;
+          int cur_s1LL=0 ;
+          int cur_s2LR=0 ;
+          int cur_s3RL=0 ;
+          int cur_s4RR=0 ;
+
+          ISwitch *sp ;
+
+          PowerSwitchesSP.s = IPS_BUSY ;
+          IDSetSwitch(&PowerSwitchesSP, NULL) ;
+
+
+          for( nset = i = 0; i < n; i++) {
+            /* Find numbers with the passed names in the SettingsNP property */
+            sp = IUFindSwitch (&PowerSwitchesSP, names[i]) ;
+
+            /* If the state found is  (PowerSwitchesS[0]) then process it */
+
+            if( sp == &PowerSwitchesS[0]){
+
+
+              new_s = (states[i]) ;
+              new_sn= 0;
+              nset++ ;
+            } else if( sp == &PowerSwitchesS[1]){
+
+              new_s = (states[i]) ;
+              new_sn= 1;
+              nset++ ;
+            } else if( sp == &PowerSwitchesS[2]){
+
+              new_s = (states[i]) ;
+              new_sn= 2;
+              nset++ ;
+            } else if( sp == &PowerSwitchesS[3]){
+
+              new_s = (states[i]) ;
+              new_sn= 3;
+              nset++ ;
+            }
+          }
+          if (nset == 1)
+          {
+            cur_s1LL= cur_s2LR= cur_s3RL= cur_s4RR= 0 ;
+
+            if(( ret= updateRFPowerSwitches(new_s, new_sn, &cur_s1LL, &cur_s2LR, &cur_s3RL, &cur_s4RR)) < 0)
+            {
+
+              PowerSwitchesSP.s = IPS_ALERT;
+              IDSetSwitch(&PowerSwitchesSP, "Unknown error while reading  Robofocus power swicht settings");
+              return true;
+            }
+          }
+          else
+          {
+            /* Set property state to idle */
+            PowerSwitchesSP.s = IPS_IDLE ;
+
+            IDSetNumber(&SettingsNP, "Power switch settings absent or bogus.");
+            return true ;
+          }
+
+      }
+    }
+
+
+    return INDI::Focuser::ISNewSwitch(dev, name, states, names, n);
+}
+
+bool RoboFocus::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
+{
+    int nset=0,i=0;
+
+    if(strcmp(dev,deviceName())==0)
+    {
+
+        if (!strcmp (name, SettingsNP.name))
+        {
+          /* new speed */
+          double new_duty = 0 ;
+          double new_delay = 0 ;
+          double new_ticks = 0 ;
+          int ret = -1 ;
+
+          for (nset = i = 0; i < n; i++)
+          {
+            /* Find numbers with the passed names in the SettingsNP property */
+            INumber *eqp = IUFindNumber (&SettingsNP, names[i]);
+
+            /* If the number found is  (SettingsN[0]) then process it */
+            if (eqp == &SettingsN[0])
+            {
+
+              new_duty = (values[i]);
+              nset += new_duty >= 0 && new_duty <= 255;
+            } else if  (eqp == &SettingsN[1])
+            {
+
+              new_delay = (values[i]);
+              nset += new_delay >= 0 && new_delay <= 255;
+            } else if  (eqp == &SettingsN[2])
+            {
+
+              new_ticks = (values[i]);
+              nset += new_ticks >= 0 && new_ticks <= 255;
+            }
+          }
+
+          /* Did we process the three numbers? */
+          if (nset == 3)
+          {
+
+            /* Set the robofocus state to BUSY */
+            SettingsNP.s = IPS_BUSY;
+
+
+            IDSetNumber(&SettingsNP, NULL);
+
+            if(( ret= updateRFMotorSettings(&new_duty, &new_delay, &new_ticks))< 0)
+            {
+
+              IDSetNumber(&SettingsNP, "Changing to new settings failed");
+              return false;
+            }
+
+            currentDuty = new_duty ;
+            currentDelay= new_delay ;
+            currentTicks= new_ticks ;
+
+            SettingsNP.s = IPS_OK;
+            IDSetNumber(&SettingsNP, "Motor settings are now  %3.0f %3.0f %3.0f", currentDuty, currentDelay, currentTicks);
+            return true;
+
+          } else
+          {
+            /* Set property state to idle */
+            SettingsNP.s = IPS_IDLE;
+
+            IDSetNumber(&SettingsNP, "Settings absent or bogus.");
+            return false ;
+          }
+        }
+
+
+        if (!strcmp (name, RelMovementNP.name))
+        {
+
+          double cur_rpos=0 ;
+          double new_rpos = 0 ;
+          int nset = 0;
+          int ret= -1 ;
+
+          for (nset = i = 0; i < n; i++)
+          {
+            /* Find numbers with the passed names in the RelMovementNP property */
+            INumber *eqp = IUFindNumber (&RelMovementNP, names[i]);
+
+            /* If the number found is RelMovement (RelMovementN[0]) then process it */
+            if (eqp == &RelMovementN[0])
+            {
+
+              cur_rpos= new_rpos = (values[i]);
+
+              /* CHECK 2006-01-26, limmits are relative to the actual position */
+              nset += new_rpos >= -0xffff && new_rpos <= 0xffff;
+            }
+
+            if (nset == 1)
+            {
+
+              /* Set the robofocus state to BUSY */
+              RelMovementNP.s = IPS_BUSY;
+              IDSetNumber(&RelMovementNP, NULL);
+
+              if((currentPosition + new_rpos < currentMinPosition) || (currentPosition + new_rpos > currentMaxPosition))
+              {
+
+                RelMovementNP.s = IPS_ALERT ;
+                IDSetNumber(&RelMovementNP, "Value out of limits %5.0f", currentPosition +  new_rpos);
+                return false ;
+              }
+
+              if( new_rpos > 0)
+              {
+
+                ret= updateRFPositionRelativeOutward(&new_rpos) ;
+              } else
+              {
+
+                new_rpos= -new_rpos ;
+                ret= updateRFPositionRelativeInward(&new_rpos) ;
+              }
+
+              if( ret < 0)
+              {
+
+                RelMovementNP.s = IPS_IDLE;
+                IDSetNumber(&RelMovementNP, "Read out of the relative movement failed, trying to recover position.");
+                if((ret= updateRFPosition(&currentPosition)) < 0) {
+
+
+                  PositionNP.s = IPS_ALERT;
+                  IDSetNumber(&PositionNP, "Unknown error while reading  Robofocus position: %d", ret);
+                  return false;
+                }
+                PositionNP.s = IPS_ALERT;
+                IDSetNumber(&PositionNP, "Robofocus position recovered %5.0f", currentPosition);
+
+                IDMessage( deviceName(), "Robofocus position recovered resuming normal operation");
+
+                /* We have to leave here, because new_rpos is not set */
+                return false ;
+              }
+
+              RelMovementNP.s = IPS_OK;
+              currentRelativeMovement= cur_rpos ;
+              IDSetNumber(&RelMovementNP, NULL) ;
+
+              AbsMovementNP.s = IPS_OK;
+              currentAbsoluteMovement=  new_rpos - cur_rpos ;
+              IDSetNumber(&AbsMovementNP, NULL) ;
+
+              PositionNP.s = IPS_OK;
+              currentPosition= new_rpos ;
+              IDSetNumber(&PositionNP,  "Last position was %5.0f", currentAbsoluteMovement);
+              return true;
+
+           } else {
+
+              RelMovementNP.s = IPS_IDLE;
+              IDSetNumber(&RelMovementNP, "Need exactly one parameter.");
+
+              return  false;
+            }
+          }
+        }
+
+
+
+        if (!strcmp (name, AbsMovementNP.name))
+        {
+
+          double new_apos = 0 ;
+          int nset = 0;
+          int ret= -1 ;
+
+          for (nset = i = 0; i < n; i++)
+          {
+            /* Find numbers with the passed names in the AbsMovementNP property */
+            INumber *eqp = IUFindNumber (&AbsMovementNP, names[i]);
+
+            /* If the number found is AbsMovement (AbsMovementN[0]) then process it */
+            if (eqp == &AbsMovementN[0]){
+
+              new_apos = (values[i]);
+
+              /* limits are absolute to the actual position */
+              nset += new_apos >= 0 && new_apos <= 0xffff;
+            }
+
+            if (nset == 1)
+            {
+
+              /* Set the robofocus state to BUSY */
+              AbsMovementNP.s = IPS_BUSY;
+              IDSetNumber(&AbsMovementNP, NULL);
+
+              if((new_apos < currentMinPosition) || (new_apos > currentMaxPosition))
+              {
+
+                AbsMovementNP.s = IPS_ALERT ;
+                IDSetNumber(&AbsMovementNP, "Value out of limits  %5.0f", new_apos);
+                return false ;
+              }
+
+              if(( ret= updateRFPositionAbsolute(&new_apos)) < 0)
+              {
+
+                AbsMovementNP.s = IPS_IDLE;
+                IDSetNumber(&AbsMovementNP, "Read out of the absolute movement failed %3d, trying to recover position.", ret);
+
+                if((ret= updateRFPosition(&currentPosition)) < 0)
+                {
+
+                  PositionNP.s = IPS_ALERT;
+                  IDSetNumber(&PositionNP, "Unknown error while reading  Robofocus position: %d.", ret);
+
+                  return false;
+                }
+
+                PositionNP.s = IPS_OK;
+                IDSetNumber(&PositionNP, "Robofocus position recovered %5.0f", currentPosition);
+                IDMessage( deviceName(), "Robofocus position recovered resuming normal operation");
+                /* We have to leave here, because new_apos is not set */
+                return false;
+              }
+
+              currentAbsoluteMovement=  currentPosition ;
+              AbsMovementNP.s = IPS_OK;
+              IDSetNumber(&AbsMovementNP, NULL) ;
+
+              PositionNP.s = IPS_OK;
+              currentPosition= new_apos ;
+              IDSetNumber(&PositionNP,  "Absolute position was  %5.0f", currentAbsoluteMovement);
+              return true;
+
+            } else
+            {
+
+              AbsMovementNP.s = IPS_IDLE;
+              IDSetNumber(&RelMovementNP, "Need exactly one parameter.");
+
+              return false;
+            }
+          }
+        }
+
+
+
+        if (!strcmp (name, SetBacklashNP.name))
+        {
+
+          double new_back = 0 ;
+          int nset = 0;
+          int ret= -1 ;
+
+          for (nset = i = 0; i < n; i++)
+          {
+            /* Find numbers with the passed names in the SetBacklashNP property */
+            INumber *eqp = IUFindNumber (&SetBacklashNP, names[i]);
+
+            /* If the number found is SetBacklash (SetBacklashN[0]) then process it */
+            if (eqp == &SetBacklashN[0]){
+
+              new_back = (values[i]);
+
+              /* limits */
+              nset += new_back >= -0xff && new_back <= 0xff;
+            }
+
+            if (nset == 1) {
+
+              /* Set the robofocus state to BUSY */
+              SetBacklashNP.s = IPS_BUSY;
+              IDSetNumber(&SetBacklashNP, NULL);
+
+              if(( ret= updateRFBacklash(&new_back)) < 0) {
+
+                SetBacklashNP.s = IPS_IDLE;
+                IDSetNumber(&SetBacklashNP, "Setting new backlash failed.");
+
+                return false ;
+              }
+
+              currentSetBacklash=  new_back ;
+              SetBacklashNP.s = IPS_OK;
+              IDSetNumber(&SetBacklashNP, "Backlash is now  %3.0f", currentSetBacklash) ;
+              return true;
+            } else {
+
+              SetBacklashNP.s = IPS_IDLE;
+              IDSetNumber(&SetBacklashNP, "Need exactly one parameter.");
+
+              return false ;
+            }
+          }
+        }
+
+
+
+        if (!strcmp (name, MinMaxPositionNP.name))
+        {
+          /* new positions */
+          double new_min = 0 ;
+          double new_max = 0 ;
+
+          for (nset = i = 0; i < n; i++)
+          {
+            /* Find numbers with the passed names in the MinMaxPositionNP property */
+            INumber *mmpp = IUFindNumber (&MinMaxPositionNP, names[i]);
+
+            /* If the number found is  (MinMaxPositionN[0]) then process it */
+            if (mmpp == &MinMaxPositionN[0])
+            {
+
+              new_min = (values[i]);
+              nset += new_min >= 1 && new_min <= 65000;
+            } else if  (mmpp == &MinMaxPositionN[1])
+            {
+
+              new_max = (values[i]);
+              nset += new_max >= 1 && new_max <= 65000;
+            }
+          }
+
+          /* Did we process the two numbers? */
+          if (nset == 2)
+          {
+
+            /* Set the robofocus state to BUSY */
+            MinMaxPositionNP.s = IPS_BUSY;
+
+            currentMinPosition = new_min ;
+            currentMaxPosition= new_max ;
+
+
+            MinMaxPositionNP.s = IPS_OK;
+            IDSetNumber(&MinMaxPositionNP, "Minimum and Maximum settings are now  %3.0f %3.0f", currentMinPosition, currentMaxPosition);
+            return true;
+
+          } else {
+            /* Set property state to idle */
+            MinMaxPositionNP.s = IPS_IDLE;
+
+            IDSetNumber(&MinMaxPositionNP, "Minimum and maximum limits absent or bogus.");
+
+            return false;
+          }
+        }
+
+
+        if (!strcmp (name, MaxTravelNP.name))
+        {
+
+          double new_maxt = 0 ;
+          int ret = -1 ;
+
+          for (nset = i = 0; i < n; i++)
+          {
+            /* Find numbers with the passed names in the MinMaxPositionNP property */
+            INumber *mmpp = IUFindNumber (&MaxTravelNP, names[i]);
+
+            /* If the number found is  (MaxTravelN[0]) then process it */
+            if (mmpp == &MaxTravelN[0])
+            {
+
+              new_maxt = (values[i]);
+              nset += new_maxt >= 1 && new_maxt <= 64000;
+            }
+          }
+          /* Did we process the one number? */
+          if (nset == 1) {
+
+            IDSetNumber(&MinMaxPositionNP, NULL);
+
+            if(( ret= updateRFMaxPosition(&new_maxt))< 0 )
+            {
+              MaxTravelNP.s = IPS_IDLE;
+              IDSetNumber(&MaxTravelNP, "Changing to new maximum travel failed");
+              return false ;
+            }
+
+            currentMaxTravel=  new_maxt ;
+            MaxTravelNP.s = IPS_OK;
+            IDSetNumber(&MaxTravelNP, "Maximum travel is now  %3.0f", currentMaxTravel) ;
+            return true;
+
+          } else {
+            /* Set property state to idle */
+
+            MaxTravelNP.s = IPS_IDLE;
+            IDSetNumber(&MaxTravelNP, "Maximum travel absent or bogus.");
+
+            return false ;
+          }
+        }
+
+
+        if (!strcmp (name, SetRegisterPositionNP.name))
+        {
+
+          double new_apos = 0 ;
+          int nset = 0;
+          int ret= -1 ;
+
+          for (nset = i = 0; i < n; i++)
+          {
+            /* Find numbers with the passed names in the SetRegisterPositionNP property */
+            INumber *srpp = IUFindNumber (&SetRegisterPositionNP, names[i]);
+
+            /* If the number found is SetRegisterPosition (SetRegisterPositionN[0]) then process it */
+            if (srpp == &SetRegisterPositionN[0])
+            {
+
+              new_apos = (values[i]);
+
+              /* limits are absolute */
+              nset += new_apos >= 0 && new_apos <= 64000;
+            }
+
+            if (nset == 1)
+            {
+
+              if((new_apos < currentMinPosition) || (new_apos > currentMaxPosition))
+              {
+
+                SetRegisterPositionNP.s = IPS_ALERT ;
+                IDSetNumber(&SetRegisterPositionNP, "Value out of limits  %5.0f", new_apos);
+                return false ;
+              }
+
+              /* Set the robofocus state to BUSY */
+              SetRegisterPositionNP.s = IPS_BUSY;
+              IDSetNumber(&SetRegisterPositionNP, NULL);
+
+              if(( ret= updateRFSetPosition(&new_apos)) < 0)
+              {
+
+                SetRegisterPositionNP.s = IPS_OK;
+                IDSetNumber(&SetRegisterPositionNP, "Read out of the set position to %3d failed. Trying to recover the position", ret);
+
+                if((ret= updateRFPosition( &currentPosition)) < 0)
+                {
+
+                  PositionNP.s = IPS_ALERT;
+                  IDSetNumber(&PositionNP, "Unknown error while reading  Robofocus position: %d", ret);
+
+                  SetRegisterPositionNP.s = IPS_IDLE;
+                  IDSetNumber(&SetRegisterPositionNP, "Relative movement failed.");
+                }
+
+                SetRegisterPositionNP.s = IPS_OK;
+                IDSetNumber(&SetRegisterPositionNP, NULL);
+
+
+                PositionNP.s = IPS_OK;
+                IDSetNumber(&PositionNP, "Robofocus position recovered %5.0f", currentPosition);
+                IDMessage( deviceName(), "Robofocus position recovered resuming normal operation");
+                /* We have to leave here, because new_apos is not set */
+                return true ;
+              }
+              currentPosition= new_apos ;
+              SetRegisterPositionNP.s = IPS_OK;
+              IDSetNumber(&SetRegisterPositionNP, "Robofocus register set to %5.0f", currentPosition);
+
+              PositionNP.s = IPS_OK;
+              IDSetNumber(&PositionNP, "Robofocus position is now %5.0f", currentPosition);
+
+              return true ;
+
+            } else
+            {
+
+              SetRegisterPositionNP.s = IPS_IDLE;
+              IDSetNumber(&SetRegisterPositionNP, "Need exactly one parameter.");
+
+              return false;
+            }
+
+            if((ret= updateRFPosition(&currentPosition)) < 0)
+            {
+
+              PositionNP.s = IPS_ALERT;
+              IDSetNumber(&PositionNP, "Unknown error while reading  Robofocus position: %d", ret);
+
+              return false ;
+            }
+
+            SetRegisterPositionNP.s = IPS_OK;
+            IDSetNumber(&SetRegisterPositionNP, "Robofocus has accepted new register setting" ) ;
+
+            PositionNP.s = IPS_OK;
+            IDSetNumber(&PositionNP, "Robofocus new position %5.0f", currentPosition);
+
+            return true;
+          }
+        }
+
+
+
+    }
+
+    return INDI::Focuser::ISNewNumber(dev, name, values, names, n);
+
+}
+
+void RoboFocus::GetFocusParams ()
+{
+
+  int ret = -1 ;
+  int cur_s1LL=0 ;
+  int cur_s2LR=0 ;
+  int cur_s3RL=0 ;
+  int cur_s4RR=0 ;
+
+
+      if((ret= updateRFPosition(&currentPosition)) < 0)
+      {
+        PositionNP.s = IPS_ALERT;
+        IDSetNumber(&PositionNP, "Unknown error while reading  Robofocus position: %d", ret);
+        return;
+      }
+
+      PositionNP.s = IPS_OK;
+      IDSetNumber(&PositionNP, NULL);
+
+      AbsMovementN[0].value = currentPosition;
+      IDSetNumber(&AbsMovementNP, NULL);
+
+      if(( ret= updateRFTemperature(&currentTemperature)) < 0)
+      {
+        TemperatureNP.s = IPS_ALERT;
+        IDSetNumber(&TemperatureNP, "Unknown error while reading  Robofocus temperature");
+        return;
+      }
+      TemperatureNP.s = IPS_OK;
+      IDSetNumber(&TemperatureNP, NULL);
+
+
+      currentBacklash= BACKLASH_READOUT ;
+      if(( ret= updateRFBacklash(&currentBacklash)) < 0)
+      {
+        SetBacklashNP.s = IPS_ALERT;
+        IDSetNumber(&SetBacklashNP, "Unknown error while reading  Robofocus backlash");
+        return;
+      }
+      SetBacklashNP.s = IPS_OK;
+      IDSetNumber(&SetBacklashNP, NULL);
+
+      currentDuty= currentDelay= currentTicks=0 ;
+
+      if(( ret= updateRFMotorSettings(&currentDuty, &currentDelay, &currentTicks )) < 0)
+      {
+        SettingsNP.s = IPS_ALERT;
+        IDSetNumber(&SettingsNP, "Unknown error while reading  Robofocus motor settings");
+        return;
+      }
+
+      SettingsNP.s = IPS_OK;
+      IDSetNumber(&SettingsNP, NULL);
+
+      if(( ret= updateRFPowerSwitches(-1, -1,  &cur_s1LL, &cur_s2LR, &cur_s3RL, &cur_s4RR)) < 0)
+      {
+        PowerSwitchesSP.s = IPS_ALERT;
+        IDSetSwitch(&PowerSwitchesSP, "Unknown error while reading  Robofocus power swicht settings");
+        return;
+      }
+
+      PowerSwitchesS[0].s= PowerSwitchesS[1].s= PowerSwitchesS[2].s= PowerSwitchesS[3].s= ISS_OFF ;
+
+      if(cur_s1LL== ISS_ON) {
+
+        PowerSwitchesS[0].s= ISS_ON ;
+      }
+      if(cur_s2LR== ISS_ON) {
+
+        PowerSwitchesS[1].s= ISS_ON ;
+      }
+      if(cur_s3RL== ISS_ON) {
+
+        PowerSwitchesS[2].s= ISS_ON ;
+      }
+      if(cur_s4RR== ISS_ON) {
+
+        PowerSwitchesS[3].s= ISS_ON ;
+      }
+      PowerSwitchesSP.s = IPS_OK ;
+      IDSetSwitch(&PowerSwitchesSP, NULL);
+
+
+      currentMaxTravel= MAXTRAVEL_READOUT ;
+      if(( ret= updateRFMaxPosition(&currentMaxTravel)) < 0)
+      {
+        MaxTravelNP.s = IPS_ALERT;
+        IDSetNumber(&MaxTravelNP, "Unknown error while reading  Robofocus maximum travel");
+        return;
+      }
+      MaxTravelNP.s = IPS_OK;
+      IDSetNumber(&MaxTravelNP, NULL);
+
+}
+
+bool RoboFocus::Move(FocusDirection dir, int speed, int duration)
+{
+    INDI_UNUSED(speed);
+    double pos=0;
+    struct timeval tv_start;
+    struct timeval tv_finish;
+    double dt=0;
+    gettimeofday (&tv_start, NULL);
+
+    while (duration > 0)
+    {
+
+        pos = RF_STEP_RES;
+
+    if (dir == FOCUS_INWARD)
+         updateRFPositionRelativeInward(&pos);
+    else
+        updateRFPositionRelativeOutward(&pos);
+
+        gettimeofday (&tv_finish, NULL);
+
+        dt = tv_finish.tv_sec - tv_start.tv_sec + (tv_finish.tv_usec - tv_start.tv_usec)/1e6;
+
+
+
+        duration -= dt * 1000;
+
+      // IDLog("dt is: %g --- duration is: %d -- pos: %g\n", dt, duration, pos);
+    }
+
+   return true;
+}
+
+
Index: /BAORadio/libindi/libindi/drivers/focuser/robofocus.h
===================================================================
--- /BAORadio/libindi/libindi/drivers/focuser/robofocus.h	(revision 646)
+++ /BAORadio/libindi/libindi/drivers/focuser/robofocus.h	(revision 646)
@@ -0,0 +1,102 @@
+/*
+    RoboFocus
+    Copyright (C) 2006 Markus Wildi (markus.wildi@datacomm.ch)
+                  2011 Jasem Mutlaq (mutlaqja@ikarustech.com)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+*/
+
+#ifndef ROBOFOCUS_H
+#define ROBOFOCUS_H
+
+#include "indibase/indifocuser.h"
+#include "robofocus.h"
+
+class RoboFocus : public INDI::Focuser
+{
+public:
+    RoboFocus();
+    ~RoboFocus();
+
+    virtual bool Connect();
+    virtual bool Disconnect();
+    const char * getDefaultName();
+    virtual bool initProperties();
+    virtual bool updateProperties();
+    virtual void ISGetProperties(const char *dev);
+    virtual bool ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n);
+    virtual bool ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n);
+    virtual bool ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
+    virtual bool Move(FocusDirection dir, int speed, int duration);
+
+private:
+
+    int PortFD;
+
+    unsigned char CheckSum(char *rf_cmd);
+    unsigned char CalculateSum(char *rf_cmd);
+    int SendCommand(char *rf_cmd);
+    int ReadResponse(char *buf, int nbytes, int timeout);
+    void GetFocusParams();
+
+    int updateRFPosition(double *value);
+    int updateRFTemperature(double *value) ;
+    int updateRFBacklash(double *value);
+    int updateRFFirmware(char *rf_cmd) ;
+    int updateRFMotorSettings(double *duty, double *delay, double *ticks);
+    int updateRFPositionRelativeInward(double *value);
+    int updateRFPositionRelativeOutward(double *value) ;
+    int updateRFPositionAbsolute(double *value);
+    int updateRFPowerSwitches(int s, int  new_sn, int *cur_s1LL, int *cur_s2LR, int *cur_s3RL, int *cur_s4RR) ;
+    int updateRFMaxPosition(double *value);
+    int updateRFSetPosition(double *value);
+
+    ITextVectorProperty PortTP;
+    IText PortT[1];
+
+    INumber TemperatureN[1];
+    INumberVectorProperty TemperatureNP;
+
+    INumber SettingsN[3];
+    INumberVectorProperty SettingsNP;
+
+    ISwitch PowerSwitchesS[4];
+    ISwitchVectorProperty PowerSwitchesSP;
+
+    INumber MinMaxPositionN[2];
+    INumberVectorProperty MinMaxPositionNP;
+
+    INumber MaxTravelN[1];
+    INumberVectorProperty MaxTravelNP;
+
+    INumber SetRegisterPositionN[1];
+    INumberVectorProperty SetRegisterPositionNP;
+
+    INumber PositionN[1];
+    INumberVectorProperty PositionNP;
+
+    INumber RelMovementN[1];
+    INumberVectorProperty RelMovementNP;
+
+    INumber AbsMovementN[1];
+    INumberVectorProperty AbsMovementNP;
+
+    INumber SetBacklashN[1];
+    INumberVectorProperty SetBacklashNP;
+
+};
+
+#endif // ROBOFOCUS_H
Index: ORadio/libindi/libindi/drivers/telescope/ServerSocket.cpp
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/ServerSocket.cpp	(revision 645)
+++ 	(revision )
@@ -1,94 +1,0 @@
-// Implementation of the ServerSocket class
-// Franck RICHARD
-// BAORadio
-
-#include "ServerSocket.h"
-#include "SocketException.h"
-#include <net/if.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-
-
-ServerSocket::ServerSocket ( int port )
-{
-    if ( ! Socket::create() )
-    {
-        throw SocketException ( "Could not create server socket." );
-    }
-
-    if ( ! Socket::bind ( port ) )
-    {
-        throw SocketException ( "Could not bind to port." );
-    }
-
-    if ( ! Socket::listen() )
-    {
-        throw SocketException ( "Could not listen to socket." );
-    }
-
-    Socket::set_non_blocking(true);
-}
-
-ServerSocket::~ServerSocket()
-{
-}
-
-
-const ServerSocket& ServerSocket::operator << ( const std::string& s ) const
-{
-    if ( ! Socket::send ( s ) )
-    {
-        throw SocketException ( "Could not write to socket." );
-    }
-
-    return *this;
-
-}
-
-
-const ServerSocket& ServerSocket::operator >> ( std::string& s ) const
-{
-    if ( ! Socket::recv ( s ) )
-    {
-        throw SocketException ( "Could not read from socket." );
-    }
-
-    return *this;
-}
-
-
-void ServerSocket::accept ( ServerSocket& sock )
-{
-    if ( ! Socket::accept ( sock ) )
-    {
-        throw SocketException ( "Could not accept socket." );
-    }
-}
-
-void ServerSocket::shutdown ( )
-{
-    if ( ! Socket::shutdown (  ) )
-    {
-        throw SocketException ( "Could not shutdown socket." );
-    }
-}
-
-void ServerSocket::create ( )
-{
-    if ( ! Socket::create (  ) )
-    {
-        throw SocketException ( "Could not create socket." );
-    }
-}
-
-bool ServerSocket::connect(std::string IP ) 
-{
-   return Socket::connect (IP, 8000);  
-}
-
-std::string ServerSocket::recupip( ServerSocket& sock)
-{ 
-   return ( Socket::recupip() ); 
-}
Index: ORadio/libindi/libindi/drivers/telescope/ServerSocket.h
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/ServerSocket.h	(revision 645)
+++ 	(revision )
@@ -1,34 +1,0 @@
-// Definition of the ServerSocket class
-
-#ifndef ServerSocket_class
-#define ServerSocket_class
-
-#include "Socket.h"
-
-
-
-
-class ServerSocket : private Socket
-{
- public:
-
-  ServerSocket ( int port );
-  ServerSocket (){};
-  virtual ~ServerSocket();
-
-  const ServerSocket& operator << ( const std::string& ) const;
-  const ServerSocket& operator >> ( std::string& ) const;
-  
-  void accept ( ServerSocket& );
-
-  void shutdown ( );
-  
-  void create();
-  
-  bool connect(std::string IP );
-  
-  std::string recupip( ServerSocket& );
-};
-
-
-#endif
Index: ORadio/libindi/libindi/drivers/telescope/Socket.cpp
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/Socket.cpp	(revision 645)
+++ 	(revision )
@@ -1,235 +1,0 @@
-// Implementation of the Socket class.
-
-
-#include "Socket.h"
-#include "string.h"
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <iostream>
-#include <netinet/tcp.h>
-
-
-
-Socket::Socket() :
-        m_sock ( -1 )
-{
-
-    memset ( &m_addr,
-             0,
-             sizeof ( m_addr ) );
-}
-
-Socket::~Socket()
-{
-    if ( is_valid() )
-        ::close ( m_sock );
-}
-
-bool Socket::create()
-{
-    m_sock = socket ( AF_INET,
-                      SOCK_STREAM,
-                      0); //IPPROTO_TCP
-
-    if ( ! is_valid() )
-        return false;
-
-
-    int on = 1;
-
-    if ( setsockopt ( m_sock, SOL_SOCKET, SO_REUSEADDR, ( const char* ) &on, sizeof ( on ) ) == -1 ) return false;
-
-    // RÃ©duire les dÃ©lais lors des transmissions TCP/IP
-    // Voir article Ã  l'adresse
-    // http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_MRG/1.0/html/Realtime_Tuning_Guide/sect-Realtime_Tuning_Guide-Application_Tuning_and_Deployment-TCP_NODELAY_and_Small_Buffer_Writes.html
-    
-    if ( setsockopt(m_sock, SOL_TCP, TCP_NODELAY, (const char*) &on, sizeof(on)) < 0 ) return false;
-
-    return true;
-}
-
-
-
-bool Socket::bind ( const int port )
-{
-    if ( ! is_valid() ) return false;
-    
-    m_addr.sin_family = AF_INET;
-    m_addr.sin_addr.s_addr = INADDR_ANY;
-    m_addr.sin_port =  htons ( port );
-
-    int bind_return = ::bind ( m_sock,
-                               ( struct sockaddr * ) &m_addr,
-                               sizeof ( m_addr ) );
-
-
-    if ( bind_return == -1 ) return false;
-    
-    return true;
-}
-
-
-bool Socket::listen() const
-{
-    if ( ! is_valid() ) return false;
-    
-    int listen_return = ::listen ( m_sock, MAXCONNECTIONS );
-
-    if ( listen_return == -1 ) return false;
-    
-    return true;
-}
-
-
-bool Socket::accept ( Socket& new_socket ) const
-{
-    int addr_length = sizeof ( m_addr );
-    
-    new_socket.m_sock = ::accept ( m_sock, ( sockaddr * ) &m_addr, ( socklen_t * ) &addr_length );
-
-    if ( new_socket.m_sock <= 0 ) return false;
-        
-    return true;
-}
-
-
-bool Socket::shutdown()
-{
-  int ret = 0;
-
-  if ( is_valid() )
-      ret =  ::shutdown ( m_sock, 2 );
-  
-  m_sock=-1;
-
-  if ( ret == 0 ) return true;
-
-  return false;
-}
-
-
-bool Socket::send ( const std::string s ) const
-{
-    if ( ! is_valid() ) return false;
-    
-    int status = ::send ( m_sock, s.c_str(), s.size(), MSG_NOSIGNAL);
-    
-    if ( status == -1 ) return false;
-        
-    return true;    
-}
-
-
-int Socket::recv ( std::string& s ) const
-{
-    int sel;
-    fd_set r;
-    struct timeval timeout;
-    
-    if ( ! is_valid() ) return false;
-    
-    s="";
-
-    timeout.tv_sec = 0; // initialise le timeout, ici  les secondes
-    timeout.tv_usec = 1; // les microsecondes
-
-    FD_ZERO(&r); // initialise la liste de fd
-    FD_SET(m_sock, &r); // ajoute la socket dans la liste des fd
-    sel = select(m_sock + 1, &r, NULL, NULL, &timeout);
-    if (sel < 0) // select a rencontrÃ© un problÃšme
-    {
-        return -1;
-    }
-    else if (sel == 0) // timeout
-    {
-	return 1;
-    }
-    else // quelque chose est Ã  lire sur un file descriptor
-    {
-        if (FD_ISSET(m_sock, &r)) // si la socket est prÃªte Ã  Ãªtre lue
-        {
-            char buf [ MAXRECV + 1 ];
-
-            s = "";
-
-            memset ( buf, 0, MAXRECV + 1 );
-
-            int status = ::recv ( m_sock, buf, MAXRECV, 0 );
-
-            if ( status == -1 )
-            {
-	         // lÃ , nous ne sommes pas en prÃ©sence d'une vraie erreur
-		 // car le mode non-bloquant est activÃ© ici
-		 // (consulter la doc de la fct recv...)
-                 if (errno == EAGAIN )
-		 {
-	           return 0;
-		 }
-		 
-		 return -1;
-            }
-            else if ( status == 0 )
-            {
-                return 0;
-            }
-            else
-            {
-                s = buf;
-                return status;
-            }
-        }
-    }
-}
-
-
-
-bool Socket::connect ( const std::string host, const int port )
-{
-    if ( ! is_valid() ) return false;
-    
-    memset ( &m_addr,
-             0,
-             sizeof ( m_addr ) );
-
-
-    m_addr.sin_family = AF_INET;
-    m_addr.sin_port = htons ( port );
-
-    int status = inet_pton ( AF_INET, host.c_str(), &m_addr.sin_addr );
-
-    if ( errno == EAFNOSUPPORT ) return false;
-
-    status = ::connect ( m_sock, ( sockaddr * ) &m_addr, sizeof ( m_addr ) );
-
-    if ( status == 0 ) return true;
-    
-    return false;
-}
-
-void Socket::set_non_blocking ( const bool b )
-{
-    int opts;
-
-    opts = fcntl ( m_sock,F_GETFL );
-
-    if ( opts < 0 )
-    {
-        return;
-    }
-
-    if ( b )
-        opts = ( opts | O_NONBLOCK );
-    else
-        opts = ( opts & ~O_NONBLOCK );
-
-    fcntl ( m_sock,
-            F_SETFL,opts );
-
-}
-
-
-std::string Socket::recupip() const
-{
-    return inet_ntoa(m_addr.sin_addr);
-}
Index: ORadio/libindi/libindi/drivers/telescope/Socket.h
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/Socket.h	(revision 645)
+++ 	(revision )
@@ -1,56 +1,0 @@
-// Definition of the Socket class
-
-#ifndef Socket_class
-#define Socket_class
-
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <string>
-#include <arpa/inet.h>
-
-
-const int MAXHOSTNAME = 501;
-const int MAXCONNECTIONS = 254;
-const int MAXRECV = 1024;
-
-  
-class Socket
-{
- public:
-  Socket();
-  virtual ~Socket();
-
-  // Server initialization
-  bool create();
-  bool bind ( const int port );
-  bool listen() const;
-  bool accept ( Socket& ) const;
-
-  // Client initialization
-  bool connect ( const std::string host, const int port );
-
-  // Data Transimission
-  bool send ( const std::string ) const;
-  int recv ( std::string& ) const;
-
-  std::string recupip() const;
-
-  void set_non_blocking ( const bool );
-
-  bool is_valid() const { return m_sock != -1; }
-
-  bool shutdown();
-  
- private:
-
-  int m_sock;
-  sockaddr_in m_addr;
-
-};
-
-
-#endif
Index: ORadio/libindi/libindi/drivers/telescope/SocketException.h
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/SocketException.h	(revision 645)
+++ 	(revision )
@@ -1,23 +1,0 @@
-// SocketException class
-
-
-#ifndef SocketException_class
-#define SocketException_class
-
-#include <string>
-
-class SocketException
-{
- public:
-  SocketException ( std::string s ) : m_s ( s ) {};
-  ~SocketException (){};
-
-  std::string description() { return m_s; }
-
- private:
-
-  std::string m_s;
-
-};
-
-#endif
Index: ORadio/libindi/libindi/drivers/telescope/astro.cpp
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/astro.cpp	(revision 645)
+++ 	(revision )
@@ -1,979 +1,0 @@
-////////////////////////////////
-// Classe Astro               //
-// Franck RICHARD             //
-// franckrichard033@gmail.com //
-// BAORadio                   //
-// juin 2011                  //
-////////////////////////////////
-
-
-#include "astro.h"
-
-
-/**************************************************************************************
-** Constructeur de la classe Astro
-***************************************************************************************/
-
-Astro::Astro()
-{
-    //Initialisation des variables
-    
-    Longitude = 0.0;                     // CordonnÃ©es du lieu d'observation
-    Latitude  = 0.0;
-    
-    Annee     = 0.0;                     // Date et heure de l'observation
-    Mois      = 0.0;
-    Jour      = 0.0;
-    Heure     = 0.0;
-    Min       = 0.0;
-    Sec       = 0.0;
-    UTCP      = 0.0;			 // permet de gÃ©rer le fuseau horaire
-                                         // mais semble inutile sous Linux
-    
-    hs        = 0.0;                     // fraction du jour en cours hs=(heure+min/60+secs/3600)/24.
-    ep        = 0.0;                     // obliquitÃ© de l'Ã©cliptique
-    tsl       = 0.0;                     // temps sidÃ©ral local
-    JJ        = 0.0;                     // Jour Julien
-    
-    CorP      = 0.0;                     // Nutation en longitude 
-    CorEP     = 0.0; 			 // Nutation en inclinaison
-     
-    LongitudeSoleil = 0.0;
-}
-
-Astro::~Astro()
-{
-}
-
-
-/**************************************************************************************
-** Initialisation des variables globales de la classe Astro
-***************************************************************************************/
-
-void Astro::DefinirDateHeure(double A, double M, double J, double H, double Mi, double S)
-{
-    Annee = A;
-    Mois = M;
-    Jour = J;
-    Heure = H;
-    Min = Mi;
-    Sec = S;
-}
-
-void Astro::DefinirPressionTemp(double P, double T)
-{
-    Pression = P;
-    Temp = T;
-}
-
-void Astro::DefinirLongitudeLatitude(double log, double lat)
-{
-    Longitude = log;
-    Latitude = lat;
-}
-
-
-
-/**************************************************************************************
-** ParamÃštre : angle en radians
-** retourne angle dans un intervalle 0 <= Angle <= 2*PI
-***************************************************************************************/
-
-double Astro::VerifAngle(double Angle)
-{
-    Angle=fmod(Angle, Pi2);
-    if (Angle<0.0) Angle+=Pi2;
-
-    return(Angle);
-}
-
-
-
-/**************************************************************************************
-** retourne l'arrondi du nombre donnÃ© en paramÃštre
-** Exemples: Arrondi(5.7) =  6
-**           Arrondi(-5.7)= -6
-***************************************************************************************/
-
-double Astro::Arrondi(double a)
-{
-    double b;
-
-    if (a>=0.0)
-    {
-        b=a-floor(a);
-        if (b>=0.5) return ceil(a);
-        else return floor(a);
-    }
-    else
-    {
-        b=ceil(a)-a;
-        if (b>=0.5) return floor(a);
-        else return ceil(a);
-    }
-}
-
-
-
-/**************************************************************************************
-** converti un angle (exprimÃ© en degrÃ©s) dans le format hh:mm:ss ou deg:mm:ss
-** selon la valeur de HMS
-***************************************************************************************/
-
-string Astro::DHMS(double mema, bool HMS)
-{
-    double d, m, s, a;
-
-    a=mema;
-
-    if (HMS) a=a / 15.0;
-    a=fabs(a * 3600.0);
-    s=Arrondi(fmod(a, 60.0) * 10.0) / 10.0;
-    a=floor(a / 60.0);
-    m=fmod(a, 60.0);
-    d=floor(a / 60.0);
-
-    if (s == 60.0)
-    {
-        s=0.0;
-        m+=1.0;
-        if (m==60.0)
-        {
-            m=0.0;
-            d+=1.0;
-
-            if (HMS && d>23.0) d=0.0;
-        }
-    }
-
-    stringstream strsTemp;
-
-    if (mema < 0) strsTemp << '-';
-
-    strsTemp << setfill('0') << setw(2) << d << ":" << m << ":" << s;
-
-    return (strsTemp.str());
-}
-
-
-/**************************************************************************************
-** Calcul de la longitude du Soleil
-** La quantitÃ© PS n'est pas indispensable. Elle permet d'amÃ©liorer la prÃ©cision
-***************************************************************************************/
-
-double Astro::CalculLongitudeSoleil()
-{
-    double T = (JJ - 2415020.0) / 36525.0;
-
-    double A = 153.23 + 22518.7541 * T;
-    double B = 216.57 + 44037.5082 * T;
-    double C = 312.69 + 32964.3577 * T;
-    double D = 350.74 + ( 445267.1142 - 0.00144 * T ) * T;
-    double E = 231.19 + 20.2 * T;
-
-
-    double L = 279.69668 + ( 36000.76892 + 0.0003025 * T ) * T;
-    double M = 358.47583 + (((( -0.0000033 * T) -0.00015 )  * T ) + 35999.04975 ) * T;
-
-    double CC =   (1.919460 + ((-0.000014 * T) - 0.004789 ) * T ) * sin(M * Pidiv180)
-                  + (0.020094 - 0.0001 * T) * sin(2.0 * M * Pidiv180)
-                  + 0.000293 * sin(3.0 * M * Pidiv180);
-
-    double PS =  0.00134 * cos(A * Pidiv180)
-                +0.00154 * cos(B * Pidiv180)
-                +0.00200 * cos(C * Pidiv180)
-                +0.00179 * sin(D * Pidiv180)
-                +0.00178 * sin(E * Pidiv180);
-
-
-    double LS = VerifAngle( (L + CC + PS) * Pidiv180);
-    
-    return LS;
-}
-
-
-
-/**************************************************************************************
-** Calcul de l'AD et la dÃ©clinaison du Soleil
-** indispensable pour exÃ©cuter la commande "goto sun"
-***************************************************************************************/
-
-void Astro::CalculARDecSoleil(Coordonnees *Soleil)
-{
-    double ar;
-    double de;
-    
-    ar = atan( cos(ep) * sin(LongitudeSoleil) / cos(LongitudeSoleil));
-    
-    if ( cos(LongitudeSoleil) < 0.0) ar += Pi;
-    
-    de = asin( sin(ep) * sin(LongitudeSoleil));
-
-    Soleil->ar = DHMS( VerifAngle(ar) * N180divPi, true );
-    
-    Soleil->dec = DHMS( de * N180divPi, false );
-}
-    
-
-
-
-/**************************************************************************************
-** Calcul de la nutation en longitude et en inclinaison
-** NÃ©cessaire pour calculer la position apparente d'un objet (Ã©toile, galaxie etc...)
-***************************************************************************************/
-
-void Astro::Nutation()
-{
-    double T = (JJ-2415020.0) / 36525.0;
-
-    double L  = (279.6967 + (36000.7689 + 0.000303 * T ) * T ) * Pidiv180;
-    double LP = (270.4342 + (481267.8831 - 0.001133 * T ) * T ) * Pidiv180;
-    double M  = (358.4758 + (35999.0498 - 0.000150 * T ) * T ) * Pidiv180;
-    double MP = (296.1046 + (477198.8491 + 0.009192 * T ) * T ) * Pidiv180;
-    double O  = (259.1833 + (-1934.1420 + 0.002078 * T ) * T ) * Pidiv180;
-
-    double L2  = 2.0 * L;
-    double LP2 = 2.0 * LP;
-    double O2  = 2.0 * O;
-    
-    // Nutation en longitude
-
-    CorP = -(17.2327 + 0.01737 * T) * sin(O)
-           -(1.2729+0.00013 * T) * sin(L2)
-           +0.2088 * sin(O2)
-           -0.2037 * sin(LP2)
-           +(0.1261 - 0.00031 * T) * sin(M)
-           +0.0675 * sin(MP)
-           -(0.0497 - 0.00012 * T) * sin(L2 + M)
-           -0.0342 * sin(LP2 - O)
-           -0.0261 * sin(LP2 + MP)
-           +0.0214 * sin(L2 - M)
-           -0.0149 * sin(L2 - LP2 + MP)
-           +0.0124 * sin(L2 - O)
-           +0.0114 * sin(LP2 - MP);
-	   
-    //Nutation en inclinaison
-
-    CorEP = (9.2100 + 0.00091 * T) * cos(O)
-            +(0.5522 - 0.00029 * T) * cos(L2)
-            -0.0904 * cos(O2)
-            +0.0884 * cos(LP2)
-            +0.0216 * cos(L2+M)
-            +0.0183 * cos(LP2-O)
-            +0.0113 * cos(LP2+MP)
-            -0.0093 * cos(L2-M)
-            -0.0066 * cos(L2-O);
-
-    CorP  = CorP / 3600.0 * Pidiv180;
-    CorEP = CorEP / 3600.0 * Pidiv180;
-}
-
-
-
-/**************************************************************************************
-** Nutation des Ã©toiles - on utilise les quantitÃ©s calculÃ©es prÃ©cÃ©demment
-** ar et de sont exprimÃ©s en radians
-***************************************************************************************/
-
-void Astro::NutationEtoile(double *ar, double *de)
-{
-    double a = (cos(ep) + sin(ep) * sin(*ar) * tan(*de)) * CorP - (cos(*ar) * tan(*de)) * CorEP;
-    double b = (sin(ep) * cos(*ar)) * CorP + sin(*ar) * CorEP;
-
-    *ar = VerifAngle(*ar+a);
-    *de += b;
-}
-
-
-/**************************************************************************************
-** PrÃ©cession des Ã©quinoxes
-** ar et de sont exprimÃ©s en radians
-***************************************************************************************/
-
-void Astro::Precession(double *ar, double *de)
-{
-    double t = (JJ - 2451544.5) / 36524.2199;
-
-    double ze = ((((0.018 * t) + 0.302) * t + 2304.948) * t) / 3600.0 * Pidiv180;
-    double z = ((((0.019 * t) + 1.093) * t + 2304.948) * t) / 3600.0 * Pidiv180;
-    double delta = ((((-0.042 * t) - 0.426) * t + 2004.255) * t) / 3600.0 * Pidiv180;
-
-
-    double A = cos(*de) * sin(*ar + ze);
-    double B = cos(delta) * cos(*de) * cos (*ar + ze) - sin(delta) * sin(*de);
-    double C = sin(delta) * cos(*de) * cos (*ar + ze) + cos(delta) * sin(*de);
-
-    double AMZ = atan(A / B);
-
-    if (B<0.0) AMZ += Pi;
-
-    *ar=VerifAngle(AMZ + z);
-    *de=asin(C);
-}
-
-
-
-/**************************************************************************************
-** ObliquitÃ©
-** calcul de l'inclinaison de l'axe terrestre par rapport Ã  au plan de l'Ã©cliptique
-** QuantitÃ© indispensable pour calculer le temps sidÃ©ral local et les coordonnÃ©es
-** horaires du soleil
-***************************************************************************************/
-
-void Astro::Obliquite(double JJ)
-{
-    double T;
-
-    T = (JJ - 2415020.0) / 36525.0;
-
-    ep = (23.452294+ (((0.000000503 * T ) - 0.00000164 ) * T - 0.0130125 ) * T ) * Pidiv180;
-}
-
-
-
-
-/**************************************************************************************
-** Aberration annuelle des Ã©toiles
-** ar et de sont exprimÃ©s en radians
-***************************************************************************************/
-
-void Astro::AberrationAnnuelle(double *ar, double *de)
-{
-    double c = -20.49 / 3600.0 * Pidiv180;
-    double a = c * ( cos(*ar) * cos(LongitudeSoleil) * cos(ep)
-                     + sin(*ar) * sin(LongitudeSoleil)
-                   ) / cos(*de);
-
-    double b = c * ( cos(LongitudeSoleil) * cos(ep) * (tan(ep) * cos(*de) - sin(*ar) * sin(*de))
-                     + cos(*ar) * sin(*de) * sin(LongitudeSoleil));
-
-    *ar = VerifAngle(*ar + a);
-    *de += b;
-}
-
-
-/**************************************************************************************
-** calcul Jour julien
-***************************************************************************************/
-
-void Astro::CalculJJ(double Heure)
-{
-    JJ = CalculJJ(Annee, Mois, Jour, Heure);    
-}
-
-double Astro::CalculJJ(double A, double M, double J, double Heure)
-{
-    long y, a, b, c, e, m;
-
-    long year = (long)A;
-    int month = (int)M;
-    double day = J + Heure;
-
-    y = year + 4800;
-
-    m = month;
-    if ( m <= 2 )
-    {
-        m += 12;
-        y -= 1;
-    }
-    e = (306 * (m+1))/10;
-
-    a = y/100;
-    if ( year <= 1582L )
-    {
-        if ( year == 1582L )
-        {
-            if ( month < 10 )
-                goto julius;
-            if ( month > 10)
-                goto gregor;
-            if ( day >= 15 )
-                goto gregor;
-        }
-julius:
-
-        b = -38;
-    }
-    else
-    {
-
-gregor:
-        b = (a / 4) - a;
-    }
-
-    c = (36525L * y) / 100;
-    
-    return b + c + e + day - 32167.5;
-}
-
-
-
-/**************************************************************************************
-** Temps sidÃ©ral local
-***************************************************************************************/
-
-double Astro::TSL(double JJ, double HeureSiderale, double Longitude)
-{
-    double T = (JJ - 2415020.0 ) / 36525.0;
-    double rd = 0.276919398 + ( 100.0021359 + 0.000001075 * T ) * T;
-    rd += HeureSiderale;
-    rd *= Pi2;
-    // temps sidÃ©ral apparent
-    rd += CorP * cos(ep);
-    rd -= Longitude;
-
-    return VerifAngle(rd);
-}
-
-
-/**************************************************************************************
-** routine principale des calculs
-***************************************************************************************/
-
-void Astro::CalculTSL()
-{
-    hs = (Heure + Min / 60.0 + Sec / 3600.0) / 24.0;
-
-    hs -= UTCP / 24.0;
-
-    CalculJJ(hs);
-
-    Obliquite(JJ);
-
-    Nutation();
-
-    tsl = TSL(JJ, hs, Longitude);
-
-    LongitudeSoleil = CalculLongitudeSoleil();
-}
-
-
-
-/**************************************************************************************
-** Calcule la hauteur et l'azimut des Ã©toiles en fct du lieu d'observation
-***************************************************************************************/
-
-void Astro::Azimut(double Ar, double De, double *azi, double *hau)
-{
-    double ah = tsl - Ar;
-
-    double zc = sin(Latitude) * sin(De) + cos(Latitude) * cos(De) * cos(ah);
-    double ht = atan(zc / sqrt((-zc * zc) + 1.0));
-
-    double a1 = cos(De) * sin(ah) / cos(ht);
-    double ac = (-cos(Latitude) * sin(De) + sin(Latitude) * cos(De) * cos(ah)) / cos(ht);
-    double az = atan(a1 / sqrt((-a1*a1)+1.0));
-
-    if (ac<0.0) az=Pi-az;
-
-    *azi=VerifAngle(Pi+az);
-    *hau=ht;
-}
-
-
-/**************************************************************************************
-** rÃ©fraction atmosphÃ©rique : formule simple de Jean Meeus
-** la hauteur ht est exprimÃ©e en radians
-***************************************************************************************/
-
-double Astro::RefractionAtmospherique(double ht)
-{
-    double gamma, R0, a, b, PressionTempCalc, tanHT;
-
-    if (Pression!=0.0)
-    {
-        PressionTempCalc = (Pression / 1013.25) * 273.0 / (273.0 + Temp);
-
-        if (ht <= 15.0 * Pidiv180)
-        {
-            gamma = 2.6;
-            a = 7.5262;
-            b = -2.2204;
-
-            if (ht >= 4.0 * Pidiv180)
-            {
-                gamma=-1.1;
-                a=4.4010;
-                b=-0.9603;
-            }
-
-            R0 = (pow((a+b*log(ht*N180divPi+gamma)), 2.0)) / 60.0 * Pidiv180;
-            ht += R0 * PressionTempCalc;
-        }
-        else
-        {
-            tanHT = fabs(tan(Pidiv2 - ht));
-            R0 = (0.0161877777777777777777-0.000022888888888888888 * tanHT * tanHT)
-                 * tanHT * Pidiv180;
-            ht += R0 * PressionTempCalc;
-        }
-    }
-
-    return ht;
-}
-
-
-
-
-double Astro::slaDrange(double angle )
-{
-    return fmod(angle, Pi);
-}
-
-float  Astro::slaRange(float angle )
-{
-    return fmodf(angle, Pi);
-}
-
-void Astro::slaRefro ( double zobs, double hm, double tdk, double pmb,
-                       double rh, double wl, double phi, double tlr,
-                       double eps, double *ref )
-/*
-**  - - - - - - - - -
-**   s l a R e f r o
-**  - - - - - - - - -
-**
-**  Atmospheric refraction for radio and optical wavelengths.
-**
-**  Given:
-**    zobs    double  observed zenith distance of the source (radian)
-**    hm      double  height of the observer above sea level (metre)
-**    tdk     double  ambient temperature at the observer (deg K)
-**    pmb     double  pressure at the observer (millibar)
-**    rh      double  relative humidity at the observer (range 0-1)
-**    wl      double  effective wavelength of the source (micrometre)
-**    phi     double  latitude of the observer (radian, astronomical)
-**    tlr     double  temperature lapse rate in the troposphere (degK/met
-**    eps     double  precision required to terminate iteration (radian)
-**
-**  Returned:
-**    ref     double  refraction: in vacuo ZD minus observed ZD (radian)
-**
-**  Notes:
-**
-**  1  A suggested value for the tlr argument is 0.0065D0.  The
-**     refraction is significantly affected by tlr, and if studies
-**     of the local atmosphere have been carried out a better tlr
-**     value may be available.
-**
-**  2  A suggested value for the eps argument is 1e-8.  The result is
-**     usually at least two orders of magnitude more computationally
-**     precise than the supplied eps value.
-**
-**  3  The routine computes the refraction for zenith distances up
-**     to and a little beyond 90 deg using the method of Hohenkerk
-**     and Sinclair (NAO Technical Notes 59 and 63, subsequently adopted
-**     in the Explanatory Supplement, 1992 edition - see section 3.281).
-**
-**  4  The C code is an adaptation of the Fortran optical refraction
-**     subroutine AREF of C.Hohenkerk (HMNAO, September 1984), with
-**     extensions to support the radio case.  The following modifications
-**     to the original HMNAO optical refraction algorithm have been made:
-**
-**     .  The angle arguments have been changed to radians.
-**
-**     .  Any value of zobs is allowed (see note 6, below).
-**
-**     .  Other argument values have been limited to safe values.
-**
-**     .  Murray's values for the gas constants have been used
-**        (Vectorial Astrometry, Adam Hilger, 1983).
-**
-**     .  The numerical integration phase has been rearranged for
-**        extra clarity.
-**
-**     .  A better model for Ps(T) has been adopted (taken from
-**        Gill, Atmosphere-Ocean Dynamics, Academic Press, 1982).
-**
-**     .  More accurate expressions for Pwo have been adopted
-**        (again from Gill 1982).
-**
-**     .  Provision for radio wavelengths has been added using
-**        expressions devised by A.T.Sinclair, RGO (private
-**        communication 1989), based on the Essen & Froome
-**        refractivity formula adopted in Resolution 1 of the
-**        13th International Geodesy Association General Assembly
-**        (Bulletin Geodesique 1963 p390).
-**
-**     .  Various small changes have been made to gain speed.
-**
-**     None of the changes significantly affects the optical results
-**     with respect to the algorithm given in the 1992 Explanatory
-**     Supplement.  For example, at 70 deg zenith distance the present
-**     routine agrees with the ES algorithm to better than 0.05 arcsec
-**     for any reasonable combination of parameters.  However, the
-**     improved water-vapour expressions do make a significant difference
-**     in the radio band, at 70 deg zenith distance reaching almost
-**     4 arcsec for a hot, humid, low-altitude site during a period of
-**     low pressure.
-**
-**  5  The radio refraction is chosen by specifying wl > 100 micrometres.
-**     Because the algorithm takes no account of the ionosphere, the
-**     accuracy deteriorates at low frequencies, below about 30 MHz.
-**
-**  6  Before use, the value of zobs is expressed in the range +/- pi.
-**     If this ranged zobs is -ve, the result ref is computed from its
-**     absolute value before being made -ve to match.  In addition, if
-**     it has an absolute value greater than 93 deg, a fixed ref value
-**     equal to the result for zobs = 93 deg is returned, appropriately
-**     signed.
-**
-**  7  As in the original Hohenkerk and Sinclair algorithm, fixed values
-**     of the water vapour polytrope exponent, the height of the
-**     tropopause, and the height at which refraction is negligible are
-**     used.
-**
-**  8  The radio refraction has been tested against work done by
-**     Iain Coulson, JACH, (private communication 1995) for the
-**     James Clerk Maxwell Telescope, Mauna Kea.  For typical conditions,
-**     agreement at the 0.1 arcsec level is achieved for moderate ZD,
-**     worsening to perhaps 0.5-1.0 arcsec at ZD 80 deg.  At hot and
-**     humid sea-level sites the accuracy will not be as good.
-**
-**  9  It should be noted that the relative humidity rh is formally
-**     defined in terms of "mixing ratio" rather than pressures or
-**     densities as is often stated.  It is the mass of water per unit
-**     mass of dry air divided by that for saturated air at the same
-**     temperature and pressure (see Gill 1982).
-**
-**  Called:  slaDrange, atmt, atms
-**
-**  Defined in slamac.h:  TRUE, FALSE
-**
-**  Last revision:   30 January 1997
-**
-**  Copyright P.T.Wallace.  All rights reserved.
-*/
-{
-    /* Fixed parameters */
-
-    static double d93 = 1.623156204; /* 93 degrees in radians        */
-    static double gcr = 8314.32;     /* Universal gas constant       */
-    static double dmd = 28.9644;     /* Molecular weight of dry air  */
-    static double dmw = 18.0152;     /* Molecular weight of water
-                                                             vapour */
-    static double s = 6378120.0;     /* Mean Earth radius (metre)    */
-    static double delta = 18.36;     /* Exponent of temperature
-                                         dependence of water vapour
-                                                           pressure */
-    static double ht = 11000.0;      /* Height of tropopause (metre) */
-    static double hs = 80000.0;      /* Upper limit for refractive
-                                                    effects (metre) */
-
-    /* Variables used when calling the internal routine atmt */
-    double robs;   /* height of observer from centre of Earth (metre) */
-    double tdkok;  /* temperature at the observer (deg K) */
-    double alpha;  /* alpha          |        */
-    double gamm2;  /* gamma minus 2  | see ES */
-    double delm2;  /* delta minus 2  |        */
-    double c1,c2,c3,c4,c5,c6;  /* various */
-
-    /* Variables used when calling the internal routine atms */
-    double rt;     /* height of tropopause from centre of Earth (metre) */
-    double tt;     /* temperature at the tropopause (deg k) */
-    double dnt;    /* refractive index at the tropopause */
-    double gamal;  /* constant of the atmospheric model = g*md/r */
-
-    int is, k, n, i, j, optic;
-    double zobs1, zobs2, hmok, pmbok, rhok, wlok, tol, wlsq, gb,
-    a, gamma, tdc, psat, pwo, w, tempo, dn0, rdndr0, sk0,
-    f0, rdndrt, zt, ft, dnts, rdndrp, zts, fts, rs,
-    dns, rdndrs, zs, fs, refold, z0, zrange, fb, ff, fo,
-    fe, h, r, sz, rg, dr, tg, dn, rdndr, t, f, refp, reft;
-
-    /* The refraction integrand */
-#define refi(R,DN,RDNDR) ((RDNDR)/(DN+RDNDR));
-
-
-
-    /* Transform zobs into the normal range */
-    zobs1 = slaDrange ( zobs );
-    zobs2 = fabs ( zobs1 );
-    zobs2 = gmin ( zobs2, d93 );
-
-    /* Keep other arguments within safe bounds */
-    hmok = gmax ( hm, -1000.0 );
-    hmok = gmin ( hmok, 10000.0 );
-    tdkok = gmax ( tdk, 100.0 );
-    tdkok = gmin ( tdkok, 500.0 );
-    pmbok = gmax ( pmb, 0.0 );
-    pmbok = gmin ( pmbok, 10000.0 );
-    rhok  = gmax ( rh, 0.0 );
-    rhok  = gmin ( rhok, 1.0 );
-    wlok  = gmax ( wl, 0.1 );
-    alpha = fabs ( tlr );
-    alpha = gmax ( alpha, 0.001 );
-    alpha = gmin ( alpha, 0.01 );
-
-    /* Tolerance for iteration */
-    w = fabs ( eps );
-    tol = gmin ( w, 0.1 ) / 2.0;
-
-    /* Decide whether optical or radio case - switch at 100 micron */
-    optic = ( wlok <= 100.0 );
-
-    /* Set up model atmosphere parameters defined at the observer */
-    wlsq = wlok * wlok;
-    gb = 9.784 * ( 1.0 - 0.0026 * cos ( 2.0 * phi ) - 2.8e-7 * hmok );
-    a = ( optic ) ?
-        ( ( 287.604 + 1.6288 / wlsq + 0.0136 / ( wlsq * wlsq ) )
-          * 273.15 / 1013.25 ) * 1e-6
-        :
-        77.624e-6;
-    gamal = gb * dmd / gcr;
-    gamma = gamal / alpha;
-    gamm2 = gamma - 2.0;
-    delm2 = delta - 2.0;
-    tdc = tdkok - 273.15;
-    psat = pow ( 10.0, ( 0.7859 + 0.03477 * tdc ) /
-                 ( 1.0 + 0.00412 * tdc ) ) *
-           ( 1.0 + pmbok * ( 4.5e-6 + 6e-10 * tdc * tdc ) );
-    pwo = ( pmbok > 0.0 ) ?
-          rhok * psat / ( 1.0 - ( 1.0 - rhok ) * psat / pmbok ) :
-          0.0;
-    w = pwo * ( 1.0 - dmw / dmd ) * gamma / ( delta - gamma );
-    c1 = a * ( pmbok + w ) / tdkok;
-    c2 = ( a * w + ( optic ? 11.2684e-6 : 12.92e-6 ) * pwo ) / tdkok;
-    c3 = ( gamma - 1.0 ) * alpha * c1 / tdkok;
-    c4 = ( delta - 1.0 ) * alpha * c2 / tdkok;
-    c5 = optic ? 0.0 : 371897e-6 * pwo / tdkok;
-    c6 = c5 * delm2 * alpha / ( tdkok * tdkok );
-
-    /* Conditions at the observer */
-    robs = s + hmok;
-    atmt ( robs, tdkok, alpha, gamm2, delm2, c1, c2, c3, c4, c5, c6, robs,
-           &tempo, &dn0, &rdndr0 );
-    sk0 = dn0 * robs * sin ( zobs2 );
-    f0 = refi ( robs, dn0, rdndr0 );
-
-    /* Conditions at the tropopause in the troposphere */
-    rt = s + ht;
-    atmt ( robs, tdkok, alpha, gamm2, delm2, c1, c2, c3, c4, c5, c6, rt,
-           &tt, &dnt, &rdndrt );
-    zt = asin ( sk0 / ( rt * dnt ) );
-    ft = refi ( rt, dnt, rdndrt );
-
-    /* Conditions at the tropopause in the stratosphere */
-    atms ( rt, tt, dnt, gamal, rt, &dnts, &rdndrp );
-    zts = asin ( sk0 / ( rt * dnts ) );
-    fts = refi ( rt, dnts, rdndrp );
-
-    /* At the stratosphere limit */
-    rs = s + hs;
-    atms ( rt, tt, dnt, gamal, rs, &dns, &rdndrs );
-    zs = asin ( sk0 / ( rs * dns ) );
-    fs = refi ( rs, dns, rdndrs );
-
-    /*
-    ** Integrate the refraction integral in two parts;  first in the
-    ** troposphere (k=1), then in the stratosphere (k=2).
-    */
-
-    /* Initialize previous refraction to ensure at least two iterations */
-    refold = 1e6;
-
-    /*
-    ** Start off with 8 strips for the troposphere integration, and then
-    ** use the final troposphere value for the stratosphere integration,
-    ** which tends to need more strips.
-    */
-    is = 8;
-
-    /* Troposphere then stratosphere */
-    for ( k = 1; k <= 2; k++ ) {
-
-        /* Start z, z range, and start and end values */
-        if ( k == 1 ) {
-            z0 = zobs2;
-            zrange = zt - z0;
-            fb = f0;
-            ff = ft;
-        } else {
-            z0 = zts;
-            zrange = zs - z0;
-            fb = fts;
-            ff = fs;
-        }
-
-        /* Sums of odd and even values */
-        fo = 0.0;
-        fe = 0.0;
-
-        /* First time through loop we have to do every point */
-        n = 1;
-
-        /* Start of iteration loop (terminates at specified precision) */
-        for ( ; ; ) {
-
-            /* Strip width */
-            h = zrange / (double) is;
-
-            /* Initialize distance from Earth centre for quadrature pass */
-            r = ( k == 1 ) ? robs : rt;
-
-            /* One pass (no need to compute evens after first time) */
-            for ( i = 1; i < is; i += n ) {
-
-                /* Sine of observed zenith distance */
-                sz = sin ( z0 + h * (double) i );
-
-                /* Find r (to nearest metre, maximum four iterations) */
-                if ( sz > 1e-20 ) {
-                    w = sk0 / sz;
-                    rg = r;
-                    j = 0;
-                    do {
-                        if ( k == 1 ) {
-                            atmt ( robs, tdkok, alpha, gamm2, delm2,
-                                   c1, c2, c3, c4, c5, c6, rg,
-                                   &tg, &dn, &rdndr );
-                        } else {
-                            atms ( rt, tt, dnt, gamal, rg, &dn, &rdndr );
-                        }
-                        dr = ( rg * dn - w ) / ( dn + rdndr );
-                        rg -= dr;
-                    } while ( fabs ( dr ) > 1.0 && j++ <= 4 );
-                    r = rg;
-                }
-
-                /* Find refractive index and integrand at r */
-                if ( k == 1 ) {
-                    atmt ( robs, tdkok, alpha, gamm2, delm2,
-                           c1, c2, c3, c4, c5, c6, r,
-                           &t, &dn, &rdndr );
-                } else {
-                    atms ( rt, tt, dnt, gamal, r, &dn, &rdndr );
-                }
-                f = refi ( r, dn, rdndr );
-
-                /* Accumulate odd and (first time only) even values */
-                if ( n == 1 && i % 2 == 0 ) {
-                    fe += f;
-                } else {
-                    fo += f;
-                }
-            }
-
-            /* Evaluate the integrand using Simpson's Rule */
-            refp = h * ( fb + 4.0 * fo + 2.0 * fe + ff ) / 3.0;
-
-            /* Has the required precision been reached? */
-            if ( fabs ( refp - refold ) > tol ) {
-
-                /* No: prepare for next iteration */
-                refold = refp;   /* Save current value for convergence test */
-                is += is;        /* Double the number of strips */
-                fe += fo;        /* Sum of all = sum of evens next time */
-                fo = 0.0;        /* Reset odds accumulator */
-                n = 2;           /* Skip even values next time */
-
-            } else {
-
-                /* Yes: save troposphere component and terminate loop */
-                if ( k == 1 ) reft = refp;
-                break;
-            }
-        }
-    }
-
-    /* Result */
-    *ref = reft + refp;
-    if ( zobs1 < 0.0 ) *ref = - ( *ref );
-
-    *ref+=Pidiv2-zobs1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-void Astro::atmt ( double robs, double tdkok, double alpha, double gamm2,
-                   double delm2, double c1, double c2, double c3,
-                   double c4, double c5, double c6, double r,
-                   double *t, double *dn, double *rdndr )
-/*
-**  - - - - -
-**   a t m t
-**  - - - - -
-**
-**  Internal routine used by slaRefro:
-**
-**    refractive index and derivative with respect to height for the
-**    troposphere.
-**
-**  Given:
-**    robs    double   height of observer from centre of the Earth (metre)
-**    tdkok   double   temperature at the observer (deg K)
-**    alpha   double   alpha          )
-**    gamm2   double   gamma minus 2  ) see ES
-**    delm2   double   delta minus 2  )
-**    c1      double   useful term  )
-**    c2      double   useful term  )
-**    c3      double   useful term  ) see source of
-**    c4      double   useful term  ) slaRefro main routine
-**    c5      double   useful term  )
-**    c6      double   useful term  )
-**    r       double   current distance from the centre of the Earth (metre)
-**
-**  Returned:
-**    *t      double   temperature at r (deg K)
-**    *dn     double   refractive index at r
-**    *rdndr  double   r * rate the refractive index is changing at r
-**
-**  This routine is derived from the ATMOSTRO routine (C.Hohenkerk,
-**  HMNAO), with enhancements specified by A.T.Sinclair (RGO) to
-**  handle the radio case.
-**
-**  Note that in the optical case c5 and c6 are zero.
-*/
-{
-    double w, tt0, tt0gm2, tt0dm2;
-
-    w = tdkok - alpha * ( r - robs );
-    w = gmin ( w, 320.0 );
-    w = gmax ( w, 200.0 );
-    tt0 = w / tdkok;
-    tt0gm2 = pow ( tt0, gamm2 );
-    tt0dm2 = pow ( tt0, delm2 );
-    *t = w;
-    *dn = 1.0 + ( c1 * tt0gm2 - ( c2 - c5 / w ) * tt0dm2 ) * tt0;
-    *rdndr = r * ( - c3 * tt0gm2 + ( c4 - c6 / tt0 ) * tt0dm2 );
-}
-
-/*--------------------------------------------------------------------------*/
-
-void Astro::atms ( double rt, double tt, double dnt, double gamal, double r,
-                   double *dn, double *rdndr )
-/*
-**  - - - - -
-**   a t m s
-**  - - - - -
-**
-**  Internal routine used by slaRefro:
-**
-**   refractive index and derivative with respect to height for the
-**   stratosphere.
-**
-**  Given:
-**    rt      double   height of tropopause from centre of the Earth (metre)
-**    tt      double   temperature at the tropopause (deg k)
-**    dnt     double   refractive index at the tropopause
-**    gamal   double   constant of the atmospheric model = g*md/r
-**    r       double   current distance from the centre of the Earth (metre)
-**
-**  Returned:
-**    *dn     double   refractive index at r
-**    *rdndr  double   r * rate the refractive index is changing at r
-**
-**  This routine is derived from the ATMOSSTR routine (C.Hohenkerk, HMNAO).
-*/
-{
-    double b, w;
-
-    b = gamal / tt;
-    w = ( dnt - 1.0 ) * exp ( - b * ( r - rt ) );
-    *dn = 1.0 + w;
-    *rdndr = - r * b * w;
-}
-
-
-
Index: ORadio/libindi/libindi/drivers/telescope/astro.h
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/astro.h	(revision 645)
+++ 	(revision )
@@ -1,113 +1,0 @@
-////////////////////////////////
-// Classe Astro               //
-// Franck RICHARD             //
-// BAORadio                   //
-// franckrichard033@gmail.com //
-// juin 2011                  //
-////////////////////////////////
-
-#ifndef Astro_class
-#define Astro_class
-
-#include "math.h"
-#include "stdio.h"
-#include <iostream>
-#include <string.h>
-#include <sstream>
-#include <iomanip>
-
-using namespace std;
-
-//////////////////////////////
-// Constantes MathÃ©matiques //
-//////////////////////////////
-
-#define Pi		3.14159265358979323846264338327
-#define Pidiv180	0.01745329251994329576923690768
-#define N180divPi	57.2957795130823208767981548141
-#define Pi2          	6.28318530717958647692528676655
-#define Pidiv2		1.57079632679489661923132169163
-
-#define gmax(A,B) ((A)>(B)?(A):(B))
-
-#define gmin(A,B) ((A)<(B)?(A):(B))
-
-
-struct Coordonnees
-{
-    string ar;				// CoordonnÃ©es horaires d'un objet
-    string dec;
-};
-
-class Astro 
-{
-public:
-    Astro();
-    ~Astro();
-
-    void   DefinirDateHeure(double Annee, double Mois, double Jour, double Heu, double Min, double Sec);
-    void   DefinirPressionTemp(double P, double T);
-    void   DefinirLongitudeLatitude(double log, double lat);
-    double VerifAngle(double Angle);
-    double Arrondi(double a);
-    string DHMS(double mema, bool HMS);
-    void   Azimut(double Ar, double De, double *azi, double *hau);
-    void   Precession(double *ar, double *de);
-    void   NutationEtoile(double *ar, double *de);
-    void   AberrationAnnuelle(double *ar, double *de);
-    void   CalculJJ(double Heure);
-    double CalculJJ(double A, double M, double J, double Heure);
-    void   CalculTSL();  
-    double RefractionAtmospherique(double ht);
-    double CalculLongitudeSoleil();
-    double TSL(double JJ,double HeureSiderale,double Longitude);
-    void   Nutation();
-    void   Obliquite(double JJ);
-    void   atms ( double rt, double tt, double dnt, double gamal, double r,
-                   double *dn, double *rdndr );
-    void   atmt ( double robs, double tdkok, double alpha, double gamm2,
-                   double delm2, double c1, double c2, double c3,
-                   double c4, double c5, double c6, double r,
-                   double *t, double *dn, double *rdndr );
-    void   slaRefro ( double zobs, double hm, double tdk, double pmb,
-                double rh, double wl, double phi, double tlr,
-                double eps, double *ref );
-    float  slaRange(float angle );
-    double slaDrange(double angle );
-    void   CalculARDecSoleil(Coordonnees *Soleil);
-    
-    
-    double GetAnnee() { return Annee; }
-    double GetMois()  { return Mois;  }
-    double GetJour()  { return Jour;  }
-    double GetHeure() { return Heure; }
-    double GetMin()   { return Min;   }
-    double GetSec()   { return Sec;   }
-    double GetJJ()    { return JJ;    }  
-
-  
-    
-    
-private:
-    double Longitude;
-    double Latitude;
-    double JJ;
-    double CorP;
-    double CorEP;
-    double Annee;
-    double Mois;
-    double Jour;
-    double Heure;
-    double Min;
-    double Sec;
-    double ep;
-    double hs;
-    double UTCP;
-    double tsl;
-    double LongitudeSoleil;
-    double Pression;
-    double Temp;
-};
-
-
-#endif
Index: ORadio/libindi/libindi/drivers/telescope/exception.c
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/exception.c	(revision 645)
+++ 	(revision )
@@ -1,36 +1,0 @@
-/* exception.c */
-/* fonctions de manipulation de la pile */
-
-#include "exception.h"
-
-except *_exceptions = NULL;
-
-/* empile */
-
-void push_exc(){
-  except* layer;
-  layer = (except*) malloc(sizeof(except));
-  if(layer == NULL){
-    fprintf(stderr,"[push_exc()]Erreur d'allocation memoire pour la pile");
-  }
-  layer->super = _exceptions;
-  _exceptions = layer;
-}
-
-/* depile */
-
-void pop_exc(int ex){
-  except* super;
-  super = _exceptions->super;
-  free(_exceptions);
-  _exceptions = super;
-  if(ex){
-    if(_exceptions){
-      longjmp(_exceptions->ctx, ex);
-    }
-    else{
-      fprintf(stderr, "Exception non geree : %d\n", ex);
-      exit(-1);
-    }
-  }
-}
Index: ORadio/libindi/libindi/drivers/telescope/exception.h
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/exception.h	(revision 645)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/* exception.h */
-#include <stdio.h>
-#include <stdlib.h>
-#include <setjmp.h>
-
-#ifndef __EXCEPTION__
-#define __EXCEPTION__  1
-
-/* exceptions de base */
-
-#define ERR_MALLOC     10
-#define NULL_POINTEUR  11
-#define ERR_FOPEN      12
-
-/*prototypes*/
-
-/* definition des structures de donnees de gestion de la pile des contextes 
-   et des macros TRY, CATCH, et ENDTRY */
-
-
-/* liste chainee des contextes */
-typedef struct except_ctx 
-{
-  jmp_buf ctx;
-  struct except_ctx* super;
-} except;
-extern except* _exceptions;
-
-/* les macros */
-#define TRY { \
-  int exc; \
-  push_exc(); \
-  exc = setjmp(_exceptions->ctx); \
-  switch(exc){ \
-  case 0:
-
-#define CATCH(X) \
-  break; \
-  case(X): \
-  exc = 0;
-
-#define ENDTRY \
-  break; \
-  default: \
-  pop_exc(exc); }\
-  }
-
-#define THROW(X) longjmp(_exceptions->ctx, X)
-
-
-void push_exc();
-void pop_exc(int);
-
-#endif
Index: ORadio/libindi/libindi/drivers/telescope/filetools.cpp
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/filetools.cpp	(revision 645)
+++ 	(revision )
@@ -1,1109 +1,0 @@
-/*filetools.c*/
-
-#include "filetools.h"
-
-#define MAX_LENGHT 255
-
-
-
-/******************************************************
- * NOM:              readINI                          *
- * SPECIFICATION:                                     *
- *   retourne la valeur de la cle du                  *
- *               fichier dont la structure est celle  *
- *               d'un fichier .ini windows            *
- * ARGUMENTS:                                         *
- * >section: le nom de la section sans les crochets   *
- * >key: nom de la cle de la section                  *
- * >pStr: pointeur pour mettre le resultat            *
- *       allocation memoire effectuee                 *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:0 si echec 1 si oui               *
- ******************************************************/
-int
-readINI (char *sectionName, char *pKeyName, char **ppStr, char *fileName)
-{
-    INI *pIni = NULL;
-    SECTION *pSection = NULL;
-    KEY *pKey = NULL;
-    int trouve = 0;
-    char *pSectionName = NULL;
-    int offset = 0;
- 
-
-    trouve = 0;
-    pIni = _loadINI (fileName);
-    if (!pIni) return 0;
-
-    /*recherche de la section */
-    offset = strlen (sectionName) + 3;
-    pSectionName = new char [offset];
-    pSectionName[0] = '[';
-    strcpy (pSectionName + 1, sectionName);
-    pSectionName[strlen (sectionName) + 1] = ']';
-    pSectionName[offset - 1]='\0';
-
-    pSection = _findSECTION (pIni, pSectionName);
-
-    delete [] pSectionName;
-
-    if (pSection != NULL)
-    {
-        /*recherche de la cle */
-        pKey = _findKEY (pSection, pKeyName);
-        if (pKey != NULL)
-        {
-            *ppStr = new char [strlen (pKey->value) + 2];
-            strcpy (*ppStr, pKey->value);
-            (*ppStr)[strlen (pKey->value)] = '\0';
-            trouve = 1;
-
-        }
-    }
-
-    //On efface toutes les clÃ©s et toutes les sections
-
-    KEY *keyprev=NULL;
-    SECTION * secprev=NULL;
-    pSection=pIni->fils;
-
-    do
-    {
-        pKey=pSection->fils;
-
-        do
-        {
-            if (pKey->name) delete [] pKey->name;
-            if (pKey->value) delete [] pKey->value;
-
-            keyprev=pKey;
-
-            KEY *prev=pKey;
-            pKey=pKey->next;
-
-            delete prev;
-
-        } while (pKey!=keyprev);
- 
-        if (pSection->name) delete [] pSection->name;
-
-        secprev=pSection;
-
-        SECTION *sprev=pSection;
-        pSection=pSection->next;
-
-        delete sprev;
-
-    }  while (pSection!=secprev);
-
-
-
-    delete [] pIni->fileName;
-    delete pIni;
-    pIni=NULL;
-
-    return trouve;
-}
-
-int
-readINI (const char *sectionName, const char *pKeyName, char **ppStr, const char *fileName)
-{
-     return readINI((char*)sectionName, (char*)pKeyName, ppStr, (char*)fileName);
-}
-
-/******************************************************
- * NOM:                delINI                         *
- * SPECIFICATION:                                     *
- *  seule la cle de la section est supprimee          *
- *  si la section est vide, elle est supprimee        *
- * ARGUMENTS:                                         *
- * >section: le nom de la section sans les crochets   *
- * >key: nom de la cle de la section                  *
- * >pStr: pointeur pour mettre la valeur de la cle    *
- *       avant sa suppression                         *
- *       allocation memoire effectuee                 *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- * 1 si reussite de la suppression, 0 sinon           *
- ******************************************************/
-/*
-int
-delINI (char *sectionName, char *pKeyName, char **ppStr, char *fileName)
-{
-  INI *pIni = NULL;
-  SECTION *pSection = NULL;
-  KEY *pKey = NULL;
-  int del = 0;
-  char *pSectionName = NULL;
-  int offset = 0;
-  //pStr = resultValue;
-  TRY
-  {
-
-    pIni = _loadINI (fileName);
-    //recherche de la section
-    offset = strlen (sectionName) + 3;
-    pSectionName = (char *) m_malloc (sizeof (char) * offset);
-    pSectionName[0] = '[';
-    strcpy (pSectionName + 1, sectionName);
-    pSectionName[strlen (sectionName) + 1] = ']';
-    pSectionName[offset - 1];
-
-    pSection = _findSECTION (pIni, pSectionName);
-
-    if (pSection != NULL)
-      {
-	if (pKeyName == NULL)
-	  {
-	    //on supprime toute la section
-
-	    pKey = _lastKEY (pSection);
-	    while (pKey != NULL)
-	      {
-		_delKEY (pKey);
-		pKey = _lastKEY (pSection);
-	      }
-	    _delSECTION (pSection);
-	    del = 1;
-	  }
-	else
-	  {
-	    //recherche de la cle si indiquee
-	    pKey = _findKEY (pSection, pKeyName);
-	    if (pKey != NULL)
-	      {
-		(*ppStr) =
-		  (char *) m_malloc (sizeof (char) * strlen (pKey->value) +
-				     2);
-		strcpy (*ppStr, pKey->value);
-		(*ppStr)[strlen (pKey->value)] = '\0';
-		if (_delKEY (pKey))
-		  {
-		    //si la cle supprimee etait la derniere de la section
-		    _delSECTION (pSection);
-		  }
-		del = 1;
-	      }
-	  }
-      }
-    if (del)
-      {
-	_saveINI (pIni);
-      }
-  }
-  CATCH (ERR_FOPEN)
-  {
-    printf ("impossible d'ouvrir le fichier %s\n", fileName);
-    (*ppStr) = NULL;
-  }
-  CATCH (ERR_MALLOC)
-  {
-    perror ("Probleme d'allocation memoire");
-    exit (EXIT_FAILURE);
-  }
-  ENDTRY;
-
-  return del;
-}
-*/
-/******************************************************
- * NOM:                writeINI                       *
- * SPECIFICATION:                                     *
- *  si la section n'existe pas elle est cree          *
- *  si la cle n'existe pas elle est cree              *
- *  et la valeur de la cle est initialisee            *
- *  sinon la cle existante de la section existante est*
- *  mise a jour                                       *
- * ARGUMENTS:                                         *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- *  NULL si echec ou keyValue si reussite             *
- ******************************************************/
-
-
-/*
-char * writeINI (char *sectionName, char *keyName, char *keyValue, char *fileName)
-{
-  char *pSectionName = NULL;
-  char *pKeyName = NULL;
-  char *pKeyValue = NULL;
-  INI  *pIni = NULL;
-  SECTION *pSection = NULL;
-  KEY *pKey = NULL;
-  TRY
-  {
-    pKeyName = new char [sizeof (char) * strlen (keyName) + 1];
-    pSectionName = new char [sizeof (char) * strlen (sectionName) + 3];
-    if (keyValue != NULL)
-      {
-	pKeyValue = new char [sizeof (char) * strlen (keyValue) + 1];
-	strcpy (pKeyValue, keyValue);
-	pKeyValue[strlen (keyValue)] = '\0';
-      }
-    else
-      {
-	pKeyValue = new char [sizeof (char)];
-	pKeyValue[0] = '\0';
-      }
-    strcpy (pKeyName, keyName);
-    pSectionName[0] = '[';
-    strcpy (pSectionName + 1, sectionName);
-    pSectionName[strlen (sectionName) + 1] = ']';
-    pSectionName[strlen (sectionName) + 2] = '\0';
-    //chargement
-    pIni = _loadINI (fileName);
-  }
-  CATCH (ERR_FOPEN)
-  {
-    printf ("Erreur en ouvrant le fichier .ini:%s\n", fileName);
-    exit (EXIT_FAILURE);
-  }
-  CATCH (ERR_MALLOC)
-  {
-    perror ("Probleme d'allocation memoire");
-    exit (EXIT_FAILURE);
-  }
-  ENDTRY;
-
-  //recherche de la section
-  pSection = _findSECTION (pIni, pSectionName);
-  //recherche de la cle
-  if (pSection != NULL)
-    {
-      pKey = _findKEY (pSection, pKeyName);
-      if (pKey != NULL)
-	{
-	  if (pKey->value != NULL) { delete [] pKey->value; pKey->value = NULL; pKey->value = new char [sizeof (char) * strlen (pKeyValue) + 1]; }
-	  
-	  if (pKey->value == NULL)
-	    {
-	      perror ("probleme de reallocation memoire");
-	      exit (EXIT_FAILURE);
-	    }
-	  strcpy (pKey->value, pKeyValue);
-	}
-      else
-	{
-	  //cle pas trouve dans la section, on ajoute la cle a la section
-	  pKey = _newKEY (pKeyName, pKeyValue);
-	  _addKEY (pSection, pKey);
-	}
-    }
-  else
-    {
-       //section pas trouve, on la cree avec sa cle
-      pSection = _newSECTION (pSectionName);
-      _addSECTION (pIni, pSection);
-      pKey = _newKEY (pKeyName, pKeyValue);
-      _addKEY (pSection, pKey);
-
-    }
-  TRY
-  {
-    //sauvegarde
-    _saveINI (pIni);
-
-  }
-  CATCH (ERR_FOPEN)
-  {
-    printf ("erreur sur le fichier %s", pIni->fileName);
-  }
-  ENDTRY;
-
-  //nettoyage
-  if (pKey->value != NULL) delete [] pKey->value; 
-  if (pKey != NULL) delete [] pKey;
-  if (pKeyName != NULL) delete [] pKeyName;
-  if (pSectionName != NULL) delete [] pSectionName;
-  if (pIni != NULL) delete [] pIni;
-  if (pSection != NULL) delete [] pSection;
-  pIni = NULL;
-  pKeyName = NULL;
-  pSectionName = NULL;
-  return pKeyValue;
-}
-*/
-
-/******************************************************
- * NOM:                                               *
- *                 _delKEY                            *
- * SPECIFICATION:                                     *
- * ARGUMENTS:                                         *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- *  1 si derniere cellule, 0 sinon, -1 si probleme    *
- ******************************************************/
-int
-_delKEY (KEY * pKey)
-{
-    int result = 0;
-    if (pKey != NULL)
-    {
-        /*la cle n'est pas la premiere */
-        if (pKey->prev != pKey)
-        {
-            if (pKey->next != pKey)
-            {
-                /*la cle n'est pas la derniere */
-                pKey->prev->next = pKey->next;
-            }
-            else
-            {
-                result = 1;
-                pKey->prev->next = pKey->prev;
-            }
-        }
-        else
-        {
-            if (pKey->next != pKey)
-            {
-                /*la cle n'est pas non plus la derniere */
-                pKey->parent->fils = pKey->next;
-            }
-            else
-            {
-                result = 1;
-                pKey->parent->fils = NULL;
-            }
-        }
-        _freeKEY (pKey);
-        return result;
-    }
-    else
-    {
-        result = -1;
-        return result;
-    }
-}
-
-
-/******************************************************
- * NOM:                                               *
- *                 _delSECTION                        *
- * SPECIFICATION:                                     *
- * ARGUMENTS:                                         *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- *  pointeur sur la section                           *
- ******************************************************/
-int
-_delSECTION (SECTION * pSection)
-{
-    if (pSection != NULL)
-    {
-        /*la cle n'est pas la premiere */
-        if (pSection->prev != pSection)
-        {
-            /*la cle n'est pas la derniere */
-            if (pSection->next != pSection)
-            {
-                pSection->prev->next = pSection->next;
-            }
-            else
-            {
-                pSection->prev->next = pSection->prev;
-            }
-        }
-        else
-        {
-            /*la cle n'estpas nonplus la derniere */
-            if (pSection->next != pSection)
-            {
-                pSection->parent->fils = pSection->next;
-                pSection->next->prev = pSection->next;
-            }
-            else
-            {
-                pSection->parent->fils = NULL;
-            }
-        }
-        _freeSECTION (pSection);
-        return 1;
-    }
-    else
-    {
-        return 0;
-    }
-}
-
-/************************
- * liberation memoire   *
- ************************/
-void
-_freeKEY (KEY * pKey)
-{
-    if (pKey != NULL)
-    {
-        pKey->parent = NULL;
-        pKey->next = NULL;
-        pKey->prev = NULL;
-        if (pKey->value != NULL)
-        {
-            delete [] pKey->value;
-        }
-        if (pKey->name != NULL)
-        {
-            delete [] pKey->name;
-        }
-        delete pKey;
-
-        pKey=NULL;
-    }
-}
-void
-_freeSECTION (SECTION * pSection)
-{
-    if (pSection != NULL)
-    {
-        pSection->parent = NULL;
-        pSection->next = NULL;
-        pSection->prev = NULL;
-        if (pSection->name != NULL)
-        {
-            delete [] pSection->name;
-        }
-        delete pSection;
-
-        pSection=NULL;
-    }
-}
-
-/******************************************************
- * NOM:                                               *
- *                 _newKEY                            *
- * SPECIFICATION:                                     *
- *  allocation d'une nouvelle cle                     *
- * ARGUMENTS:                                         *
- * le nom et la valeur de la cle                      *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- * pointeur sur la cle, NULL sinon                    *
- ******************************************************/
-KEY *
-_newKEY (char *pKeyName, char *pKeyValue)
-{
-    KEY *pKey;
-
-    {
-        pKey = new KEY;
-
-        pKey->name = new char [strlen (pKeyName) + 1];
-        pKey->value = new char [strlen (pKeyValue) + 1];
-    }
-
-
-    strcpy (pKey->name, pKeyName);
-    strcpy (pKey->value, pKeyValue);
-    pKey->parent = NULL;
-    pKey->prev = pKey;
-    pKey->next = pKey;
-
-    return pKey;
-}
-
-/******************************************************
- * NOM:                                               *
- *                 _newSECTION                        *
- * SPECIFICATION:                                     *
- *  allocation d'une nouvelle section                 *
- * ARGUMENTS:                                         *
- * le nom de la section                               *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- * pointeur sur la section, NULL sinon                *
- ******************************************************/
-SECTION *
-_newSECTION (char *pSectionName)
-{
-    SECTION *pSection;
-
-    {
-        pSection = new SECTION;
-
-        pSection->name = new char [strlen (pSectionName) + 1];
-    }
-
-
-    strcpy (pSection->name, pSectionName);
-    pSection->parent = NULL;
-    pSection->fils = NULL;
-    pSection->prev = pSection;
-    pSection->next = pSection;
-
-    return pSection;
-}
-
-/******************************************************
- * NOM:                                               *
- *                 _findSECTION                       *
- * SPECIFICATION:                                     *
- *  trouver la section dans une struture INI          *
- * ARGUMENTS:                                         *
- * la structure INI, le nom de la section avec ses [ ]*
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- * pointeur sur la section, NULL sinon                *
- ******************************************************/
-SECTION *
-_findSECTION (INI * pIni, char *pSectionName)
-{
-    SECTION *pSection = NULL;
-    pSection = pIni->fils;
-    while ((pSection != NULL) && (strcmp (pSection->name, pSectionName) != 0))
-    {
-        if (pSection == pSection->next)
-        {
-            pSection = NULL;
-        }
-        else
-        {
-            pSection = pSection->next;
-        }
-    }
-    return pSection;
-}
-
-/******************************************************
- * NOM:                                               *
- *                 _findKEY                           *
- * SPECIFICATION:                                     *
- *  trouver la cle dans une struture SECTION          *
- * ARGUMENTS:                                         *
- * la structure SECTION, le nom de la cle             *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- * pointeur sur la cle, NULL sinon                    *
- ******************************************************/
-KEY *
-_findKEY (SECTION * pSection, char *pKeyName)
-{
-    KEY *pKey = NULL;
-    pKey = pSection->fils;
-    while ((pKey != NULL) && (strcmp (pKey->name, pKeyName) != 0))
-    {
-        if (pKey == pKey->next)
-        {
-            pKey = NULL;
-        }
-        else
-        {
-            pKey = pKey->next;
-        }
-    }
-    return pKey;
-}
-
-/******************************************************
- * NOM:                                               *
- *                 _lastKEY                           *
- * SPECIFICATION:                                     *
- *  trouver la derniere cle dans une struture SECTION *
- * ARGUMENTS:                                         *
- * la structure SECTION                               *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- * pointeur sur la cle, NULL sinon                    *
- ******************************************************/
-KEY *
-_lastKEY (SECTION * pSection)
-{
-    KEY *pKey_pred = NULL;
-    KEY *pKey = NULL;
-    pKey = pSection->fils;
-    pKey_pred = pKey;
-    while (pKey != NULL)
-    {
-        pKey_pred = pKey;
-        if (pKey == pKey->next)
-        {
-            pKey = NULL;
-        }
-        else
-        {
-            pKey = pKey->next;
-        }
-    }
-    return pKey_pred;
-}
-
-/******************************************************
- * NOM:                                               *
- *                 _lastSECTION                       *
- * SPECIFICATION:                                     *
- *  trouver la derniere section dans une INI          *
- * ARGUMENTS:                                         *
- * la structure INI                                   *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- * pointeur sur la section, NULL sinon                *
- ******************************************************/
-SECTION *
-_lastSECTION (INI * pIni)
-{
-    SECTION *pSection_pred = NULL;
-    SECTION *pSection = NULL;
-    pSection = pIni->fils;
-    pSection_pred = pSection;
-    while (pSection != NULL)
-    {
-        pSection_pred = pSection;
-        if (pSection == pSection->next)
-        {
-            pSection = NULL;
-        }
-        else
-        {
-            pSection = pSection->next;
-        }
-    }
-    return pSection_pred;
-}
-
-/******************************************************
- * NOM:                                               *
- *                 _addSECTION                        *
- * SPECIFICATION:                                     *
- *  ajoute une section en derniere place dans une INI *
- *  la section ne doit pas appartenir a une INI       *
- * ARGUMENTS:                                         *
- * la structure INI, la structure SECTION             *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- * pointeur sur la section, NULL sinon                *
- ******************************************************/
-SECTION *
-_addSECTION (INI * pIni, SECTION * pSection)
-{
-    SECTION *pSection_last = NULL;
-
-    if (pSection->parent != NULL)
-    {
-        return NULL;
-    }
-    else
-    {
-        pSection_last = _lastSECTION (pIni);
-        pSection->parent = pIni;
-        if (pSection_last != NULL)
-        {
-            pSection_last->next = pSection;
-            pSection->prev = pSection_last;
-        }
-        else
-        {
-            pIni->fils = pSection;
-        }
-        return pSection;
-    }
-}
-
-/******************************************************
- * NOM:                                               *
- *                 _addKEY                            *
- * SPECIFICATION:                                     *
- *  ajoute une cle en derniere place dans une SECTION *
- *  la section ne doit pas appartenir a une SECTION   *
- * ARGUMENTS:                                         *
- * la structure KEY, la structure SECTION             *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- * pointeur sur la cle, NULL sinon                *
- ******************************************************/
-KEY *
-_addKEY (SECTION * pSection, KEY * pKey)
-{
-    KEY *pKey_last = NULL;
-
-    if (pKey->parent != NULL)
-    {
-        return NULL;
-    }
-    else
-    {
-
-        pKey_last = _lastKEY (pSection);
-        pKey->parent = pSection;
-        if (pKey_last != NULL)
-        {
-            pKey_last->next = pKey;
-            pKey->prev = pKey_last;
-        }
-        else
-        {
-            pSection->fils = pKey;
-        }
-        pKey->next = pKey;
-        return pKey;
-    }
-}
-
-/******************************************************
- * NOM:                                               *
- *                 saveINI                            *
- * SPECIFICATION:                                     *
- *  sauvegarde de la structure INI dans son fichier   *
- *  Attention, ecrase l'ancien fichier                *
-* ARGUMENTS:                                         *
-*  pointeur sur la structure INI a sauvegarder       *
-* ENVIRONNEMENT:                                     *
-* VALEUR RETOURNEE:                                  *
-*  -1 si un probleme a eu lieu, 0 sinon              *
-******************************************************/
-
-/*
- int
-_saveINI (INI * pIni)
-{
-  FILE *pFile = NULL;
-  char *str = NULL;
-  SECTION *pSection_pred = NULL, *pSection = NULL;
-  KEY *pKey_pred = NULL, *pKey = NULL;
-  int offset = 0;
-
-  pFile = fopen (pIni->fileName, "w");
-  if (pFile == NULL)
-    THROW (ERR_FOPEN);
-  //printf("#SAUVEGARDE Fichier INI#\n");
-  //printf("# %s #\n\n",pIni->fileName);
-  if (pIni->fils != NULL)
-    {
-      pSection = pIni->fils;
-      do
-	{
-
-	  fprintf (pFile, pSection->name);
-	  fprintf (pFile, "\n");
-	  pKey = pSection->fils;
-	  do
-	    {
-
-	      offset = strlen (pKey->name) + strlen (pKey->value) + 2;
-
-	      TRY
-	      {
-		str = new char [sizeof (char) * offset];
-	      }
-	      CATCH (ERR_MALLOC)
-	      {
-		perror ("probleme d'allocation memoire");
-		exit (EXIT_FAILURE);
-	      }
-	      ENDTRY;
-	      memset (str, 0, offset);
-	      strcpy (str, pKey->name);
-	      offset = strlen (pKey->name);
-	      strcpy (str + offset, "=");
-	      offset = strlen (pKey->name) + 1;
-	      strcpy (str + offset, pKey->value);
-	      fprintf (pFile, str);
-	      fprintf (pFile, "\n");
-	      pKey_pred = pKey;
-	      pKey = pKey->next;
-	      delete [] str;
-	    }
-	  while (pKey != pKey_pred);
-
-	  pSection_pred = pSection;
-	  pSection = pSection->next;
-	}
-      while (pSection != pSection_pred);
-    }
-  //nettoyage
-  fclose (pFile);
-}*/
-
-/******************************************************
- * NOM:                                               *
- *                  loadINI                           *
- * SPECIFICATION:                                     *
- *  Charge le contenu d'un fichier .ini en memoire    *
- * ARGUMENTS:                                         *
- *  nom du fichier                                    *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- *  pointeur sur la structure INI contenant le fichier*
- *  .ini avec les structures decrites dans le .h      *
- * EXCEPTION:                                         *
- * ERR_FOPEN, ERR_MALLOC
- ******************************************************/
-INI *
-_loadINI (char *fileName)
-{
-    FILE *pFile = NULL;
-    char *pBuf;
-    int nbRead = 0;
-    SECTION *pSection = NULL;
-    KEY *pKey = NULL;
-
-    INI *pIni = NULL;
-    pBuf = new char [MAX_LENGHT];
-
-    pFile = fopen (fileName, "r");
-    if (pFile == NULL)
-    {
-        pFile = fopen (fileName, "a");
-        if (pFile == NULL)
-            
-        return NULL;
-    }
-
-    pIni = new INI;
-    pIni->fileName = new char [strlen (fileName) + 1];
-    strcpy (pIni->fileName, fileName);
-    pIni->fils = NULL;
-    /* on lit ligne par ligne */
-    nbRead = readline (pFile, pBuf);
-  //  if (nbRead==-1) { fclose(pFile); delete  [] pIni->fileName; delete pIni; delete [] pBuf; return 0;}
-    while (nbRead != -1)
-    {
-
-        if ((pBuf[0] == '[') && (pBuf[strlen (pBuf) - 1] == ']'))
-        {
-            /* une section */
-            pSection = NULL;
-
-            pSection = _newSECTION (pBuf);
-            _addSECTION (pIni, pSection);
-        }
-
-        /* les cles de la section */
-        while (((nbRead = readline (pFile, pBuf)) !=-1) && (pBuf[0] != '['))
-        {
-            int ind = 0;
-            pKey = NULL;
-            if ((ind = _isKey (pBuf)) >= 0)
-            {
-
-                char *strName = NULL;
-                strName = new char [ind + 1];
-                strncpy (strName, pBuf, ind);
-                strName[ind] = '\0';
-                pKey = _newKEY (strName, pBuf + ind + 1);
-                _addKEY (pSection, pKey);
-                delete [] strName;
-            }
-        }
-    }
-
-    /*nettoyage */
-    delete [] pBuf;
-    fclose (pFile);
-    return pIni;
-}
-
-/******************************************************
- * NOM:                                               *
- *                 _isKey                             *
- * SPECIFICATION:                                     *
- *  determine si une chaine est une cle valide        *
- * ARGUMENTS:                                         *
- *  pointeur sur la chaine                            *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- *  indice du signe '=' si oui, -1 sinon              *
- ******************************************************/
-int
-_isKey (char *str)
-{
-    int ind = 0;
-    for (ind; (ind < strlen (str)) && (str[ind] != '='); ind++);
-    if (str[ind] == '=')
-        return ind;
-    else
-        return -1;
-}
-
-
-/******************************************************
- * NOM:                                               *
- *                  _printINI                         *
- * SPECIFICATION:                                     *
- * affiche a l'ecran le contenu de structure INI      *
- * ARGUMENTS:                                         *
- *  pointeur sur la structure INI                     *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- ******************************************************/
-/*void
-_printINI (INI * pIni)
-{
-  SECTION *pSection_pred = NULL;
-  SECTION *pSection = NULL;
-  printf ("#Fichier INI#\n");
-  printf ("# %s #\n\n", pIni->fileName);
-  pSection = pIni->fils;
-  if (pSection != NULL)
-    {
-      do
-	{
-	  _printSECTION (pSection);
-	  pSection_pred = pSection;
-	  pSection = pSection->next;
-	}
-      while (pSection != pSection_pred);
-    }
-  printf ("\n#Fin du fichier INI#\n");
-}*/
-
-/******************************************************
- * NOM:                                               *
- *                  _printSECTION                     *
- * SPECIFICATION:                                     *
- * affiche a l'ecran le contenu de structure SECTION  *
- * ARGUMENTS:                                         *
- *  pointeur sur la structure SECTION                 *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- ******************************************************/
-/*void
-_printSECTION (SECTION * pSection)
-{
-  KEY *pKey = NULL;
-  KEY *pKey_pred = NULL;
-  printf ("%s\n", pSection->name);
-  pKey = pSection->fils;
-  if (pKey != NULL)
-    {
-      do
-	{
-	  _printKEY (pKey);
-	  pKey_pred = pKey;
-	  pKey = pKey->next;
-	}
-      while (pKey != pKey_pred);
-    }
-}*/
-
-/******************************************************
- * NOM:                                               *
- *                  _printKEY                         *
- * SPECIFICATION:                                     *
- * affiche a l'ecran le contenu de structure SECTION  *
- * ARGUMENTS:                                         *
- *  pointeur sur la structure SECTION                 *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- ******************************************************/
-/*
- * void
-_printKEY (KEY * pKey)
-{
-  printf ("%s=%s\n", pKey->name, pKey->value);
-}*/
-
-/******************************************************
- * NOM:                                               *
- *                  printINI                          *
- * SPECIFICATION:                                     *
- * affiche a l'ecran le contenu du fichier .ini       *
- * ARGUMENTS:                                         *
- *  nom du fichier                                    *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- ******************************************************/
-
-/*void
-printINI (char *file)
-{
-  INI *pIni = NULL;
-  TRY
-  {
-    pIni = _loadINI (file);
-  }
-  CATCH (ERR_MALLOC)
-  {
-    printf ("Erreur d'allocation memoire en chargeant le fichier .ini:%s\n",
-	    file);
-    exit (EXIT_FAILURE);
-  }
-  CATCH (ERR_FOPEN)
-  {
-    printf ("Erreur en ouvrant le fichier .ini:%s\n", file);
-    exit (EXIT_FAILURE);
-  }
-  ENDTRY;
-  _printINI (pIni);
-  free (pIni);
-}*/
-
-/******************************************************
- * NOM:                 jumpline                      *
- * SPECIFICATION:                                     *
- * fonction permettant de sauter des lignes dans le   *
- * fichier a partir de la position courante dans le   *
- * fichier                                            *
- * ARGUMENTS:                                         *
- * nombre de lignes a saute, pointeur sur le fichier  *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE: nombre de lignes sautees         *
- ******************************************************/
-
-int
-jumpline (int nbline, FILE * pfile)
-{
-    int compteur = 0, c;
-
-    while ((compteur < nbline) && ((c = getc (pfile)) != EOF))
-    {
-        if (c == '\n')
-            compteur++;
-    }
-    return (compteur);
-}
-
-/******************************************************
- * NOM:                readline                       *
- * SPECIFICATION:                                     *
- * recupere la ligne courante du fichier et renvoie le*
- * nombre de caracteres lus                           *
- * ARGUMENTS:                                         *
- * pointeur sur le fichier a lire                     *
- * pointeur sur le tableau recevant la ligne          *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- * nombre de caracteres lus                           *
- ******************************************************/
-int
-readline (FILE * pfile, char *tab)
-{
-    int nbchar = 0;
-    char c;
-    while ((c = getc (pfile)) != '\n')
-    {
-        if (c == EOF)
-        {
-            break;
-        }
-        tab[nbchar++] = c;
-    }
-    tab[nbchar] = '\0';
-
-    while (nbchar>0 && tab[nbchar-1]==' ') {
-        tab[--nbchar] = '\0';
-    }
-
-    while (tab[0]==' ') for (int i=1; i<=nbchar; i++) tab[i-1]=tab[i];
-
-    if (c == EOF) nbchar=-1;
-
-    return (nbchar);
-}
-
-/******************************************************
- * NOM:                m_malloc                       *
- * SPECIFICATION:                                     *
- *  clone de malloc renvoyant une exception           *
- * ARGUMENTS:                                         *
- * ENVIRONNEMENT:                                     *
- * VALEUR RETOURNEE:                                  *
- ******************************************************/
-
-/*
-void * m_malloc (size_t size)
-{
-  void *ptr = malloc (size);
-  if (ptr == NULL)
-    THROW (ERR_MALLOC);
-  else
-    return ptr;
-}*/
Index: ORadio/libindi/libindi/drivers/telescope/filetools.h
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/filetools.h	(revision 645)
+++ 	(revision )
@@ -1,109 +1,0 @@
-/*******************************************************
-                          filetools.h
-                          -----------
-    begin                : Wed Dec 13 2000
-    copyright            : (C) 2000 by Sylvain Le Petit 
-    email                : sylvainlepetit@wanadoo.fr
- *******************************************************/
-#include <stdio.h>
-#include <string.h>
-#include "exception.h"
-/* Structures de donnees */
-
-
-typedef struct section
-{
-  char *name;
-  struct key *fils;
-  struct ini *parent;
-  struct section *prev;
-  struct section *next;
-
-}
-SECTION;
-
-typedef struct key
-{
-  char *name;
-  char *value;
-  SECTION *parent;
-  struct key *prev;
-  struct key *next;
-}
-KEY;
-
-typedef struct ini
-{
-  char *fileName;
-  SECTION *fils;
-}
-INI;
-
-/* declaration des prototypes*/
- /*PUBLIC*/ int jumpline (int nbline, FILE * pfile);
-int readline (FILE * pfile, char *tab);
-/*************************************************************************
-gestion des fichier .ini
-**************************************************************************/
-
-int readINI (char *section, char *key, char **ppStr, char *fileName);
-/*******************************************************************************
- lire une valeur
-
-section: nom de la section
-key : nom de la cle
-ppStr: adresse du pointeur sur la valeur de la cle retour, NULL si pas trouve, memoire allouee dans la fonction
-fileName : nom du fichier contenant les cles, pas forcement xxx.ini c'est pas obligatoire
-
-**********************************************************************************/
-int readINI (const char *sectionName, const char *pKeyName, char **ppStr, const char *fileName);
-
-char *writeINI (char *section, char *key, char *pKeyValue, char *fileName);
-/*******************************************************************************
-  ecrire une cle avec sa valeur, que se soit une nouvelle cle ou un mise a jour
-c'est pareil
-
-section: nom de la section
-key : nom de la cle
-pKeyValue: valeur de la cle, evitez de mettre NULL pas encore tester ce cas limite
-fileName : nom du fichier contenant les cles, pas forcement xxx.ini c'est pas obligatoire
-
- *******************************************************************************/
-
-int delINI (char *sectionName, char *pKeyName, char **ppStr, char *fileName);
-/*************************************************************************/
-/* permet de supprimer une cle ou une section complete                   */
-/* >suppression d'une cle, donner le nomde la section et le nom de la cle*/
-/*  si la section est vide elle est supprimee                            */
-/* >suppression d'une section complete, mettre NULL comme nom de cle     */
-/*************************************************************************/
-
-void printINI (char *fileName);
-/*****************************************************************/
-/*  permet d'afficher le contenu du fichier .ini, seulement les: */
-/*  [section]                                                    */
-/*  cle=valeur                                                   */
-/*****************************************************************/
-
-
-
-/*PRIVATE: ne pas utiliser directement*/
-int _saveINI (INI * ini);
-INI *_loadINI (char *fileName);
-void _printINI (INI * pIni);
-void _printSECTION (SECTION * pSection);
-void _printKEY (KEY * pKey);
-KEY *_newKEY (char *pKeyName, char *pKeyValue);
-SECTION *_newSECTION (char *pSectionName);
-SECTION *_findSECTION (INI * pIni, char *pSectionName);
-KEY *_findKEY (SECTION * pSection, char *pKeyName);
-KEY *_lastKEY (SECTION * pSection);
-SECTION *_lastSECTION (INI * pIni);
-SECTION *_addSECTION (INI * pIni, SECTION * pSection);
-KEY *_addKEY (SECTION * pSection, KEY * pKey);
-int _isKey (char *str);
-void *m_malloc (size_t size);	/*renvoi l'exception ERR_MALLOC */
-void _freeKEY (KEY * pKey);
-void _freeSECTION (SECTION * pSection);
-int _delKEY (KEY * pKey);
-int _delSECTION (SECTION * pSection);
Index: /BAORadio/libindi/libindi/drivers/telescope/ieq45.cpp
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/ieq45.cpp	(revision 646)
+++ /BAORadio/libindi/libindi/drivers/telescope/ieq45.cpp	(revision 646)
@@ -0,0 +1,816 @@
+#if 0
+    IEQ45 Basic Driver
+    Copyright (C) 2011 Nacho Mas (mas.ignacio@gmail.com). Only litle changes
+    from lx200basic made it by Jasem Mutlaq (mutlaqja@ikarustech.com) 
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <math.h>
+#include <unistd.h>
+#include <time.h>
+#include <memory>
+
+#include <config.h>
+
+/* INDI Common Library Routines */
+#include "indicom.h"
+
+/* IEQ45 Command Set */
+#include "ieq45driver.h"
+
+/* Our driver header */
+#include "ieq45.h"
+
+using namespace std;
+
+/* Our telescope auto pointer */
+auto_ptr<IEQ45Basic> telescope(0);
+
+const int POLLMS = 100;				// Period of update, 1 second.
+const char *mydev = "IEQ45";				// Name of our device.
+
+const char *BASIC_GROUP    = "Main Control";		// Main Group
+const char *OPTIONS_GROUP  = "Options";			// Options Group
+
+/* Handy Macros */
+#define currentRA	EquatorialCoordsRN[0].value
+#define currentDEC	EquatorialCoordsRN[1].value
+#define targetRA	EquatorialCoordsWN[0].value
+#define targetDEC	EquatorialCoordsWN[1].value
+
+static void ISPoll(void *);
+static void retry_connection(void *);
+
+/**************************************************************************************
+** Send client definitions of all properties.
+***************************************************************************************/
+void ISInit()
+{
+ static int isInit=0;
+
+ if (isInit)
+  return;
+
+ if (telescope.get() == 0) telescope.reset(new IEQ45Basic());
+
+ isInit = 1;
+ 
+ IEAddTimer (POLLMS, ISPoll, NULL);
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void ISGetProperties (const char *dev)
+{
+ ISInit(); 
+ telescope->ISGetProperties(dev);
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
+{
+ ISInit();
+ telescope->ISNewSwitch(dev, name, states, names, n);
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
+{
+ ISInit();
+ telescope->ISNewText(dev, name, texts, names, n);
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
+{
+ ISInit();
+ telescope->ISNewNumber(dev, name, values, names, n);
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void ISPoll (void *p)
+{
+ INDI_UNUSED(p);
+
+ telescope->ISPoll(); 
+ IEAddTimer (POLLMS, ISPoll, NULL);
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
+{
+  INDI_UNUSED(dev);
+  INDI_UNUSED(name);
+  INDI_UNUSED(sizes);
+  INDI_UNUSED(blobsizes);
+  INDI_UNUSED(blobs);
+  INDI_UNUSED(formats);
+  INDI_UNUSED(names);
+  INDI_UNUSED(n);
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void ISSnoopDevice (XMLEle *root) 
+{
+  INDI_UNUSED(root);
+}
+
+/**************************************************************************************
+** IEQ45 Basic constructor
+***************************************************************************************/
+IEQ45Basic::IEQ45Basic()
+{
+   init_properties();
+
+   lastSet        = -1;
+   fd             = -1;
+   simulation     = false;
+   lastRA 	  = 0;
+   lastDEC	  = 0;
+   currentSet     = 0;
+
+   IDLog("Initilizing from IEQ45 device...\n");
+   IDLog("Driver Version: 0.1 (2011-11-07)\n");
+ 
+   enable_simulation(false);  
+
+ }
+
+/**************************************************************************************
+**
+***************************************************************************************/
+IEQ45Basic::~IEQ45Basic()
+{
+
+}
+
+/**************************************************************************************
+** Initialize all properties & set default values.
+***************************************************************************************/
+void IEQ45Basic::init_properties()
+{
+    // Connection
+    IUFillSwitch(&ConnectS[0], "CONNECT", "Connect", ISS_OFF);
+    IUFillSwitch(&ConnectS[1], "DISCONNECT", "Disconnect", ISS_ON);
+    IUFillSwitchVector(&ConnectSP, ConnectS, NARRAY(ConnectS), mydev, "CONNECTION", "Connection", BASIC_GROUP, IP_RW, ISR_1OFMANY, 60, IPS_IDLE);
+
+    // Coord Set
+    IUFillSwitch(&OnCoordSetS[0], "SLEW", "Slew", ISS_ON);
+    IUFillSwitch(&OnCoordSetS[1], "SYNC", "Sync", ISS_OFF);
+    IUFillSwitchVector(&OnCoordSetSP, OnCoordSetS, NARRAY(OnCoordSetS), mydev, "ON_COORD_SET", "On Set", BASIC_GROUP, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);
+
+    //Track MODE
+    IUFillSwitch(&TrackModeS[0],"SIDERAL", "Sideral", ISS_ON);
+    IUFillSwitch(&TrackModeS[1],"LUNAR","Lunar", ISS_OFF);
+    IUFillSwitch(&TrackModeS[2],"SOLAR", "Solar", ISS_OFF);
+    IUFillSwitch(&TrackModeS[3],"ZERO", "Stop", ISS_OFF);
+    IUFillSwitchVector(&TrackModeSP, TrackModeS, NARRAY(TrackModeS), mydev, "TRACK_MODE", "Track Mode", BASIC_GROUP, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);
+
+    // Abort
+    IUFillSwitch(&AbortSlewS[0], "ABORT", "Abort", ISS_OFF);
+    IUFillSwitchVector(&AbortSlewSP, AbortSlewS, NARRAY(AbortSlewS), mydev, "ABORT_MOTION", "Abort Slew/Track", BASIC_GROUP, IP_RW, ISR_ATMOST1, 0, IPS_IDLE);
+
+    // Port
+    IUFillText(&PortT[0], "PORT", "Port", "/dev/ttyS0");
+    IUFillTextVector(&PortTP, PortT, NARRAY(PortT), mydev, "DEVICE_PORT", "Ports", BASIC_GROUP, IP_RW, 0, IPS_IDLE);
+
+    // Equatorial Coords - SET
+    IUFillNumber(&EquatorialCoordsWN[0], "RA", "RA  H:M:S", "%10.6m",  0., 24., 0., 0.);
+    IUFillNumber(&EquatorialCoordsWN[1], "DEC", "Dec D:M:S", "%10.6m", -90., 90., 0., 0.);
+    IUFillNumberVector(&EquatorialCoordsWNP, EquatorialCoordsWN, NARRAY(EquatorialCoordsWN), mydev, "EQUATORIAL_EOD_COORD_REQUEST" , "Equatorial JNow", BASIC_GROUP, IP_RW, 0, IPS_IDLE);
+
+    // Equatorial Coords - READ
+    IUFillNumber(&EquatorialCoordsRN[0], "RA", "RA  H:M:S", "%10.6m",  0., 24., 0., 0.);
+    IUFillNumber(&EquatorialCoordsRN[1], "DEC", "Dec D:M:S", "%10.6m", -90., 90., 0., 0.);
+    IUFillNumberVector(&EquatorialCoordsRNP, EquatorialCoordsRN, NARRAY(EquatorialCoordsRN), mydev, "EQUATORIAL_EOD_COORD" , "Equatorial JNow", BASIC_GROUP, IP_RO, 0, IPS_IDLE);
+
+}
+
+/**************************************************************************************
+** Define IEQ45 Basic properties to clients.
+***************************************************************************************/
+void IEQ45Basic::ISGetProperties(const char *dev)
+{
+
+ if (dev && strcmp (mydev, dev))
+    return;
+
+  // Main Control
+  IDDefSwitch(&ConnectSP, NULL);
+  IDDefText(&PortTP, NULL);
+  IDDefNumber(&EquatorialCoordsWNP, NULL);
+  IDDefNumber(&EquatorialCoordsRNP, NULL);
+  IDDefSwitch(&OnCoordSetSP, NULL);
+  IDDefSwitch(&TrackModeSP, NULL);
+  IDDefSwitch(&AbortSlewSP, NULL);
+
+
+  
+}
+
+/**************************************************************************************
+** Process Text properties
+***************************************************************************************/
+void IEQ45Basic::ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
+{
+	// Ignore if not ours 
+	if (strcmp (dev, mydev))
+	    return;
+
+	// ===================================
+	// Port Name
+	// ===================================
+	if (!strcmp(name, PortTP.name) )
+	{
+	  if (IUUpdateText(&PortTP, texts, names, n) < 0)
+		return;
+
+	  PortTP.s = IPS_OK;
+	  IDSetText (&PortTP, NULL);
+	  return;
+	}
+
+	if (is_connected() == false)
+        {
+		IDMessage(mydev, "IEQ45 is offline. Please connect before issuing any commands.");
+		reset_all_properties();
+		return;
+	}
+
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void IEQ45Basic::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
+{
+	
+	// Ignore if not ours
+	if (strcmp (dev, mydev))
+	    return;
+
+	if (is_connected() == false)
+        {
+		IDMessage(mydev, "IEQ45 is offline. Please connect before issuing any commands.");
+		reset_all_properties();
+		return;
+	}
+
+	// ===================================
+        // Equatorial Coords
+	// ===================================
+	if (!strcmp (name, EquatorialCoordsWNP.name))
+	{
+	  int i=0, nset=0, error_code=0;
+	  double newRA =0, newDEC =0;
+
+	    for (nset = i = 0; i < n; i++)
+	    {
+		INumber *eqp = IUFindNumber (&EquatorialCoordsWNP, names[i]);
+		if (eqp == &EquatorialCoordsWN[0])
+		{
+                    newRA = values[i];
+		    nset += newRA >= 0 && newRA <= 24.0;
+		} else if (eqp == &EquatorialCoordsWN[1])
+		{
+		    newDEC = values[i];
+		    nset += newDEC >= -90.0 && newDEC <= 90.0;
+		}
+	    }
+
+	  if (nset == 2)
+	  {
+	   char RAStr[32], DecStr[32];
+
+	   fs_sexa(RAStr, newRA, 2, 3600);
+	   fs_sexa(DecStr, newDEC, 2, 3600);
+	  
+           #ifdef INDI_DEBUG
+	   IDLog("We received JNow RA %g - DEC %g\n", newRA, newDEC);
+	   IDLog("We received JNow RA %s - DEC %s\n", RAStr, DecStr);
+           #endif
+	   
+	   if (!simulation && ( (error_code = setObjectRA(fd, newRA)) < 0 || ( error_code = setObjectDEC(fd, newDEC)) < 0))
+	   {
+	     handle_error(&EquatorialCoordsWNP, error_code, "Setting RA/DEC");
+	     return;
+	   } 
+	   
+	   targetRA  = newRA;
+	   targetDEC = newDEC;
+	   
+	   if (process_coords() == false)
+	   {
+	     EquatorialCoordsWNP.s = IPS_ALERT;
+	     IDSetNumber(&EquatorialCoordsWNP, NULL);
+	     
+	   }
+	} // end nset
+	else
+	{
+		EquatorialCoordsWNP.s = IPS_ALERT;
+		IDSetNumber(&EquatorialCoordsWNP, "RA or Dec missing or invalid");
+	}
+
+	    return;
+     } /* end EquatorialCoordsWNP */
+
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void IEQ45Basic::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
+{
+	// ignore if not ours //
+	if (strcmp (mydev, dev))
+	    return;
+
+	// ===================================
+        // Connect Switch
+	// ===================================
+	if (!strcmp (name, ConnectSP.name))
+	{
+	    if (IUUpdateSwitch(&ConnectSP, states, names, n) < 0)
+		return;
+
+   	    connect_telescope();
+	    return;
+	}
+
+	if (is_connected() == false)
+        {
+		IDMessage(mydev, "IEQ45 is offline. Please connect before issuing any commands.");
+		reset_all_properties();
+		return;
+	}
+
+	// ===================================
+        // Coordinate Set
+	// ===================================
+	if (!strcmp(name, OnCoordSetSP.name))
+	{
+	   if (IUUpdateSwitch(&OnCoordSetSP, states, names, n) < 0)
+		return;
+
+	  currentSet = get_switch_index(&OnCoordSetSP);
+	  OnCoordSetSP.s = IPS_OK;
+	  IDSetSwitch(&OnCoordSetSP, NULL);
+	}
+
+	// ===================================
+        // Track Mode Set
+	// ===================================
+	if (!strcmp(name, TrackModeSP.name))
+	{
+	   if (IUUpdateSwitch(&TrackModeSP, states, names, n) < 0)
+		return;
+
+	  int trackMode = get_switch_index(&TrackModeSP);
+	  selectTrackingMode(fd, trackMode);
+	  TrackModeSP.s = IPS_OK;
+	  IDSetSwitch(&TrackModeSP, NULL);
+	}
+	  
+	// ===================================
+        // Abort slew
+	// ===================================
+	if (!strcmp (name, AbortSlewSP.name))
+	{
+
+	  IUResetSwitch(&AbortSlewSP);
+	  abortSlew(fd);
+
+	    if (EquatorialCoordsWNP.s == IPS_BUSY)
+	    {
+		AbortSlewSP.s = IPS_OK;
+		EquatorialCoordsWNP.s       = IPS_IDLE;
+                EquatorialCoordsRNP.s       = IPS_IDLE;
+		IDSetSwitch(&AbortSlewSP, "Slew aborted.");
+		IDSetNumber(&EquatorialCoordsWNP, NULL);
+		IDSetNumber(&EquatorialCoordsRNP, NULL);
+            }
+
+	    return;
+	}
+
+}
+
+/**************************************************************************************
+** Retry connecting to the telescope on error. Give up if there is no hope.
+***************************************************************************************/
+void IEQ45Basic::handle_error(INumberVectorProperty *nvp, int err, const char *msg)
+{
+  
+  nvp->s = IPS_ALERT;
+  
+  /* First check to see if the telescope is connected */
+    if (check_IEQ45_connection(fd))
+    {
+      /* The telescope is off locally */
+      ConnectS[0].s = ISS_OFF;
+      ConnectS[1].s = ISS_ON;
+      ConnectSP.s = IPS_BUSY;
+      IDSetSwitch(&ConnectSP, "Telescope is not responding to commands, will retry in 10 seconds.");
+      
+      IDSetNumber(nvp, NULL);
+      IEAddTimer(10000, retry_connection, &fd);
+      return;
+    }
+    
+   /* If the error is a time out, then the device doesn't support this property */
+      if (err == -2)
+      {
+       nvp->s = IPS_ALERT;
+       IDSetNumber(nvp, "Device timed out. Current device may be busy or does not support %s. Will retry again.", msg);
+      }
+      else
+    /* Changing property failed, user should retry. */
+       IDSetNumber( nvp , "%s failed.", msg);
+       
+       fault = true;
+}
+
+/**************************************************************************************
+** Set all properties to idle and reset most switches to clean state.
+***************************************************************************************/
+void IEQ45Basic::reset_all_properties()
+{
+    ConnectSP.s			= IPS_IDLE;
+    OnCoordSetSP.s		= IPS_IDLE;
+    TrackModeSP.s		= IPS_IDLE;  
+    AbortSlewSP.s		= IPS_IDLE;
+    PortTP.s			= IPS_IDLE;
+    EquatorialCoordsWNP.s	= IPS_IDLE;
+    EquatorialCoordsRNP.s	= IPS_IDLE;
+
+
+    IUResetSwitch(&OnCoordSetSP);
+    IUResetSwitch(&TrackModeSP);
+    IUResetSwitch(&AbortSlewSP);
+
+    OnCoordSetS[0].s = ISS_ON;
+    TrackModeS[0].s = ISS_ON;
+    ConnectS[0].s = ISS_OFF;
+    ConnectS[1].s = ISS_ON;
+
+    IDSetSwitch(&ConnectSP, NULL);
+    IDSetSwitch(&OnCoordSetSP, NULL);
+    IDSetSwitch(&TrackModeSP, NULL);
+    IDSetSwitch(&AbortSlewSP, NULL);
+    IDSetText(&PortTP, NULL);
+    IDSetNumber(&EquatorialCoordsWNP, NULL);
+    IDSetNumber(&EquatorialCoordsRNP, NULL);
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void IEQ45Basic::correct_fault()
+{
+  fault = false;
+  IDMessage(mydev, "Telescope is online.");
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+bool IEQ45Basic::is_connected()
+{
+  if (simulation) return true;
+  
+  return (ConnectSP.sp[0].s == ISS_ON);
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+static void retry_connection(void * p)
+{
+  int fd = *((int *) p);
+
+  if (check_IEQ45_connection(fd))
+	telescope->connection_lost();
+  else
+	telescope->connection_resumed();
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void IEQ45Basic::ISPoll()
+{	
+	if (is_connected() == false || simulation)
+	 return;
+
+        double dx, dy;
+	int error_code=0;
+
+	switch (EquatorialCoordsWNP.s)
+	{
+		case IPS_IDLE:
+		getIEQ45RA(fd, &currentRA);
+		getIEQ45DEC(fd, &currentDEC);
+	        if ( fabs (currentRA - lastRA) > 0.01 || fabs (currentDEC - lastDEC) > 0.01)
+		{
+	        	lastRA = currentRA;
+			lastDEC = currentDEC;
+			IDSetNumber (&EquatorialCoordsRNP, NULL);
+		        IDLog("IDLE update coord\n"); 
+		}
+        	break;
+
+        	case IPS_BUSY:
+	    	getIEQ45RA(fd, &currentRA);
+		getIEQ45DEC(fd, &currentDEC);
+	    	dx = targetRA - currentRA;
+	    	dy = targetDEC - currentDEC;
+
+	    	// Wait until acknowledged or within threshold
+	    	if ( fabs(dx) <= (3/(900.0)) && fabs(dy) <= (3/60.0))
+	    	{
+		        lastRA  = currentRA;
+		        lastDEC = currentDEC;
+	       		IUResetSwitch(&OnCoordSetSP);
+	       		OnCoordSetSP.s = IPS_OK;
+	       		EquatorialCoordsWNP.s = IPS_OK;
+			EquatorialCoordsRNP.s = IPS_OK;
+	       		IDSetNumber (&EquatorialCoordsWNP, NULL);
+			IDSetNumber (&EquatorialCoordsRNP, NULL);
+
+			switch (currentSet)
+			{
+		  		case IEQ45_SLEW:
+		  		OnCoordSetSP.sp[IEQ45_SLEW].s = ISS_ON;
+		  		IDSetSwitch (&OnCoordSetSP, "Slew is complete.");
+		  		break;
+		    
+		  		case IEQ45_SYNC:
+		  		break;
+			}
+		  
+	    	}
+		else
+			IDSetNumber (&EquatorialCoordsRNP, NULL);
+	    	break;
+
+		case IPS_OK:
+	        	  
+		if ( (error_code = getIEQ45RA(fd, &currentRA)) < 0 || (error_code = getIEQ45DEC(fd, &currentDEC)) < 0)
+		{
+	  		handle_error(&EquatorialCoordsRNP, error_code, "Getting RA/DEC");
+	  		return;
+		}
+	
+		if (fault == true)
+	  		correct_fault();
+
+		if ( (currentRA != lastRA) || (currentDEC != lastDEC))
+		{
+		  	lastRA  = currentRA;
+			lastDEC = currentDEC;
+			//IDLog("IPS_OK update coords %g %g\n",currentRA,currentDEC); 
+			IDSetNumber (&EquatorialCoordsRNP, NULL);
+		}
+        	break;
+
+		case IPS_ALERT:
+	    	break;
+	}
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+bool IEQ45Basic::process_coords()
+{
+
+  int  error_code;
+  char syncString[256];
+  char RAStr[32], DecStr[32];
+  double dx, dy;
+  
+  switch (currentSet)
+  {
+
+    // Slew
+    case IEQ45_SLEW:
+          lastSet = IEQ45_SLEW;
+	  if (EquatorialCoordsWNP.s == IPS_BUSY)
+	  {
+	     IDLog("Aboring Slew\n");
+	     abortSlew(fd);
+
+	     // sleep for 100 mseconds
+	     usleep(100000);
+	  }
+
+	  if ( !simulation && (error_code = Slew(fd)))
+	  {
+	    slew_error(error_code);
+	    return false;
+	  }
+
+	  EquatorialCoordsWNP.s = IPS_BUSY;
+	  EquatorialCoordsRNP.s = IPS_BUSY;
+	  fs_sexa(RAStr, targetRA, 2, 3600);
+	  fs_sexa(DecStr, targetDEC, 2, 3600);
+	  IDSetNumber(&EquatorialCoordsWNP, "Slewing to JNow RA %s - DEC %s", RAStr, DecStr);
+	  IDSetNumber(&EquatorialCoordsRNP, NULL);
+	  IDLog("Slewing to JNow RA %s - DEC %s\n", RAStr, DecStr);
+	  break;
+
+
+    // Sync
+    case IEQ45_SYNC:
+          lastSet = IEQ45_SYNC;
+	  EquatorialCoordsWNP.s = IPS_IDLE;
+	   
+	  if ( !simulation && ( error_code = Sync(fd, syncString) < 0) )
+	  {
+	        IDSetNumber( &EquatorialCoordsWNP , "Synchronization failed.");
+		return false;
+	  }
+
+	  if (simulation)
+	  {
+             EquatorialCoordsRN[0].value = EquatorialCoordsWN[0].value;
+             EquatorialCoordsRN[1].value = EquatorialCoordsWN[1].value;
+	  }
+
+	  EquatorialCoordsWNP.s = IPS_OK;
+	  EquatorialCoordsRNP.s = IPS_OK;
+	  IDSetNumber(&EquatorialCoordsRNP, NULL);
+	  IDLog("Synchronization successful %s\n", syncString);
+	  IDSetNumber(&EquatorialCoordsWNP, "Synchronization successful.");
+	  break;
+    }
+
+   return true;
+
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+int IEQ45Basic::get_switch_index(ISwitchVectorProperty *sp)
+{
+ for (int i=0; i < sp->nsp ; i++)
+     if (sp->sp[i].s == ISS_ON)
+      return i;
+
+ return -1;
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void IEQ45Basic::connect_telescope()
+{
+     switch (ConnectSP.sp[0].s)
+     {
+      case ISS_ON:  
+	
+        if (simulation)
+	{
+	  ConnectSP.s = IPS_OK;
+	  IDSetSwitch (&ConnectSP, "Simulated telescope is online.");
+	  return;
+	}
+	
+         if (tty_connect(PortT[0].text, 9600, 8, 0, 1, &fd) != TTY_OK)
+	 {
+	   ConnectS[0].s = ISS_OFF;
+	   ConnectS[1].s = ISS_ON;
+	   IDSetSwitch (&ConnectSP, "Error connecting to port %s. Make sure you have BOTH read and write permission to the port.", PortT[0].text);
+	   return;
+	 }
+
+	 if (check_IEQ45_connection(fd))
+	 {   
+	   ConnectS[0].s = ISS_OFF;
+	   ConnectS[1].s = ISS_ON;
+	   IDSetSwitch (&ConnectSP, "Error connecting to Telescope. Telescope is offline.");
+	   return;
+	 }
+
+	ConnectSP.s = IPS_OK;
+	IDSetSwitch (&ConnectSP, "Telescope is online. Retrieving basic data...");
+	get_initial_data();
+	break;
+
+     case ISS_OFF:
+         ConnectS[0].s = ISS_OFF;
+	 ConnectS[1].s = ISS_ON;
+         ConnectSP.s = IPS_IDLE;
+	 if (simulation)
+         {
+	    IDSetSwitch (&ConnectSP, "Simulated Telescope is offline.");
+	    return;
+         }
+         IDSetSwitch (&ConnectSP, "Telescope is offline.");
+	 IDLog("Telescope is offline.");
+         
+	 tty_disconnect(fd);
+	 break;
+    }
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void IEQ45Basic::get_initial_data()
+{
+
+  // Make sure short
+  checkIEQ45Format(fd);
+
+  // Get current RA/DEC
+  getIEQ45RA(fd, &currentRA);
+  getIEQ45DEC(fd, &currentDEC);
+
+  IDSetNumber (&EquatorialCoordsRNP, NULL);  
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void IEQ45Basic::slew_error(int slewCode)
+{
+    OnCoordSetSP.s = IPS_IDLE;
+    IDLog("Aboring Slew\n");
+    abortSlew(fd);
+    if (slewCode == 1)
+	IDSetSwitch (&OnCoordSetSP, "Object below horizon.");
+    else if (slewCode == 2)
+	IDSetSwitch (&OnCoordSetSP, "Object below the minimum elevation limit.");
+    else
+        IDSetSwitch (&OnCoordSetSP, "Slew failed.");
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void IEQ45Basic::enable_simulation(bool enable)
+{
+   simulation = enable;
+   
+   if (simulation)
+     IDLog("Warning: Simulation is activated.\n");
+   else
+     IDLog("Simulation is disabled.\n");
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void IEQ45Basic::connection_lost()
+{
+    ConnectSP.s = IPS_IDLE;
+    IDSetSwitch(&ConnectSP, "The connection to the telescope is lost.");
+    return;
+ 
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void IEQ45Basic::connection_resumed()
+{
+  ConnectS[0].s = ISS_ON;
+  ConnectS[1].s = ISS_OFF;
+  ConnectSP.s = IPS_OK;
+   
+  IDSetSwitch(&ConnectSP, "The connection to the telescope has been resumed.");
+}
Index: /BAORadio/libindi/libindi/drivers/telescope/ieq45.h
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/ieq45.h	(revision 646)
+++ /BAORadio/libindi/libindi/drivers/telescope/ieq45.h	(revision 646)
@@ -0,0 +1,116 @@
+/*
+    IEQ45 Basic Driver
+    Copyright (C) 2011 Nacho Mas (mas.ignacio@gmail.com). Only litle changes
+    from lx200basic made it by Jasem Mutlaq (mutlaqja@ikarustech.com) 
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+*/
+
+#ifndef IEQ45BASIC_H
+#define IEQ45BASIC_H
+
+#include "indidevapi.h"
+#include "indicom.h"
+
+class IEQ45Basic
+{
+ public:
+ IEQ45Basic();
+ ~IEQ45Basic();
+
+ void ISGetProperties (const char *dev);
+ void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n);
+ void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n);
+ void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
+ void ISPoll ();
+
+ void connection_lost();
+ void connection_resumed();
+
+private:
+
+  enum IEQ45_STATUS { IEQ45_SLEW, IEQ45_SYNC, IEQ45_PARK };
+
+  /* Switches */
+  ISwitch ConnectS[2];
+  ISwitch OnCoordSetS[2];
+  ISwitch TrackModeS[4];
+  ISwitch AbortSlewS[1];
+  
+  /* Texts */
+  IText PortT[1];
+
+
+  /* Numbers */
+  INumber EquatorialCoordsRN[2];
+  INumber EquatorialCoordsWN[2];
+  
+  /* Switch Vectors */
+  ISwitchVectorProperty ConnectSP;
+  ISwitchVectorProperty OnCoordSetSP;
+  ISwitchVectorProperty TrackModeSP;
+  ISwitchVectorProperty AbortSlewSP;
+  
+   /* Number Vectors */
+  INumberVectorProperty EquatorialCoordsRNP;
+  INumberVectorProperty EquatorialCoordsWNP;
+  
+  /* Text Vectors */
+  ITextVectorProperty PortTP;
+
+
+ /*******************************************************/
+ /* Connection Routines
+ ********************************************************/
+ void init_properties();
+ void get_initial_data();
+ void connect_telescope();
+ bool is_connected(void);
+ 
+ /*******************************************************/
+ /* Misc routines
+ ********************************************************/
+ bool process_coords();
+ int get_switch_index(ISwitchVectorProperty *sp);
+
+ /*******************************************************/
+ /* Simulation Routines
+ ********************************************************/
+ void enable_simulation(bool enable);
+ 
+ /*******************************************************/
+ /* Error handling routines
+ ********************************************************/
+ void slew_error(int slewCode);
+ void reset_all_properties();
+ void handle_error(INumberVectorProperty *nvp, int err, const char *msg);
+ void correct_fault();
+
+ protected:
+
+  double JD;				/* Julian Date */
+  double lastRA;
+  double lastDEC;
+  bool   simulation;
+  bool   fault;
+  int    fd;				/* Telescope tty file descriptor */
+
+  int currentSet;
+  int lastSet;
+
+};
+
+#endif
Index: /BAORadio/libindi/libindi/drivers/telescope/ieq45driver.c
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/ieq45driver.c	(revision 646)
+++ /BAORadio/libindi/libindi/drivers/telescope/ieq45driver.c	(revision 646)
@@ -0,0 +1,1462 @@
+#if 0
+    IEQ45 Driver
+    Copyright (C) 2011 Nacho Mas (mas.ignacio@gmail.com). Only litle changes
+    from lx200basic made it by Jasem Mutlaq (mutlaqja@ikarustech.com) 
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <math.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <time.h>
+
+#include "indicom.h"
+#include "indidevapi.h"
+#include "ieq45driver.h"
+
+#ifndef _WIN32
+#include <termios.h>
+#endif
+
+#define IEQ45_TIMEOUT	5		/* FD timeout in seconds */
+
+int controller_format;
+
+/**************************************************************************
+ Diagnostics
+ **************************************************************************/
+int check_IEQ45_connection(int fd);
+
+/**************************************************************************
+ Get Commands: store data in the supplied buffer. Return 0 on success or -1 on failure 
+ **************************************************************************/
+ 
+/* Get Double from Sexagisemal */
+int getCommandSexa(int fd, double *value, const char *cmd);
+/* Get String */
+int getCommandString(int fd, char *data, const char* cmd);
+/* Get Int */
+int getCommandInt(int fd, int *value, const char* cmd);
+/* Get tracking frequency */
+int getTrackFreq(int fd, double * value);
+/* Get site Latitude */
+int getSiteLatitude(int fd, int *dd, int *mm);
+/* Get site Longitude */
+int getSiteLongitude(int fd, int *ddd, int *mm);
+/* Get Calender data */
+int getCalenderDate(int fd, char *date);
+/* Get site Name */
+int getSiteName(int fd, char *siteName, int siteNum);
+/* Get Number of Bars */
+int getNumberOfBars(int fd, int *value);
+/* Get Home Search Status */
+int getHomeSearchStatus(int fd, int *status);
+/* Get OTA Temperature */
+int getOTATemp(int fd, double * value);
+/* Get time format: 12 or 24 */
+int getTimeFormat(int fd, int *format);
+
+
+/**************************************************************************
+ Set Commands
+ **************************************************************************/
+
+/* Set Int */
+int setCommandInt(int fd, int data, const char *cmd);
+/* Set Sexigesimal */
+int setCommandXYZ(int fd, int x, int y, int z, const char *cmd);
+/* Common routine for Set commands */
+int setStandardProcedure(int fd, char * writeData);
+/* Set Slew Mode */
+int setSlewMode(int fd, int slewMode);
+/* Set Alignment mode */
+int setAlignmentMode(int fd, unsigned int alignMode);
+/* Set Object RA */
+int setObjectRA(int fd, double ra);
+/* set Object DEC */
+int setObjectDEC(int fd, double dec);
+/* Set Calender date */
+int setCalenderDate(int fd, int dd, int mm, int yy);
+/* Set UTC offset */
+int setUTCOffset(int fd, double hours);
+/* Set Track Freq */
+int setTrackFreq(int fd, double trackF);
+/* Set current site longitude */
+int setSiteLongitude(int fd, double Long);
+/* Set current site latitude */
+int setSiteLatitude(int fd, double Lat);
+/* Set Object Azimuth */
+int setObjAz(int fd, double az);
+/* Set Object Altitude */
+int setObjAlt(int fd, double alt);
+/* Set site name */
+int setSiteName(int fd, char * siteName, int siteNum);
+/* Set maximum slew rate */
+int setMaxSlewRate(int fd, int slewRate);
+/* Set focuser motion */
+int setFocuserMotion(int fd, int motionType);
+/* Set focuser speed mode */
+int setFocuserSpeedMode (int fd, int speedMode);
+/* Set minimum elevation limit */
+int setMinElevationLimit(int fd, int min);
+/* Set maximum elevation limit */
+int setMaxElevationLimit(int fd, int max);
+
+/**************************************************************************
+ Motion Commands
+ **************************************************************************/
+/* Slew to the selected coordinates */
+int Slew(int fd);
+/* Synchronize to the selected coordinates and return the matching object if any */
+int Sync(int fd, char *matchedObject);
+/* Abort slew in all axes */
+int abortSlew(int fd);
+/* Move into one direction, two valid directions can be stacked */
+int MoveTo(int fd, int direction);
+/* Half movement in a particular direction */
+int HaltMovement(int fd, int direction);
+/* Select the tracking mode */
+int selectTrackingMode(int fd, int trackMode);
+/* Select Astro-Physics tracking mode */
+int selectAPTrackingMode(int fd, int trackMode);
+/* Send Pulse-Guide command (timed guide move), two valid directions can be stacked */
+int SendPulseCmd(int fd, int direction, int duration_msec);
+
+/**************************************************************************
+ Other Commands
+ **************************************************************************/
+ /* Ensures IEQ45 RA/DEC format is long */
+int checkIEQ45Format(int fd);
+/* Select a site from the IEQ45 controller */
+int selectSite(int fd, int siteNum);
+/* Select a catalog object */
+int selectCatalogObject(int fd, int catalog, int NNNN);
+/* Select a sub catalog */
+int selectSubCatalog(int fd, int catalog, int subCatalog);
+
+int check_IEQ45_connection(int in_fd)
+{
+  int i=0;
+  char firmwareDate[14] = ":FirmWareDate#";
+  char MountAlign[64];
+  int nbytes_read=0;
+
+  #ifdef INDI_DEBUG
+  IDLog("Testing telescope's connection using FirmwareDate command...\n");
+  #endif
+
+  if (in_fd <= 0) return -1;
+
+  for (i=0; i < 2; i++)
+  {
+    if (write(in_fd,  firmwareDate, 14) < 0) return -1;
+    tty_read(in_fd, MountAlign, 1, IEQ45_TIMEOUT, &nbytes_read);
+    if (nbytes_read == 1)
+     return 0;
+    usleep(50000);
+  }
+  
+  return -1;
+}
+
+
+/**********************************************************************
+* GET
+**********************************************************************/
+
+
+int getCommandSexa(int fd, double *value, const char * cmd)
+{
+  char temp_string[16];
+  int error_type;
+  int nbytes_write=0, nbytes_read=0;
+  
+  tcflush(fd, TCIFLUSH);
+  if ( (error_type = tty_write_string(fd, cmd, &nbytes_write)) != TTY_OK)
+   return error_type;
+  
+  /*if ( (read_ret = portRead(temp_string, -1, IEQ45_TIMEOUT)) < 1)
+     return read_ret;*/
+  tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
+
+  temp_string[nbytes_read - 1] = '\0';
+
+
+  /*IDLog("getComandSexa: %s\n", temp_string);*/
+
+  if (f_scansexa(temp_string, value))
+  {
+   #ifdef INDI_DEBUG
+   IDLog("unable to process [%s]\n", temp_string);
+   #endif
+   return -1;
+  }
+
+   tcflush(fd, TCIFLUSH);
+   return 0;
+}
+
+int getCommandInt(int fd, int *value, const char* cmd)
+{
+  char temp_string[16];
+  float temp_number;
+  int error_type;
+  int nbytes_write=0, nbytes_read=0;
+
+  
+  tcflush(fd, TCIFLUSH);
+
+  if ( (error_type = tty_write_string(fd, cmd, &nbytes_write)) != TTY_OK)
+   return error_type;
+  
+  tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
+ 
+  temp_string[nbytes_read - 1] = '\0';
+
+  /* Float */
+  if (strchr(temp_string, '.'))
+  {
+     if (sscanf(temp_string, "%f", &temp_number) != 1)
+	return -1;
+
+	*value = (int) temp_number;
+   }
+  /* Int */
+  else if (sscanf(temp_string, "%d", value) != 1)
+	return -1;
+
+   return 0;
+}
+
+
+int getCommandString(int fd, char *data, const char* cmd)
+{
+    char * term;
+    int error_type;
+    int nbytes_write=0, nbytes_read=0;
+    
+   /*if (portWrite(cmd) < 0)
+      return -1;*/
+
+   if ( (error_type = tty_write_string(fd, cmd, &nbytes_write)) != TTY_OK)
+    return error_type;
+
+    /*read_ret = portRead(data, -1, IEQ45_TIMEOUT);*/
+    error_type = tty_read_section(fd, data, '#', IEQ45_TIMEOUT, &nbytes_read);
+    tcflush(fd, TCIFLUSH);
+
+    if (error_type != TTY_OK)
+	return error_type;
+
+    term = strchr (data, '#');
+    if (term)
+      *term = '\0';
+
+   #ifdef INDI_DEBUG
+    /*IDLog("Requested data: %s\n", data);*/
+   #endif
+
+    return 0;
+}
+
+int getCalenderDate(int fd, char *date)
+{
+
+ int dd, mm, yy;
+ int error_type;
+ int nbytes_read=0;
+ char mell_prefix[3];
+ 
+
+ if ( (error_type = getCommandString(fd, date, ":GC#")) )
+   return error_type;
+
+ /* Meade format is MM/DD/YY */
+
+  nbytes_read = sscanf(date, "%d%*c%d%*c%d", &mm, &dd, &yy);
+  if (nbytes_read < 3)
+   return -1;
+
+  /* We consider years 50 or more to be in the last century, anything less in the 21st century.*/
+  if (yy > 50)
+	strncpy(mell_prefix, "19", 3);
+  else
+	strncpy(mell_prefix, "20", 3);
+
+ /* We need to have in in YYYY/MM/DD format */
+ snprintf(date, 16, "%s%02d/%02d/%02d", mell_prefix, yy, mm, dd);
+
+ return (0);
+
+}
+
+int getTimeFormat(int fd, int *format)
+{
+  char temp_string[16];
+  int error_type;
+  int nbytes_write=0, nbytes_read=0;
+  int tMode;
+
+  /*if (portWrite(":Gc#") < 0)
+    return -1;*/
+  
+ if ( (error_type = tty_write_string(fd, ":Gc#", &nbytes_write)) != TTY_OK)
+    return error_type;
+
+  /*read_ret = portRead(temp_string, -1, IEQ45_TIMEOUT);*/
+  if ( (error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read)) != TTY_OK)
+	return error_type;
+
+  tcflush(fd, TCIFLUSH);
+  
+  if (nbytes_read < 1)
+   return error_type;
+   
+  temp_string[nbytes_read-1] = '\0';
+
+  nbytes_read = sscanf(temp_string, "(%d)", &tMode);
+
+  if (nbytes_read < 1)
+   return -1;
+  else
+   *format = tMode;
+   
+  return 0;
+
+}
+
+int getSiteName(int fd, char *siteName, int siteNum)
+{
+  char * term;
+  int error_type;
+  int nbytes_write=0, nbytes_read=0;
+
+  switch (siteNum)
+  {
+    case 1:
+     /*if (portWrite(":GM#") < 0)
+      return -1;*/
+       if ( (error_type = tty_write_string(fd, ":GM#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+     break;
+    case 2:
+     /*if (portWrite(":GN#") < 0)
+      return -1;*/
+	if ( (error_type = tty_write_string(fd, ":GN#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+     break;
+    case 3:
+     /*if (portWrite(":GO#") < 0)
+       return -1;*/
+	if ( (error_type = tty_write_string(fd, ":GO#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+     break;
+    case 4:
+     /*if (portWrite(":GP#") < 0)
+      return -1;*/
+	if ( (error_type = tty_write_string(fd, ":GP#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+     break;
+    default:
+     return -1;
+   }
+
+   /*read_ret = portRead(siteName, -1, IEQ45_TIMEOUT);*/
+   error_type = tty_read_section(fd, siteName, '#', IEQ45_TIMEOUT, &nbytes_read);
+   tcflush(fd, TCIFLUSH);
+
+   if (nbytes_read < 1)
+     return error_type;
+
+   siteName[nbytes_read - 1] = '\0';
+
+   term = strchr (siteName, ' ');
+    if (term)
+      *term = '\0';
+
+    term = strchr (siteName, '<');
+    if (term)
+      strcpy(siteName, "unused site");
+
+   #ifdef INDI_DEBUG
+   IDLog("Requested site name: %s\n", siteName);
+   #endif
+
+    return 0;
+}
+
+int getSiteLatitude(int fd, int *dd, int *mm)
+{
+  char temp_string[16];
+  int error_type;
+  int nbytes_write=0, nbytes_read=0;
+
+  /*if (portWrite(":Gt#") < 0)
+    return -1;*/
+  if ( (error_type = tty_write_string(fd, ":Gt#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+
+  /*read_ret = portRead(temp_string, -1, IEQ45_TIMEOUT);*/
+  error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
+  tcflush(fd, TCIFLUSH);
+  
+   if (nbytes_read < 1) 
+   return error_type;
+   
+  temp_string[nbytes_read -1] = '\0';
+
+  if (sscanf (temp_string, "%d%*c%d", dd, mm) < 2)
+   return -1;
+
+  #ifdef INDI_DEBUG
+  fprintf(stderr, "Requested site latitude in String %s\n", temp_string);
+  fprintf(stderr, "Requested site latitude %d:%d\n", *dd, *mm);
+  #endif
+
+  return 0;
+}
+
+int getSiteLongitude(int fd, int *ddd, int *mm)
+{
+  char temp_string[16];
+  int error_type;
+  int nbytes_write=0, nbytes_read=0;
+
+  if ( (error_type = tty_write_string(fd, ":Gg#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+
+  /*if (portWrite(":Gg#") < 0)
+   return -1;*/
+  error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
+  /*read_ret = portRead(temp_string, -1, IEQ45_TIMEOUT);*/
+  
+  tcflush(fd, TCIFLUSH);
+  
+  if (nbytes_read < 1)
+    return error_type;
+    
+  temp_string[nbytes_read -1] = '\0';
+
+  if (sscanf (temp_string, "%d%*c%d", ddd, mm) < 2)
+   return -1;
+
+  #ifdef INDI_DEBUG
+  fprintf(stderr, "Requested site longitude in String %s\n", temp_string);
+  fprintf(stderr, "Requested site longitude %d:%d\n", *ddd, *mm);
+  #endif
+
+  return 0;
+}
+
+int getTrackFreq(int fd, double *value)
+{
+    float Freq;
+    char temp_string[16];
+    int error_type;
+    int nbytes_write=0, nbytes_read=0;
+    
+    if ( (error_type = tty_write_string(fd, ":GT#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+
+	/*if (portWrite(":GT#") < 0)
+      return -1;*/
+
+    /*read_ret = portRead(temp_string, -1, IEQ45_TIMEOUT);*/
+    error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
+    tcflush(fd, TCIFLUSH);
+    
+    if (nbytes_read < 1)
+     return error_type;
+
+    temp_string[nbytes_read] = '\0';
+    
+    /*fprintf(stderr, "Telescope tracking freq str: %s\n", temp_string);*/
+    
+    if (sscanf(temp_string, "%f#", &Freq) < 1)
+     return -1;
+   
+    *value = (double) Freq;
+    
+    #ifdef INDI_DEBUG
+    fprintf(stderr, "Tracking frequency value is %f\n", Freq);
+    #endif
+
+    return 0;
+}
+
+int getNumberOfBars(int fd, int *value)
+{
+   char temp_string[128];
+   int error_type;
+   int nbytes_write=0, nbytes_read=0;
+
+   if ( (error_type = tty_write_string(fd, ":D#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+   /*if (portWrite(":D#") < 0)
+     return -1;*/
+
+   error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
+   tcflush(fd, TCIFLUSH);
+   
+   if (nbytes_read < 0)
+    return error_type;
+
+   *value = nbytes_read -1;
+   
+   return 0;
+}
+
+int getHomeSearchStatus(int fd, int *status)
+{
+  char temp_string[16];
+  int error_type;
+  int nbytes_write=0, nbytes_read=0;
+
+  if ( (error_type = tty_write_string(fd, ":h?#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+ /*if (portWrite(":h?#") < 0)
+   return -1;*/
+
+  /*read_ret = portRead(temp_string, 1, IEQ45_TIMEOUT);*/
+  error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
+  tcflush(fd, TCIFLUSH);
+  
+  if (nbytes_read < 1)
+   return error_type;
+   
+  temp_string[1] = '\0';
+
+  if (temp_string[0] == '0')
+    *status = 0;
+  else if (temp_string[0] == '1')
+    *status = 1;
+  else if (temp_string[0] == '2')
+    *status = 1;
+  
+  return 0;
+}
+
+int getOTATemp(int fd, double *value)
+{
+
+  char temp_string[16];
+  int error_type;
+  int nbytes_write=0, nbytes_read=0;
+  float temp;
+  
+  if ( (error_type = tty_write_string(fd, ":fT#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+
+  error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
+  
+  if (nbytes_read < 1)
+   return error_type;
+   
+  temp_string[nbytes_read - 1] = '\0';
+
+  if (sscanf(temp_string, "%f", &temp) < 1)
+   return -1;
+   
+   *value = (double) temp;
+
+  return 0;
+
+}
+
+int updateSkyCommanderCoord(int fd, double *ra, double *dec)
+{
+  char coords[16];
+  char CR[1] = { (char) 0x0D };
+  float RA=0.0, DEC=0.0;
+  int error_type;
+  int nbytes_read=0;
+
+  error_type = write(fd, CR, 1);
+
+  error_type = tty_read(fd, coords, 16, IEQ45_TIMEOUT, &nbytes_read);
+  /*read_ret = portRead(coords, 16, IEQ45_TIMEOUT);*/
+  tcflush(fd, TCIFLUSH);
+
+  nbytes_read = sscanf(coords, " %g %g", &RA, &DEC);
+
+  if (nbytes_read < 2)
+  {
+   #ifdef INDI_DEBUG
+   IDLog("Error in Sky commander number format [%s], exiting.\n", coords);
+   #endif
+   return error_type;
+  }
+
+  *ra  = RA;
+  *dec = DEC;
+
+  return 0;
+
+}
+
+int updateIntelliscopeCoord (int fd, double *ra, double *dec)
+{
+  char coords[16];
+  char CR[1] = { (char) 0x51 };	/* "Q" */
+  float RA = 0.0, DEC = 0.0;
+  int error_type;
+  int nbytes_read=0;
+
+  /*IDLog ("Sending a Q\n");*/
+  error_type = write (fd, CR, 1);
+  /* We start at 14 bytes in case its a Sky Wizard, 
+     but read one more later it if it's a intelliscope */
+  /*read_ret = portRead (coords, 14, IEQ45_TIMEOUT);*/
+  error_type = tty_read(fd, coords, 14, IEQ45_TIMEOUT, &nbytes_read);
+  tcflush(fd, TCIFLUSH);
+  /*IDLog ("portRead() = [%s]\n", coords);*/
+
+  /* Remove the Q in the response from the Intelliscope  but not the Sky Wizard */
+  if (coords[0] == 'Q') {
+    coords[0] = ' ';
+    /* Read one more byte if Intelliscope to get the "CR" */
+    error_type = tty_read(fd, coords, 1, IEQ45_TIMEOUT, &nbytes_read);
+    /*read_ret = portRead (coords, 1, IEQ45_TIMEOUT);*/
+  }
+  nbytes_read = sscanf (coords, " %g %g", &RA, &DEC);
+  /*IDLog ("sscanf() RA = [%f]\n", RA * 0.0390625);*/
+  /*IDLog ("sscanf() DEC = [%f]\n", DEC * 0.0390625);*/
+
+  /*IDLog ("Intelliscope output [%s]", coords);*/
+  if (nbytes_read < 2)
+  {
+    #ifdef INDI_DEBUG
+    IDLog ("Error in Intelliscope number format [%s], exiting.\n", coords);
+    #endif
+    return -1;
+  }
+
+  *ra = RA * 0.0390625;
+  *dec = DEC * 0.0390625;
+
+  return 0;
+
+}
+
+
+/**********************************************************************
+* SET
+**********************************************************************/
+
+int setStandardProcedure(int fd, char * data)
+{
+ char bool_return[2];
+ int error_type;
+ int nbytes_write=0, nbytes_read=0;
+ 
+ if ( (error_type = tty_write_string(fd, data, &nbytes_write)) != TTY_OK)
+    	return error_type;
+
+ error_type = tty_read(fd, bool_return, 1, IEQ45_TIMEOUT, &nbytes_read);
+ /*read_ret = portRead(boolRet, 1, IEQ45_TIMEOUT);*/
+ tcflush(fd, TCIFLUSH);
+ 
+ if (nbytes_read < 1)
+   return error_type;
+
+ if (bool_return[0] == '0')
+ {
+     #ifdef INDI_DEBUG
+     IDLog("%s Failed.\n", data);
+     #endif
+     return -1;
+ }
+
+ #ifdef INDI_DEBUG
+ IDLog("%s Successful\n", data);
+ #endif
+
+ return 0;
+
+
+}
+
+int setCommandInt(int fd, int data, const char *cmd)
+{
+  char temp_string[16];
+  int error_type;
+  int nbytes_write=0;
+
+  snprintf(temp_string, sizeof( temp_string ), "%s%d#", cmd, data);
+
+  if ( (error_type = tty_write_string(fd, temp_string, &nbytes_write)) != TTY_OK)
+    	return error_type;
+
+ /*  if (portWrite(temp_string) < 0)
+    return -1;*/
+
+  return 0;
+}
+
+int setMinElevationLimit(int fd, int min)
+{
+ char temp_string[16];
+
+ snprintf(temp_string, sizeof( temp_string ), ":Sh%02d#", min);
+
+ return (setStandardProcedure(fd, temp_string));
+}
+
+int setMaxElevationLimit(int fd, int max)
+{
+ char temp_string[16];
+
+ snprintf(temp_string, sizeof( temp_string ), ":So%02d*#", max);
+
+ return (setStandardProcedure(fd, temp_string));
+
+}
+
+int setMaxSlewRate(int fd, int slewRate)
+{
+
+   char temp_string[16];
+
+   if (slewRate < 2 || slewRate > 8)
+    return -1;
+
+   snprintf(temp_string, sizeof( temp_string ), ":Sw%d#", slewRate);
+
+   return (setStandardProcedure(fd, temp_string));
+
+}
+
+int setObjectRA(int fd, double ra)
+{
+
+ int h, m, s, frac_m;
+ char temp_string[16];
+
+ getSexComponents(ra, &h, &m, &s);
+
+ frac_m = (s / 60.0) * 10.;
+
+ if (controller_format == IEQ45_LONG_FORMAT)
+ 	snprintf(temp_string, sizeof( temp_string ), ":Sr %02d:%02d:%02d#", h, m, s);
+ else
+	snprintf(temp_string, sizeof( temp_string ), ":Sr %02d:%02d.%01d#", h, m, frac_m);
+	
+ /*IDLog("Set Object RA String %s\n", temp_string);*/
+ return (setStandardProcedure(fd, temp_string));
+}
+
+
+int setObjectDEC(int fd, double dec)
+{
+  int d, m, s;
+  char temp_string[16];
+
+  getSexComponents(dec, &d, &m, &s);
+
+  switch(controller_format)
+  {
+ 
+    case IEQ45_SHORT_FORMAT:
+    /* case with negative zero */
+    if (!d && dec < 0)
+    	snprintf(temp_string, sizeof( temp_string ), ":Sd -%02d*%02d#", d, m);
+    else	
+    	snprintf(temp_string, sizeof( temp_string ), ":Sd %+03d*%02d#", d, m);
+    break;
+
+    case IEQ45_LONG_FORMAT:
+    /* case with negative zero */
+    if (!d && dec < 0)
+    	snprintf(temp_string, sizeof( temp_string ), ":Sd -%02d:%02d:%02d#", d, m, s);
+    else	
+    	snprintf(temp_string, sizeof( temp_string ), ":Sd %+03d:%02d:%02d#", d, m, s);
+    break;
+  }
+
+  /*IDLog("Set Object DEC String %s\n", temp_string);*/
+  
+  return (setStandardProcedure(fd, temp_string));
+
+}
+
+int setCommandXYZ(int fd, int x, int y, int z, const char *cmd)
+{
+  char temp_string[16];
+
+  snprintf(temp_string, sizeof( temp_string ), "%s %02d:%02d:%02d#", cmd, x, y, z);
+
+  return (setStandardProcedure(fd, temp_string));
+}
+
+int setAlignmentMode(int fd, unsigned int alignMode)
+{
+  /*fprintf(stderr , "Set alignment mode %d\n", alignMode);*/
+  int error_type;
+  int nbytes_write=0;
+
+  switch (alignMode)
+   {
+     case IEQ45_ALIGN_POLAR:
+	if ( (error_type = tty_write_string(fd, ":AP#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+      /*if (portWrite(":AP#") < 0)
+        return -1;*/
+      break;
+     case IEQ45_ALIGN_ALTAZ:
+	if ( (error_type = tty_write_string(fd, ":AA#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+      /*if (portWrite(":AA#") < 0)
+        return -1;*/
+      break;
+     case IEQ45_ALIGN_LAND:
+	if ( (error_type = tty_write_string(fd, ":AL#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+       /*if (portWrite(":AL#") < 0)
+        return -1;*/
+       break;
+   }
+   
+   tcflush(fd, TCIFLUSH);
+   return 0;
+}
+
+int setCalenderDate(int fd, int dd, int mm, int yy)
+{
+   char temp_string[32];
+   char dumpPlanetaryUpdateString[64];
+   char bool_return[2];
+   int error_type;
+   int nbytes_write=0, nbytes_read=0;
+   yy = yy % 100;
+
+   snprintf(temp_string, sizeof( temp_string ), ":SC %02d/%02d/%02d#", mm, dd, yy);
+
+   if ( (error_type = tty_write_string(fd, temp_string, &nbytes_write)) != TTY_OK)
+    	return error_type;
+
+   /*if (portWrite(temp_string) < 0)
+    return -1;*/
+
+   /*read_ret = portRead(boolRet, 1, IEQ45_TIMEOUT);*/
+   error_type = tty_read(fd, bool_return, 1, IEQ45_TIMEOUT, &nbytes_read);
+   tcflush(fd, TCIFLUSH);
+   
+   if (nbytes_read < 1)
+    return error_type;
+    
+   bool_return[1] = '\0';
+
+   if (bool_return[0] == '0')
+     return -1;
+     
+    /* Read dumped data */
+    error_type = tty_read_section(fd, dumpPlanetaryUpdateString, '#', IEQ45_TIMEOUT, &nbytes_read);
+    error_type = tty_read_section(fd, dumpPlanetaryUpdateString, '#', 5, &nbytes_read);
+
+   return 0;
+}
+
+int setUTCOffset(int fd, double hours)
+{
+   char temp_string[16];
+
+   snprintf(temp_string, sizeof( temp_string ), ":SG %+03d#", (int) hours);
+
+   /*IDLog("UTC string is %s\n", temp_string);*/
+
+   return (setStandardProcedure(fd, temp_string));
+
+}
+
+int setSiteLongitude(int fd, double Long)
+{
+   int d, m, s;
+   char temp_string[32];
+
+   getSexComponents(Long, &d, &m, &s);
+
+   snprintf(temp_string, sizeof( temp_string ), ":Sg%03d:%02d#", d, m);
+
+   return (setStandardProcedure(fd, temp_string));
+}
+
+int setSiteLatitude(int fd, double Lat)
+{
+   int d, m, s;
+   char temp_string[32];
+
+   getSexComponents(Lat, &d, &m, &s);
+
+   snprintf(temp_string, sizeof( temp_string ), ":St%+03d:%02d:%02d#", d, m, s);
+
+   return (setStandardProcedure(fd, temp_string));
+}
+
+int setObjAz(int fd, double az)
+{
+   int d,m,s;
+   char temp_string[16];
+
+   getSexComponents(az, &d, &m, &s);
+
+   snprintf(temp_string, sizeof( temp_string ), ":Sz%03d:%02d#", d, m);
+
+   return (setStandardProcedure(fd, temp_string));
+
+}
+
+int setObjAlt(int fd, double alt)
+{
+    int d, m, s;
+    char temp_string[16];
+
+   getSexComponents(alt, &d, &m, &s);
+
+   snprintf(temp_string, sizeof( temp_string ), ":Sa%+02d*%02d#", d, m);
+
+   return (setStandardProcedure(fd, temp_string));
+}
+
+
+int setSiteName(int fd, char * siteName, int siteNum)
+{
+
+   char temp_string[16];
+
+   switch (siteNum)
+   {
+     case 1:
+      snprintf(temp_string, sizeof( temp_string ), ":SM %s#", siteName);
+      break;
+     case 2:
+      snprintf(temp_string, sizeof( temp_string ), ":SN %s#", siteName);
+      break;
+     case 3:
+      snprintf(temp_string, sizeof( temp_string ), ":SO %s#", siteName);
+      break;
+    case 4:
+      snprintf(temp_string, sizeof( temp_string ), ":SP %s#", siteName);
+      break;
+    default:
+      return -1;
+    }
+
+   return (setStandardProcedure(fd, temp_string));
+}
+
+int setSlewMode(int fd, int slewMode)
+{
+  int error_type;
+  int nbytes_write=0;
+
+  switch (slewMode)
+  {
+    case IEQ45_SLEW_MAX:
+   if ( (error_type = tty_write_string(fd, ":RS#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+     /*if (portWrite(":RS#") < 0)
+      return -1;*/
+     break;
+    case IEQ45_SLEW_FIND:
+     if ( (error_type = tty_write_string(fd, ":RM#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+     /*if (portWrite(":RM#") < 0)
+      return -1;*/
+     break;
+    case IEQ45_SLEW_CENTER:
+	if ( (error_type = tty_write_string(fd, ":RC#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+     /*if (portWrite(":RC#") < 0)
+      return -1;*/
+     break;
+    case IEQ45_SLEW_GUIDE:
+    if ( (error_type = tty_write_string(fd, ":RG#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+     /*if (portWrite(":RG#") < 0)
+      return -1;*/
+     break;
+    default:
+     break;
+   }
+   
+   tcflush(fd, TCIFLUSH);
+   return 0;
+
+}
+
+int setFocuserMotion(int fd, int motionType)
+{
+  int error_type;
+  int nbytes_write=0;
+
+  switch (motionType)
+  {
+    case IEQ45_FOCUSIN:
+    if ( (error_type = tty_write_string(fd, ":F+#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+	#ifdef INDI_DEBUG
+	/*IDLog("Focus IN Command\n");*/
+	#endif
+    /*if (portWrite(":F+#") < 0)
+      return -1;*/
+      break;
+    case IEQ45_FOCUSOUT:
+    if ( (error_type = tty_write_string(fd, ":F-#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+	#ifdef INDI_DEBUG
+	/*IDLog("Focus OUT Command\n");*/
+	#endif
+     /*if (portWrite(":F-#") < 0)
+       return -1;*/
+     break;
+  }
+
+  tcflush(fd, TCIFLUSH);
+  return 0;
+}
+
+int setFocuserSpeedMode (int fd, int speedMode)
+{
+  int error_type;
+  int nbytes_write=0;
+
+ switch (speedMode)
+ {
+    case IEQ45_HALTFOCUS:
+    if ( (error_type = tty_write_string(fd, ":FQ#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+	#ifdef INDI_DEBUG
+	/*IDLog("Halt Focus Command\n");*/
+	#endif
+    /* if (portWrite(":FQ#") < 0)
+      return -1;*/
+     break;
+   case IEQ45_FOCUSSLOW:
+    if ( (error_type = tty_write_string(fd, ":FS#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+	#ifdef INDI_DEBUG
+	/*IDLog("Focus Slow (FS) Command\n");*/
+	#endif
+      /*if (portWrite(":FS#") < 0)
+       return -1;*/
+      break;
+    case IEQ45_FOCUSFAST:
+     if ( (error_type = tty_write_string(fd, ":FF#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+	#ifdef INDI_DEBUG
+	/*IDLog("Focus Fast (FF) Command\n");*/
+	#endif
+     /*if (portWrite(":FF#") < 0)
+      return -1;*/
+     break;
+ }
+
+ tcflush(fd, TCIFLUSH);
+ return 0;
+}
+
+int setGPSFocuserSpeed (int fd, int speed)
+{
+  char speed_str[8];
+  int error_type;
+  int nbytes_write=0;
+
+  if (speed == 0)
+  {
+     /*if (portWrite(":FQ#") < 0)
+      return -1;*/
+     if ( (error_type = tty_write_string(fd, ":FQ#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+	#ifdef INDI_DEBUG
+	/*IDLog("GPS Focus HALT Command (FQ) \n");*/
+	#endif
+
+     return 0;
+  }
+
+  snprintf(speed_str, 8, ":F%d#", speed);
+
+  if ( (error_type = tty_write_string(fd, speed_str, &nbytes_write)) != TTY_OK)
+    	return error_type;
+
+    #ifdef INDI_DEBUG
+    /*IDLog("GPS Focus Speed command %s \n", speed_str);*/
+    #endif
+  /*if (portWrite(speed_str) < 0)
+       return -1;*/
+
+  tcflush(fd, TCIFLUSH);
+  return 0;
+}
+
+int setTrackFreq(int fd, double trackF)
+{
+  char temp_string[16];
+
+  snprintf(temp_string, sizeof( temp_string ), ":ST %04.1f#", trackF);
+
+  return (setStandardProcedure(fd, temp_string));
+
+}
+
+/**********************************************************************
+* Misc
+*********************************************************************/
+
+int Slew(int fd)
+{
+    char slewNum[2];
+    int error_type;
+    int nbytes_write=0, nbytes_read=0;
+
+    if ( (error_type = tty_write_string(fd, ":MS#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+
+    error_type = tty_read(fd, slewNum, 1, IEQ45_TIMEOUT, &nbytes_read);
+    
+    if (nbytes_read < 1)
+      return error_type;
+
+    /* We don't need to read the string message, just return corresponding error code */
+    tcflush(fd, TCIFLUSH);
+
+    if (slewNum[0] == '0')
+     return 0;
+    else if  (slewNum[0] == '1')
+      return 1;
+    else return 2;
+
+}
+
+int MoveTo(int fd, int direction)
+{
+  int nbytes_write=0;
+
+  switch (direction)
+  {
+    case IEQ45_NORTH:
+    tty_write_string(fd, ":Mn#", &nbytes_write);
+    /*portWrite(":Mn#");*/
+    break;
+    case IEQ45_WEST:
+    tty_write_string(fd, ":Mw#", &nbytes_write);
+    /*portWrite(":Mw#");*/
+    break;
+    case IEQ45_EAST:
+    tty_write_string(fd, ":Me#", &nbytes_write);
+    /*portWrite(":Me#");*/
+    break;
+    case IEQ45_SOUTH:
+    tty_write_string(fd, ":Ms#", &nbytes_write);
+    /*portWrite(":Ms#");*/
+    break;
+    default:
+    break;
+  }
+  
+  tcflush(fd, TCIFLUSH);
+  return 0;
+}
+
+int SendPulseCmd(int fd, int direction, int duration_msec)
+{
+  int nbytes_write=0;
+  char cmd[20];
+  switch (direction)
+  {
+    case IEQ45_NORTH: sprintf(cmd, ":Mgn%04d#", duration_msec); break;
+    case IEQ45_SOUTH: sprintf(cmd, ":Mgs%04d#", duration_msec); break;
+    case IEQ45_EAST:  sprintf(cmd, ":Mge%04d#", duration_msec); break;
+    case IEQ45_WEST:  sprintf(cmd, ":Mgw%04d#", duration_msec); break;
+    default: return 1;
+  }
+  
+  tty_write_string(fd, cmd, &nbytes_write);
+  
+  tcflush(fd, TCIFLUSH);
+  return 0;
+}
+
+int HaltMovement(int fd, int direction)
+{
+    int error_type;
+    int nbytes_write=0;
+
+  switch (direction)
+  {
+    case IEQ45_NORTH:
+     /*if (portWrite(":Qn#") < 0)
+      return -1;*/
+       if ( (error_type = tty_write_string(fd, ":Qn#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+     break;
+    case IEQ45_WEST:
+     /*if (portWrite(":Qw#") < 0)
+      return -1;*/
+     if ( (error_type = tty_write_string(fd, ":Qw#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+     break;
+    case IEQ45_EAST:
+     /*if (portWrite(":Qe#") < 0)
+      return -1;*/
+      if ( (error_type = tty_write_string(fd, ":Qe#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+     break;
+    case IEQ45_SOUTH:
+    if ( (error_type = tty_write_string(fd, ":Qs#", &nbytes_write)) != TTY_OK)
+    	return error_type;
+     /*if (portWrite(":Qs#") < 0)
+       return -1;*/
+    break;
+    case IEQ45_ALL:
+     /*if (portWrite(":Q#") < 0)
+       return -1;*/
+	if ( (error_type = tty_write_string(fd, ":Q#", &nbytes_write)) != TTY_OK)
+    	   return error_type;
+     break;
+    default:
+     return -1;
+    break;
+  }
+  
+  tcflush(fd, TCIFLUSH);
+  return 0;
+
+}
+
+int abortSlew(int fd)
+{
+ /*if (portWrite(":Q#") < 0)
+  return -1;*/
+  int error_type;
+  int nbytes_write=0;
+
+ if ( (error_type = tty_write_string(fd, ":Q#", &nbytes_write)) != TTY_OK)
+    	   return error_type;
+
+ tcflush(fd, TCIFLUSH);
+ return 0;
+}
+
+int Sync(int fd, char *matchedObject)
+{
+  int error_type;
+  int nbytes_write=0, nbytes_read=0;
+
+  if ( (error_type = tty_write_string(fd, ":CM#", &nbytes_write)) != TTY_OK)
+    	   return error_type;
+
+  /*portWrite(":CM#");*/
+
+  /*read_ret = portRead(matchedObject, -1, IEQ45_TIMEOUT);*/
+    error_type = tty_read_section(fd, matchedObject, '#', IEQ45_TIMEOUT, &nbytes_read);
+  
+  if (nbytes_read < 1)
+   return error_type;
+   
+  matchedObject[nbytes_read-1] = '\0';
+
+  /*IDLog("Matched Object: %s\n", matchedObject);*/
+  
+  /* Sleep 10ms before flushing. This solves some issues with IEQ45 compatible devices. */
+  usleep(10000);
+  tcflush(fd, TCIFLUSH);
+
+  return 0;
+}
+
+int selectSite(int fd, int siteNum)
+{
+  int error_type;
+  int nbytes_write=0;
+
+  switch (siteNum)
+  {
+    case 1:
+  	if ( (error_type = tty_write_string(fd, ":W1#", &nbytes_write)) != TTY_OK)
+    	   return error_type;
+      /*if (portWrite(":W1#") < 0)
+       return -1;*/
+      break;
+    case 2:
+	if ( (error_type = tty_write_string(fd, ":W2#", &nbytes_write)) != TTY_OK)
+    	   return error_type;
+      /*if (portWrite(":W2#") < 0)
+       return -1;*/
+      break;
+    case 3:
+	if ( (error_type = tty_write_string(fd, ":W3#", &nbytes_write)) != TTY_OK)
+    	   return error_type;
+      /*if (portWrite(":W3#") < 0)
+       return -1;*/
+      break;
+    case 4:
+	if ( (error_type = tty_write_string(fd, ":W4#", &nbytes_write)) != TTY_OK)
+    	   return error_type;
+      /*if (portWrite(":W4#") < 0)
+       return -1;*/
+      break;
+    default:
+    return -1;
+    break;
+  }
+  
+  tcflush(fd, TCIFLUSH);
+  return 0;
+
+}
+
+int selectCatalogObject(int fd, int catalog, int NNNN)
+{
+ char temp_string[16];
+ int error_type;
+ int nbytes_write=0;
+ 
+ switch (catalog)
+ {
+   case IEQ45_STAR_C:
+    snprintf(temp_string, sizeof( temp_string ), ":LS%d#", NNNN);
+    break;
+   case IEQ45_DEEPSKY_C:
+    snprintf(temp_string, sizeof( temp_string ), ":LC%d#", NNNN);
+    break;
+   case IEQ45_MESSIER_C:
+    snprintf(temp_string, sizeof( temp_string ), ":LM%d#", NNNN);
+    break;
+   default:
+    return -1;
+  }
+
+  if ( (error_type = tty_write_string(fd, temp_string, &nbytes_write)) != TTY_OK)
+    	   return error_type;
+  /*if (portWrite(temp_string) < 0)
+   return -1;*/
+
+  tcflush(fd, TCIFLUSH);
+  return 0;
+}
+
+int selectSubCatalog(int fd, int catalog, int subCatalog)
+{
+  char temp_string[16];
+  switch (catalog)
+  {
+    case IEQ45_STAR_C:
+    snprintf(temp_string, sizeof( temp_string ), ":LsD%d#", subCatalog);
+    break;
+    case IEQ45_DEEPSKY_C:
+    snprintf(temp_string, sizeof( temp_string ), ":LoD%d#", subCatalog);
+    break;
+    case IEQ45_MESSIER_C:
+     return 1;
+    default:
+     return 0;
+  }
+
+  return (setStandardProcedure(fd, temp_string));
+}
+
+int checkIEQ45Format(int fd)
+{
+  char temp_string[16];
+  controller_format = IEQ45_LONG_FORMAT;
+  int error_type;
+  int nbytes_write=0, nbytes_read=0;
+
+  if ( (error_type = tty_write_string(fd, ":GR#", &nbytes_write)) != TTY_OK)
+    	   return error_type;
+
+  /*if (portWrite(":GR#") < 0)
+   return -1;*/
+
+  /*read_ret = portRead(temp_string, -1, IEQ45_TIMEOUT);*/
+  error_type = tty_read_section(fd, temp_string, '#', IEQ45_TIMEOUT, &nbytes_read);
+  
+  if (nbytes_read < 1)
+   return error_type;
+   
+  temp_string[nbytes_read - 1] = '\0';
+
+  /* Check whether it's short or long */
+  if (temp_string[5] == '.')
+  {
+     controller_format = IEQ45_SHORT_FORMAT;
+      return 0;
+  }
+  else
+     return 0;
+}
+
+int selectTrackingMode(int fd, int trackMode)
+{
+ int error_type;
+ int nbytes_write=0;
+  
+   switch (trackMode)
+   {
+    case IEQ45_TRACK_SIDERAL:
+      #ifdef INDI_DEBUG
+      IDLog("Setting tracking mode to sidereal.\n");
+      #endif
+     if ( (error_type = tty_write_string(fd, ":RT2#", &nbytes_write)) != TTY_OK)
+    	   return error_type;
+     /*if (portWrite(":TQ#") < 0)
+       return -1;*/
+     break;
+    case IEQ45_TRACK_LUNAR:
+      #ifdef INDI_DEBUG
+      IDLog("Setting tracking mode to LUNAR.\n");
+      #endif
+      if ( (error_type = tty_write_string(fd, ":RT0#", &nbytes_write)) != TTY_OK)
+    	   return error_type;
+     /*if (portWrite(":TL#") < 0)
+       return -1;*/
+     break;
+   case IEQ45_TRACK_SOLAR:
+     #ifdef INDI_DEBUG
+     IDLog("Setting tracking mode to SOLAR.\n");
+     #endif
+     if ( (error_type = tty_write_string(fd, ":RT1#", &nbytes_write)) != TTY_OK)
+    	   return error_type;
+     /*if (portWrite(":TM#") < 0)
+      return -1;*/
+     break;
+   case IEQ45_TRACK_ZERO:
+     #ifdef INDI_DEBUG
+     IDLog("Setting tracking mode to ZERO.\n");
+     #endif
+     if ( (error_type = tty_write_string(fd, ":RT9#", &nbytes_write)) != TTY_OK)
+    	   return error_type;
+     /*if (portWrite(":TM#") < 0)
+      return -1;*/
+     break;
+
+   default:
+    return -1;
+    break;
+   }
+   
+   tcflush(fd, TCIFLUSH);
+   return 0;
+
+}
+
Index: /BAORadio/libindi/libindi/drivers/telescope/ieq45driver.h
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/ieq45driver.h	(revision 646)
+++ /BAORadio/libindi/libindi/drivers/telescope/ieq45driver.h	(revision 646)
@@ -0,0 +1,253 @@
+/*
+    IEQ45 Driver
+    Copyright (C) 2011 Nacho Mas (mas.ignacio@gmail.com). Only litle changes
+    from lx200basic made it by Jasem Mutlaq (mutlaqja@ikarustech.com) 
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+*/
+
+#ifndef IEQ45DRIVER_H
+#define IEQ45DRIVER_H
+
+  /* Slew speeds */
+enum TSlew { IEQ45_SLEW_MAX, IEQ45_SLEW_FIND, IEQ45_SLEW_CENTER, IEQ45_SLEW_GUIDE};
+  /* Alignment modes */
+enum TAlign {  IEQ45_ALIGN_POLAR, IEQ45_ALIGN_ALTAZ, IEQ45_ALIGN_LAND };
+  /* Directions */
+enum TDirection { IEQ45_NORTH, IEQ45_WEST, IEQ45_EAST, IEQ45_SOUTH, IEQ45_ALL};
+  /* Formats of Right ascention and Declenation */
+enum TFormat { IEQ45_SHORT_FORMAT, IEQ45_LONG_FORMAT};
+  /* Time Format */
+enum TTimeFormat { IEQ45_24, IEQ45_AM, IEQ45_PM};
+  /* Focus operation */
+enum TFocusMotion { IEQ45_FOCUSIN, IEQ45_FOCUSOUT };
+enum TFocusSpeed  { IEQ45_HALTFOCUS = 0, IEQ45_FOCUSSLOW, IEQ45_FOCUSFAST};
+  /* Library catalogs */
+enum TCatalog { IEQ45_STAR_C, IEQ45_DEEPSKY_C};
+  /* Frequency mode */
+enum StarCatalog { IEQ45_STAR, IEQ45_SAO, IEQ45_GCVS };
+  /* Deep Sky Catalogs */
+enum DeepSkyCatalog { IEQ45_NGC, IEQ45_IC, IEQ45_UGC, IEQ45_CALDWELL, IEQ45_ARP, IEQ45_ABELL, IEQ45_MESSIER_C};
+  /* Mount tracking frequency, in Hz */
+enum TFreq { IEQ45_TRACK_SIDERAL, IEQ45_TRACK_LUNAR, IEQ45_TRACK_SOLAR,IEQ45_TRACK_ZERO};
+
+
+#define MaxReticleDutyCycle		15
+#define MaxFocuserSpeed			4
+
+/* GET formatted sexagisemal value from device, return as double */
+#define getIEQ45RA(fd, x)				getCommandSexa(fd, x, ":GR#")		//OK
+#define getIEQ45DEC(fd, x)				getCommandSexa(fd, x, ":GD#")		//OK
+//#define getObjectRA(fd, x)				getCommandSexa(fd, x, ":Gr#")		//NO OK
+//#define getObjectDEC(fd, x)				getCommandSexa(fd, x, ":Gd#")		//NO OK
+//#define getLocalTime12(fd, x)				getCommandSexa(fd, x, ":Ga#")		//NO OK
+#define getLocalTime24(fd, x)				getCommandSexa(fd, x, ":GL#")		//OK
+#define getSDTime(fd, x)				getCommandSexa(fd, x, ":GS#")		//OK
+#define getIEQ45Alt(fd, x)				getCommandSexa(fd, x, ":GA#")		//OK
+#define getIEQ45Az(fd, x)				getCommandSexa(fd, x, ":GZ#")		//OK
+
+/* GET String from device and store in supplied buffer x */
+//#define getObjectInfo(fd, x)				getCommandString(fd, x, ":LI#")	//NO OK
+//#define getVersionDate(fd, x)				getCommandString(fd, x, ":GVD#")	//NO OK
+//#define getVersionTime(fd, x)				getCommandString(fd, x, ":GVT#")	//NO OK
+//#define getFullVersion(fd, x)				getCommandString(fd, x, ":GVF#")	//NO OK
+//#define getVersionNumber(fd, x)			getCommandString(fd, x, ":GVN#")	//NO OK
+//#define getProductName(fd, x)				getCommandString(fd, x, ":GVP#")	//NO OK
+//#define turnGPS_StreamOn(fd)				getCommandString(fd, x, ":gps#")	//NO OK
+
+/* GET Int from device and store in supplied pointer to integer x */
+#define getUTCOffset(fd, x)				getCommandInt(fd, x, ":GG#")  		//OK
+//#define getMaxElevationLimit(fd, x)			getCommandInt(fd, x, ":Go#")  		//NO OK
+//#define getMinElevationLimit(fd, x)			getCommandInt(fd, x, ":Gh#")  		//NO OK
+
+/* Generic set, x is an integer */
+//#define setReticleDutyFlashCycle(fd, x)			setCommandInt(fd, x, ":BD")
+#define setReticleFlashRate(fd, x)			setCommandInt(fd, x, ":B")
+#define setFocuserSpeed(fd, x)				setCommandInt(fd, x, ":F")
+#define setSlewSpeed(fd, x)				setCommandInt(fd, x, ":Sw")
+
+/* Set X:Y:Z */
+#define setLocalTime(fd, x,y,z)				setCommandXYZ(fd, x,y,z, ":SL")
+#define setSDTime(fd, x,y,z)				setCommandXYZ(fd, x,y,z, ":SS")
+
+/* GPS Specefic */
+#define turnGPSOn(fd)					write(fd, ":g+#", 5)
+#define turnGPSOff(fd)					write(fd, ":g-#", 5)
+#define alignGPSScope(fd)				write(fd, ":Aa#", 5)
+#define gpsSleep(fd)					write(fd, ":hN#", 5)
+#define gpsWakeUp(fd)					write(fd, ":hW#", 5);
+#define gpsRestart(fd)					write(fd, ":I#", 4);
+#define updateGPS_System(fd)				setStandardProcedure(fd, ":gT#")
+#define enableDecAltPec(fd)				write(fd, ":QA+#", 6)
+#define disableDecAltPec(fd)				write(fd, ":QA-#", 6)
+#define enableRaAzPec(fd)				write(fd, ":QZ+#", 6)
+#define disableRaAzPec(fd)				write(fd, ":QZ-#", 6)
+#define activateAltDecAntiBackSlash(fd)			write(fd, "$BAdd#", 7)
+#define activateAzRaAntiBackSlash(fd)			write(fd, "$BZdd#", 7)
+#define SelenographicSync(fd)				write(fd, ":CL#", 5); 
+
+#define slewToAltAz(fd)					setStandardProcedure(fd, ":MA#")
+#define toggleTimeFormat(fd)				write(fd, ":H#", 4)
+#define increaseReticleBrightness(fd)			write(fd, ":B+#", 5)
+#define decreaseReticleBrightness(fd)			write(fd, ":B-#", 5)
+#define turnFanOn(fd)					write(fd, ":f+#", 5)
+#define turnFanOff(fd)					write(fd, ":f-#", 5)
+#define seekHomeAndSave(fd)				write(fd, ":hS#", 5)
+#define seekHomeAndSet(fd)				write(fd, ":hF#", 5)
+#define turnFieldDeRotatorOn(fd)			write(fd, ":r+#", 5)
+#define turnFieldDeRotatorOff(fd)			write(fd, ":r-#", 5)
+#define slewToPark(fd)					write(fd, ":hP#", 5)
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**************************************************************************
+ Basic I/O - OBSELETE
+**************************************************************************/
+/*int openPort(const char *portID);
+int portRead(char *buf, int nbytes, int timeout);
+int portWrite(const char * buf);
+int IEQ45readOut(int timeout);
+int Connect(const char* device);
+void Disconnect();*/
+
+/**************************************************************************
+ Diagnostics
+ **************************************************************************/
+char ACK(int fd);
+/*int testTelescope();
+int testAP();*/
+int check_IEQ45_connection(int fd);
+
+/**************************************************************************
+ Get Commands: store data in the supplied buffer. Return 0 on success or -1 on failure 
+ **************************************************************************/
+ 
+/* Get Double from Sexagisemal */
+int getCommandSexa(int fd, double *value, const char *cmd);
+/* Get String */
+int getCommandString(int fd, char *data, const char* cmd);
+/* Get Int */
+int getCommandInt(int fd, int *value, const char* cmd);
+/* Get tracking frequency */
+int getTrackFreq(int fd, double * value);
+/* Get site Latitude */
+int getSiteLatitude(int fd, int *dd, int *mm);
+/* Get site Longitude */
+int getSiteLongitude(int fd, int *ddd, int *mm);
+/* Get Calender data */
+int getCalenderDate(int fd, char *date);
+/* Get site Name */
+int getSiteName(int fd, char *siteName, int siteNum);
+/* Get Number of Bars */
+int getNumberOfBars(int fd, int *value);
+/* Get Home Search Status */
+int getHomeSearchStatus(int fd, int *status);
+/* Get OTA Temperature */
+int getOTATemp(int fd, double * value);
+/* Get time format: 12 or 24 */
+int getTimeFormat(int fd, int *format);
+/* Get RA, DEC from Sky Commander controller */
+int updateSkyCommanderCoord(int fd, double *ra, double *dec);
+/* Get RA, DEC from Intelliscope/SkyWizard controllers */
+int updateIntelliscopeCoord (int fd, double *ra, double *dec);
+
+/**************************************************************************
+ Set Commands
+ **************************************************************************/
+
+/* Set Int */
+int setCommandInt(int fd, int data, const char *cmd);
+/* Set Sexigesimal */
+int setCommandXYZ(int fd, int x, int y, int z, const char *cmd);
+/* Common routine for Set commands */
+int setStandardProcedure(int fd, char * writeData);
+/* Set Slew Mode */
+int setSlewMode(int fd, int slewMode);
+/* Set Alignment mode */
+int setAlignmentMode(int fd, unsigned int alignMode);
+/* Set Object RA */
+int setObjectRA(int fd, double ra);
+/* set Object DEC */
+int setObjectDEC(int fd, double dec);
+/* Set Calender date */
+int setCalenderDate(int fd, int dd, int mm, int yy);
+/* Set UTC offset */
+int setUTCOffset(int fd, double hours);
+/* Set Track Freq */
+int setTrackFreq(int fd, double trackF);
+/* Set current site longitude */
+int setSiteLongitude(int fd, double Long);
+/* Set current site latitude */
+int setSiteLatitude(int fd, double Lat);
+/* Set Object Azimuth */
+int setObjAz(int fd, double az);
+/* Set Object Altitude */
+int setObjAlt(int fd, double alt);
+/* Set site name */
+int setSiteName(int fd, char * siteName, int siteNum);
+/* Set maximum slew rate */
+int setMaxSlewRate(int fd, int slewRate);
+/* Set focuser motion */
+int setFocuserMotion(int fd, int motionType);
+/* SET GPS Focuser raneg (1 to 4) */
+int setGPSFocuserSpeed (int fd, int speed);
+/* Set focuser speed mode */
+int setFocuserSpeedMode (int fd, int speedMode);
+/* Set minimum elevation limit */
+int setMinElevationLimit(int fd, int min);
+/* Set maximum elevation limit */
+int setMaxElevationLimit(int fd, int max);
+
+/**************************************************************************
+ Motion Commands
+ **************************************************************************/
+/* Slew to the selected coordinates */
+int Slew(int fd);
+/* Synchronize to the selected coordinates and return the matching object if any */
+int Sync(int fd, char *matchedObject);
+/* Abort slew in all axes */
+int abortSlew(int fd);
+/* Move into one direction, two valid directions can be stacked */
+int MoveTo(int fd, int direction);
+/* Halt movement in a particular direction */
+int HaltMovement(int fd, int direction);
+/* Select the tracking mode */
+int selectTrackingMode(int fd, int trackMode);
+/* Select Astro-Physics tracking mode */
+int selectAPTrackingMode(int fd, int trackMode);
+/* Send Pulse-Guide command (timed guide move), two valid directions can be stacked */
+int SendPulseCmd(int fd, int direction, int duration_msec);
+
+/**************************************************************************
+ Other Commands
+ **************************************************************************/
+ /* Ensures IEQ45 RA/DEC format is long */
+int checkIEQ45Format(int fd);
+/* Select a site from the IEQ45 controller */
+int selectSite(int fd, int siteNum);
+/* Select a catalog object */
+int selectCatalogObject(int fd, int catalog, int NNNN);
+/* Select a sub catalog */
+int selectSubCatalog(int fd, int catalog, int subCatalog);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /BAORadio/libindi/libindi/drivers/telescope/lx200fs2.cpp
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/lx200fs2.cpp	(revision 646)
+++ /BAORadio/libindi/libindi/drivers/telescope/lx200fs2.cpp	(revision 646)
@@ -0,0 +1,348 @@
+#if 0
+    LX200 FS2 Driver
+	Copyright (C) 2009 Ferran Casarramona (ferran.casarramona@gmail.com)
+	Based on LX200 driver from:
+    Copyright (C) 2005 Jasem Mutlaq (mutlaqja@ikarustech.com)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+#endif
+
+#include <string.h>
+
+/* LX200 Command Set */
+#include "lx200driver.h"
+
+/* Our driver header */
+#include "lx200fs2.h"
+
+using namespace std;
+
+/* Our telescope auto pointer */
+extern LX200Generic *telescope;
+
+// Access to properties defined in LX200Generic
+extern ISwitchVectorProperty ConnectSP;
+extern ITextVectorProperty   PortTP;
+
+const char *BASIC_GROUP    = "Main Control";		// Main Group
+const char *OPTIONS_GROUP  = "Options";			// Options Group
+const char *MOTION_GROUP   = "Motion Control";
+
+/* Handy Macros */
+#define currentRA	EquatorialCoordsRN[0].value
+#define currentDEC	EquatorialCoordsRN[1].value
+#define targetRA	EquatorialCoordsWN[0].value
+#define targetDEC	EquatorialCoordsWN[1].value
+
+static void retryConnection(void *);
+
+void changeLX200FS2DeviceName(const char *newName)
+{
+
+}
+
+/**************************************************************************************
+** LX200 FS2 constructor
+***************************************************************************************/
+LX200Fs2::LX200Fs2() : LX200Generic()
+{
+   DeviceName = "LX200 FS2";
+   init_properties();
+
+   IDLog("Initilizing from LX200 FS2 device...\n");
+   IDLog("Driver Version: 2011-01-02\n");
+ 
+   //enableSimulation(true);  
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+LX200Fs2::~LX200Fs2()
+{
+
+}
+
+/**************************************************************************************
+** Initialize all properties & set default values.
+***************************************************************************************/
+void LX200Fs2::init_properties()
+{
+    // Firmware Version
+    IUFillNumber(&FirmwareVerN[0], "FirmwareVer", "Firmware version", "%2.2f", 1.16, 1.25, 0.01, 1.18);
+    IUFillNumberVector(&FirmwareVerNP, FirmwareVerN, NARRAY(FirmwareVerN), DeviceName, "FIRMWARE_VER" , "Firmware", BASIC_GROUP, IP_RW, 0, IPS_IDLE);
+}
+
+/**************************************************************************************
+** Define LX200 FS2 properties to clients.
+***************************************************************************************/
+void LX200Fs2::ISGetProperties(const char *dev)
+{
+
+ if (dev && strcmp (DeviceName, dev))
+    return;
+
+  LX200Generic::ISGetProperties(dev);
+  // Delete not supported properties 
+		IDDelete(DeviceName, "Alignment", NULL);
+		IDDelete(DeviceName, "Tracking Mode", NULL);
+		IDDelete(DeviceName, "Tracking Frequency", NULL);
+		// Focus
+		IDDelete(DeviceName, "FOCUS_MOTION", NULL);
+		IDDelete(DeviceName, "FOCUS_TIMER", NULL);
+		IDDelete(DeviceName, "FOCUS_MODE", NULL);
+		// Time
+		IDDelete(DeviceName, "TIME_UTC", NULL);
+		IDDelete(DeviceName, "TIME_UTC_OFFSET", NULL);
+		IDDelete(DeviceName, "TIME_LST", NULL);
+		// Sites
+		IDDelete(DeviceName, "Sites", NULL);
+		IDDelete(DeviceName, "Site Name", NULL);
+		
+  IDDefNumber(&FirmwareVerNP, NULL);
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void LX200Fs2::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
+{
+	
+	// Ignore if not ours
+	if (strcmp (dev, DeviceName))
+	    return;
+
+	// ===================================
+        // Update Firmware version
+	// ===================================
+	if (!strcmp (name, FirmwareVerNP.name))
+	{
+		if (IUUpdateNumber(&FirmwareVerNP, values, names, n) < 0)
+			return;
+
+		FirmwareVerNP.s = IPS_OK;
+
+		IDSetNumber(&FirmwareVerNP, NULL);
+		return;
+	}
+	
+	LX200Generic::ISNewNumber (dev, name, values, names, n);
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+int LX200Fs2::check_fs2_connection(int fd)
+{
+  double x;
+  
+  if (FirmwareVerNP.np[0].value < 1.19)
+	return getLX200RA(fd, &x); // Version 1.18 and below don't support ACK command
+  else
+	return check_lx200_connection(fd);
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void LX200Fs2::connectTelescope()
+{
+     switch (ConnectSP.sp[0].s)
+     {
+      case ISS_ON:  
+	
+		fprintf (stderr, "Trace: LX200FS2 connectTelescope ON");
+        if (simulation)
+		{
+			ConnectSP.s = IPS_OK;
+			IDSetSwitch (&ConnectSP, "Simulated telescope is online.");
+			return;
+		}
+	
+        if (tty_connect(PortTP.tp[0].text, 9600, 8, 0, 1, &fd) != TTY_OK)
+		{
+			ConnectSP.sp[0].s = ISS_OFF;
+			ConnectSP.sp[1].s = ISS_ON;
+			IDSetSwitch (&ConnectSP, "Error connecting to port %s. Make sure you have BOTH read and write permission to the port.", PortTP.tp[0].text);
+			return;
+		}
+
+		if (check_fs2_connection(fd))
+		{   
+			ConnectSP.sp[0].s = ISS_OFF;
+			ConnectSP.sp[1].s = ISS_ON;
+			IDSetSwitch (&ConnectSP, "Error connecting to Telescope. Telescope is offline.");
+			return;
+		}
+
+		ConnectSP.s = IPS_OK;
+		IDSetSwitch (&ConnectSP, "Telescope is online. Retrieving basic data...");
+		getBasicData();
+		break;
+
+     case ISS_OFF:
+        ConnectSP.sp[0].s = ISS_OFF;
+		ConnectSP.sp[1].s = ISS_ON;
+        ConnectSP.s = IPS_IDLE;
+		if (simulation)
+         {
+			IDSetSwitch (&ConnectSP, "Simulated Telescope is offline.");
+			return;
+         }
+         IDSetSwitch (&ConnectSP, "Telescope is offline.");
+		 IDLog("Telescope is offline.");
+         
+		 tty_disconnect(fd);
+		 break;
+    }
+}
+
+/**************************************************************************************
+**
+***************************************************************************************/
+void LX200Fs2::getBasicData()
+{
+
+  // process parent first
+   LX200Generic::getBasicData();
+  // Make sure short
+  //checkLX200Format(fd);
+
+  // Get current RA/DEC
+  //getLX200RA(fd, &currentRA);
+  //getLX200DEC(fd, &currentDEC);
+
+  //IDSetNumber (&EquatorialCoordsRNP, NULL);  
+}
+
+/**********************************************************************************
+**  handleError functions. Redefined because they call check_lx200_connection and this
+**                         driver needs to call check_fs2_connection
+**************************************************************************************/
+static void retryConnection(void * p)
+{
+  int fd = *((int *) p);
+
+  if (((LX200Fs2 *)telescope)->check_fs2_connection(fd))
+  {
+    ConnectSP.s = IPS_IDLE;
+    IDSetSwitch(&ConnectSP, "The connection to the telescope is lost.");
+    return;
+  }
+  
+  ConnectSP.sp[0].s = ISS_ON;
+  ConnectSP.sp[1].s = ISS_OFF;
+  ConnectSP.s = IPS_OK;
+   
+  IDSetSwitch(&ConnectSP, "The connection to the telescope has been resumed.");
+}
+
+void LX200Fs2::handleError(ISwitchVectorProperty *svp, int err, const char *msg)
+{
+  
+  svp->s = IPS_ALERT;
+  
+  /* First check to see if the telescope is connected */
+    if (check_fs2_connection(fd))
+    {
+      /* The telescope is off locally */
+      ConnectSP.sp[0].s = ISS_OFF;
+      ConnectSP.sp[1].s = ISS_ON;
+      ConnectSP.s = IPS_BUSY;
+      IDSetSwitch(&ConnectSP, "Telescope is not responding to commands, will retry in 10 seconds.");
+      
+      IDSetSwitch(svp, NULL);
+      IEAddTimer(10000, retryConnection, &fd);
+      return;
+    }
+    
+   /* If the error is a time out, then the device doesn't support this property or busy*/
+      if (err == -2)
+      {
+       svp->s = IPS_ALERT;
+       IDSetSwitch(svp, "Device timed out. Current device may be busy or does not support %s. Will retry again.", msg);
+      }
+      else
+    /* Changing property failed, user should retry. */
+       IDSetSwitch( svp , "%s failed.", msg);
+       
+       fault = true;
+}
+
+void LX200Fs2::handleError(INumberVectorProperty *nvp, int err, const char *msg)
+{
+  
+  nvp->s = IPS_ALERT;
+  
+  /* First check to see if the telescope is connected */
+    if (check_fs2_connection(fd))
+    {
+      /* The telescope is off locally */
+      ConnectSP.sp[0].s = ISS_OFF;
+      ConnectSP.sp[1].s = ISS_ON;
+      ConnectSP.s = IPS_BUSY;
+      IDSetSwitch(&ConnectSP, "Telescope is not responding to commands, will retry in 10 seconds.");
+      
+      IDSetNumber(nvp, NULL);
+      IEAddTimer(10000, retryConnection, &fd);
+      return;
+    }
+    
+   /* If the error is a time out, then the device doesn't support this property */
+      if (err == -2)
+      {
+       nvp->s = IPS_ALERT;
+       IDSetNumber(nvp, "Device timed out. Current device may be busy or does not support %s. Will retry again.", msg);
+      }
+      else
+    /* Changing property failed, user should retry. */
+       IDSetNumber( nvp , "%s failed.", msg);
+       
+       fault = true;
+}
+
+void LX200Fs2::handleError(ITextVectorProperty *tvp, int err, const char *msg)
+{
+  
+  tvp->s = IPS_ALERT;
+  
+  /* First check to see if the telescope is connected */
+    if (check_fs2_connection(fd))
+    {
+      /* The telescope is off locally */
+      ConnectSP.sp[0].s = ISS_OFF;
+      ConnectSP.sp[1].s = ISS_ON;
+      ConnectSP.s = IPS_BUSY;
+      IDSetSwitch(&ConnectSP, "Telescope is not responding to commands, will retry in 10 seconds.");
+      
+      IDSetText(tvp, NULL);
+      IEAddTimer(10000, retryConnection, &fd);
+      return;
+    }
+    
+   /* If the error is a time out, then the device doesn't support this property */
+      if (err == -2)
+      {
+       tvp->s = IPS_ALERT;
+       IDSetText(tvp, "Device timed out. Current device may be busy or does not support %s. Will retry again.", msg);
+      }
+       
+      else
+    /* Changing property failed, user should retry. */
+       IDSetText( tvp , "%s failed.", msg);
+       
+       fault = true;
+}
Index: /BAORadio/libindi/libindi/drivers/telescope/lx200fs2.h
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/lx200fs2.h	(revision 646)
+++ /BAORadio/libindi/libindi/drivers/telescope/lx200fs2.h	(revision 646)
@@ -0,0 +1,74 @@
+/*
+    LX200 FS2 Driver
+	Copyright (C) 2009 Ferran Casarramona (ferran.casarramona@gmail.com)
+	Based on LX200 Basic driver from:
+    Copyright (C) 2005 Jasem Mutlaq (mutlaqja@ikarustech.com)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+*/
+
+#ifndef LX200FS2_H
+#define LX200FS2_H
+
+//#include "indidevapi.h"
+//#include "indicom.h"
+
+#include "lx200generic.h"
+// To prevent of using mydev from generic by error
+#ifdef mydev
+#undef mydevice
+#endif
+
+class LX200Fs2 : public LX200Generic
+{
+ public:
+ LX200Fs2();
+ ~LX200Fs2();
+
+ virtual void ISGetProperties (const char *dev);
+ virtual void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n);
+ // Not implemented. LX200 generic used. 
+ //virtual void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n);
+ //virtual void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
+ //virtual void ISPoll ();
+ virtual void handleError(ISwitchVectorProperty *svp, int err, const char *msg);
+ virtual void handleError(INumberVectorProperty *nvp, int err, const char *msg);
+ virtual void handleError(ITextVectorProperty *tvp, int err, const char *msg);
+ 
+ protected:
+ 
+  const char *DeviceName;
+   /* Numbers */
+  INumber FirmwareVerN[1]; // Firmware version
+    
+   /* Number Vectors */
+  INumberVectorProperty FirmwareVerNP;  
+  
+ //*******************************************************/
+ /* Connection Routines
+ ********************************************************/
+ void init_properties();
+ void getBasicData();
+ virtual void connectTelescope();
+ bool is_connected(void);
+public:
+ int check_fs2_connection(int fd); // Added to support firmware versions below 1.19
+
+};
+
+void changeLX200FS2DeviceName(const char *newName);
+
+#endif
Index: /BAORadio/libindi/libindi/drivers/telescope/magellan1.cpp
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/magellan1.cpp	(revision 646)
+++ /BAORadio/libindi/libindi/drivers/telescope/magellan1.cpp	(revision 646)
@@ -0,0 +1,481 @@
+#if 0
+    MAGELLAN Generic
+    Copyright (C) 2011 Onno Hommes (ohommes@alumni.cmu.edu)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <math.h>
+#include <unistd.h>
+#include <time.h>
+#include <sys/time.h>
+
+#include "magellandriver.h"
+#include "magellan1.h"
+
+#include <config.h>
+
+Magellan1 *telescope = NULL;
+
+extern char* me;
+
+#define COMM_GROUP	"Communication"
+#define BASIC_GROUP	"Position"
+
+#define MAGELLAN_TRACK	0
+#define MAGELLAN_SYNC	1
+
+/* Handy Macros */
+#define currentRA	EquatorialCoordsRN[0].value
+#define currentDEC	EquatorialCoordsRN[1].value
+#define targetRA	EquatorialCoordsWN[0].value
+#define targetDEC	EquatorialCoordsWN[1].value
+
+static void ISPoll(void *);
+static void retryConnection(void *);
+
+/*INDI Propertries */
+
+/**********************************************************************************************/
+/************************************ GROUP: Communication ************************************/
+/**********************************************************************************************/
+
+/********************************************
+ Property: Connection
+*********************************************/
+static ISwitch ConnectS[]          	= {{"CONNECT" , "Connect" , ISS_OFF, 0, 0},{"DISCONNECT", "Disconnect", ISS_ON, 0, 0}};
+ISwitchVectorProperty ConnectSP		= { mydev, "CONNECTION" , "Connection", COMM_GROUP, IP_RW, ISR_1OFMANY, 0, IPS_IDLE, ConnectS, NARRAY(ConnectS), "", 0};
+
+/********************************************
+ Property: Device Port
+*********************************************/
+/*wildi removed static */
+static IText PortT[]			= {{"PORT", "Port", 0, 0, 0, 0}};
+ITextVectorProperty PortTP	= { mydev, "DEVICE_PORT", "Ports", COMM_GROUP, IP_RW, 0, IPS_IDLE, PortT, NARRAY(PortT), "", 0};
+
+/**********************************************************************************************/
+/************************************ GROUP: Position Display**********************************/
+/**********************************************************************************************/
+
+/********************************************
+ Property: Equatorial Coordinates JNow
+ Perm: Transient WO.
+ Timeout: 120 seconds.
+*********************************************/
+INumber EquatorialCoordsWN[] 		= { {"RA",  "RA  H:M:S", "%10.6m",  0., 24., 0., 0., 0, 0, 0}, {"DEC", "Dec D:M:S", "%10.6m", -90., 90., 0., 0., 0, 0, 0} };
+INumberVectorProperty EquatorialCoordsWNP= { mydev, "EQUATORIAL_EOD_COORD_REQUEST", "Equatorial JNow", BASIC_GROUP, IP_WO, 120, IPS_IDLE, EquatorialCoordsWN, NARRAY(EquatorialCoordsWN), "", 0};
+
+/********************************************
+ Property: Equatorial Coordinates JNow
+ Perm: RO
+*********************************************/
+INumber EquatorialCoordsRN[]	 	= { {"RA",  "RA  H:M:S", "%10.6m",  0., 24., 0., 0., 0, 0, 0}, {"DEC", "Dec D:M:S", "%10.6m", -90., 90., 0., 0., 0, 0, 0}};
+INumberVectorProperty EquatorialCoordsRNP= { mydev, "EQUATORIAL_EOD_COORD", "Equatorial JNow", BASIC_GROUP, IP_RO, 120, IPS_IDLE, EquatorialCoordsRN, NARRAY(EquatorialCoordsRN), "", 0};
+
+
+/*****************************************************************************************************/
+/**************************************** END PROPERTIES *********************************************/
+/*****************************************************************************************************/
+
+/* send client definitions of all properties */
+void ISInit()
+{
+  if (telescope == NULL)
+  {
+    IUSaveText(&PortT[0], "/dev/ttyS0");
+    telescope = new Magellan1();
+    telescope->setCurrentDeviceName(mydev);
+  }
+}
+
+void ISGetProperties (const char *dev)
+{ ISInit(); telescope->ISGetProperties(dev); IEAddTimer (POLLMS, ISPoll, NULL);}
+
+void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
+{ ISInit(); telescope->ISNewSwitch(dev, name, states, names, n);}
+
+void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
+{ ISInit(); telescope->ISNewText(dev, name, texts, names, n);}
+
+void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
+{ ISInit(); telescope->ISNewNumber(dev, name, values, names, n);}
+
+void ISPoll (void *p)
+{ telescope->ISPoll(); IEAddTimer (POLLMS, ISPoll, NULL); p=p;}
+
+void ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
+{
+  INDI_UNUSED(dev);
+  INDI_UNUSED(name);
+  INDI_UNUSED(sizes);
+  INDI_UNUSED(blobsizes);
+  INDI_UNUSED(blobs);
+  INDI_UNUSED(formats);
+  INDI_UNUSED(names);
+  INDI_UNUSED(n);
+}
+
+void ISSnoopDevice (XMLEle *root)
+{
+  telescope->ISSnoopDevice(root);
+}
+
+/**************************************************
+*** MAGELLAN1 Implementation
+***************************************************/
+
+Magellan1::Magellan1()
+{
+   currentSiteNum = 1;
+   trackingMode   = MAGELLAN_TRACK_DEFAULT;
+   lastSet        = -1;
+   fault          = false;
+   simulation     = false;
+   currentSet     = 0;
+   fd             = -1;
+
+   // Children call parent routines, this is the default
+   IDLog("INDI Library v%g\n", INDI_LIBV);
+   IDLog("Initializing from MAGELLAN device...\n");
+   IDLog("Driver Version: 2011-07-28\n");
+}
+
+Magellan1::~Magellan1()
+{
+}
+
+void Magellan1::setCurrentDeviceName(const char * devName)
+{
+  strcpy(thisDevice, devName);
+}
+
+void Magellan1::ISGetProperties(const char *dev)
+{
+
+ if (dev && strcmp (thisDevice, dev))
+    return;
+
+  // COMM_GROUP
+  IDDefSwitch (&ConnectSP, NULL);
+  IDDefText   (&PortTP, NULL);
+
+  // POSITION_GROUP
+  IDDefNumber (&EquatorialCoordsRNP, NULL);
+  
+  /* Send the basic data to the new client if the previous client(s) are already connected. */		
+   if (ConnectSP.s == IPS_OK)
+       getBasicData();
+}
+
+void Magellan1::ISSnoopDevice (XMLEle *root)
+{
+  INDI_UNUSED(root);
+}
+
+void Magellan1::ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
+{
+  IText *tp;
+
+  /* Ignore other devices */
+  if (strcmp (dev, thisDevice))
+      return;
+  
+  /* See if the port is updated */
+  if (!strcmp(name, PortTP.name) )
+  {
+    PortTP.s = IPS_OK;
+    tp = IUFindText( &PortTP, names[0] );
+    if (!tp)
+      return;
+
+    IUSaveText(&PortTP.tp[0], texts[0]);
+    IDSetText (&PortTP, NULL);
+    return;
+  }
+}
+
+void Magellan1::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
+{
+  INDI_UNUSED(dev);
+  INDI_UNUSED(name);
+  INDI_UNUSED(values);
+  INDI_UNUSED(names);
+  INDI_UNUSED(n);
+}
+
+void Magellan1::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
+{
+  INDI_UNUSED(names);
+
+  /* Ignore other devices */
+  if (strcmp (thisDevice, dev))
+      return;
+  
+  // FIRST Switch ALWAYS for Connection
+  if (!strcmp (name, ConnectSP.name))
+  {
+    bool connectionEstablished = (ConnectS[0].s == ISS_ON);
+    if (IUUpdateSwitch(&ConnectSP, states, names, n) < 0) return;
+    if ( (connectionEstablished && ConnectS[0].s == ISS_ON) || (!connectionEstablished && ConnectS[1].s == ISS_ON))
+    {
+      ConnectSP.s = IPS_OK;
+      IDSetSwitch(&ConnectSP, NULL);
+      return;
+    }
+    connectTelescope();
+    return;
+  }
+}
+
+void Magellan1::handleError(ISwitchVectorProperty *svp, int err, const char *msg)
+{
+  
+  svp->s = IPS_ALERT;
+  
+    /* First check to see if the telescope is connected */
+    if (check_magellan_connection(fd))
+    {
+      /* The telescope is off locally */
+      ConnectS[0].s = ISS_OFF;
+      ConnectS[1].s = ISS_ON;
+      ConnectSP.s = IPS_BUSY;
+      IDSetSwitch(&ConnectSP, "Telescope is not responding to commands, will retry in 10 seconds.");
+      
+      IDSetSwitch(svp, NULL);
+      IEAddTimer(10000, retryConnection, &fd);
+      return;
+    }
+    
+      /* If the error is a time out, then the device doesn't support this property or busy*/
+      if (err == -2)
+      {
+       svp->s = IPS_ALERT;
+       IDSetSwitch(svp, "Device timed out. Current device may be busy or does not support %s. Will retry again.", msg);
+      }
+      else
+       /* Changing property failed, user should retry. */
+       IDSetSwitch( svp , "%s failed.", msg);
+       
+   fault = true;
+}
+
+void Magellan1::handleError(INumberVectorProperty *nvp, int err, const char *msg)
+{
+  
+  nvp->s = IPS_ALERT;
+  
+  /* First check to see if the telescope is connected */
+    if (check_magellan_connection(fd))
+    {
+      /* The telescope is off locally */
+      ConnectS[0].s = ISS_OFF;
+      ConnectS[1].s = ISS_ON;
+      ConnectSP.s = IPS_BUSY;
+      IDSetSwitch(&ConnectSP, "Telescope is not responding to commands, will retry in 10 seconds.");
+      
+      IDSetNumber(nvp, NULL);
+      IEAddTimer(10000, retryConnection, &fd);
+      return;
+    }
+    
+   /* If the error is a time out, then the device doesn't support this property */
+      if (err == -2)
+      {
+       nvp->s = IPS_ALERT;
+       IDSetNumber(nvp, "Device timed out. Current device may be busy or does not support %s. Will retry again.", msg);
+      }
+      else
+    /* Changing property failed, user should retry. */
+       IDSetNumber( nvp , "%s failed.", msg);
+       
+   fault = true;
+}
+
+void Magellan1::handleError(ITextVectorProperty *tvp, int err, const char *msg)
+{
+  
+tvp->s = IPS_ALERT;
+
+  /* First check to see if the telescope is connected */
+  if (check_magellan_connection(fd))
+  {
+    /* The telescope is off locally */
+    ConnectS[0].s = ISS_OFF;
+    ConnectS[1].s = ISS_ON;
+    ConnectSP.s = IPS_BUSY;
+    IDSetSwitch(&ConnectSP, "Telescope is not responding to commands, will retry in 10 seconds.");
+    
+    IDSetText(tvp, NULL);
+    IEAddTimer(10000, retryConnection, &fd);
+    return;
+  }
+  
+  /* If the error is a time out, then the device doesn't support this property */
+  if (err == -2)
+  {
+      tvp->s = IPS_ALERT;
+      IDSetText(tvp, "Device timed out. Current device may be busy or does not support %s. Will retry again.", msg);
+  }
+      
+  else
+  {
+    /* Changing property failed, user should retry. */
+    IDSetText( tvp , "%s failed.", msg);
+  }
+      
+  fault = true;
+}
+
+ void Magellan1::correctFault()
+ {
+ 
+   fault = false;
+   IDMessage(thisDevice, "Telescope is online.");
+   
+ }
+
+bool Magellan1::isTelescopeOn(void)
+{
+  return (ConnectSP.sp[0].s == ISS_ON);
+}
+
+static void retryConnection(void * p)
+{
+  int fd = *( (int *) p);
+  
+  if (check_magellan_connection(fd))
+  {
+    ConnectSP.s = IPS_IDLE;
+    IDSetSwitch(&ConnectSP, "The connection to the telescope is lost.");
+    return;
+  }
+  
+  ConnectS[0].s = ISS_ON;
+  ConnectS[1].s = ISS_OFF;
+  ConnectSP.s = IPS_OK;
+   
+  IDSetSwitch(&ConnectSP, "The connection to the telescope has been resumed.");
+
+}
+
+void Magellan1::ISPoll()
+{
+    int err=0;
+    
+    if (!isTelescopeOn())
+      return;
+
+    if ( (err = getMAGELLANRA(fd, &currentRA)) < 0 || (err = getMAGELLANDEC(fd, &currentDEC)) < 0)
+    {
+      EquatorialCoordsRNP.s = IPS_ALERT;
+      IDSetNumber(&EquatorialCoordsRNP, NULL);
+      handleError(&EquatorialCoordsRNP, err, "Getting RA/DEC");
+      return;
+    }
+    
+    if (fault) correctFault();
+
+    EquatorialCoordsRNP.s = IPS_OK;
+
+    lastRA  = currentRA;
+    lastDEC = currentDEC;
+    IDSetNumber (&EquatorialCoordsRNP, NULL);
+}
+
+void Magellan1::getBasicData()
+{
+  char caldendarDate[10];
+  int err;
+
+  /* Magellan 1 Get Calendar Date As a Test (always 1/1/96) */
+  if ( (err = getCalenderDate(fd, caldendarDate)) < 0)
+     IDMessage(thisDevice, "Failed to retrieve calendar date from device.");
+  else
+     IDMessage(thisDevice, "Successfully retrieved calendar date from device.");
+    
+  
+  /* Only 24 Time format on Magellan and you cant get to the local time
+     which you can set in Magellan I */
+  timeFormat = MAGELLAN_24;
+
+  if ( (err = getMAGELLANRA(fd, &targetRA)) < 0 || (err = getMAGELLANDEC(fd, &targetDEC)) < 0)
+  {
+     EquatorialCoordsRNP.s = IPS_ALERT;
+     IDSetNumber(&EquatorialCoordsRNP, NULL);
+     handleError(&EquatorialCoordsRNP, err, "Getting RA/DEC");
+     return;
+  }
+	
+  if (fault) correctFault();
+
+  EquatorialCoordsRNP.np[0].value = targetRA;
+  EquatorialCoordsRNP.np[1].value = targetDEC;
+  
+  EquatorialCoordsRNP.s = IPS_OK;
+  IDSetNumber (&EquatorialCoordsRNP, NULL);  
+     
+}
+
+void Magellan1::connectTelescope()
+{
+    switch (ConnectSP.sp[0].s)
+    {
+    case ISS_ON:  
+       
+        /* Magellan I only has 1200 buad, 8 data bits, 0 parity and 1 stop bit */
+	if (tty_connect(PortTP.tp[0].text, 1200, 8, 0, 1, &fd) != TTY_OK)
+	{
+	  ConnectS[0].s = ISS_OFF;
+	  ConnectS[1].s = ISS_ON;
+	  IDSetSwitch (&ConnectSP, "Error connecting to port %s. Make sure you have BOTH write and read permission to your port.\n", PortTP.tp[0].text);
+	  return;
+	}
+	if (check_magellan_connection(fd))
+	{   
+	  ConnectS[0].s = ISS_OFF;
+	  ConnectS[1].s = ISS_ON;
+	  IDSetSwitch (&ConnectSP, "Error connecting to Telescope. Telescope is offline.");
+	  return;
+	}
+
+      #ifdef INDI_DEBUG
+      IDLog("Telescope test successful.\n");
+      #endif
+
+      ConnectSP.s = IPS_OK;
+      IDSetSwitch (&ConnectSP, "Telescope is online. Retrieving basic data...");
+      getBasicData();
+      break;
+
+    case ISS_OFF:
+	ConnectS[0].s = ISS_OFF;
+	ConnectS[1].s = ISS_ON;
+	ConnectSP.s = IPS_IDLE;
+	IDSetSwitch (&ConnectSP, "Telescope is offline.");
+	IDLog("Telescope is offline.");
+	tty_disconnect(fd);
+	break;
+
+  }
+
+}
+
+
+
Index: /BAORadio/libindi/libindi/drivers/telescope/magellan1.h
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/magellan1.h	(revision 646)
+++ /BAORadio/libindi/libindi/drivers/telescope/magellan1.h	(revision 646)
@@ -0,0 +1,76 @@
+/*
+    MAGELLAN Generic
+    Copyright (C) 2011 Onno Hommes  (ohommes@alumni.cmu.edu)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+*/
+
+#ifndef MAGELLAN1_H
+#define MAGELLAN1_H
+
+#include "indidevapi.h"
+#include "indicom.h"
+
+#define	POLLMS		1000	     /* poll period, ms */
+
+/* 
+   The device name below eventhough we have a Magellan I
+   should remain set to a KStars registered telescope so
+   It allows the service to be stopped
+*/
+#define mydev		"Magellan I" /* The device name */
+
+class Magellan1
+{
+ public:
+ Magellan1();
+ virtual ~Magellan1();
+
+ virtual void ISGetProperties (const char *dev);
+ virtual void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n);
+ virtual void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n);
+ virtual void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
+ virtual void ISSnoopDevice (XMLEle *root);
+ virtual void ISPoll ();
+ virtual void getBasicData();
+
+ void handleError(ISwitchVectorProperty *svp, int err, const char *msg);
+ void handleError(INumberVectorProperty *nvp, int err, const char *msg);
+ void handleError(ITextVectorProperty *tvp, int err, const char *msg);
+ bool isTelescopeOn(void);
+ void connectTelescope();
+ void setCurrentDeviceName(const char * devName);
+ void correctFault();
+
+ int    fd;
+
+ protected:
+  int timeFormat;
+  int currentSiteNum;
+  int trackingMode;
+
+  double JD;
+  double lastRA;
+  double lastDEC;
+  bool   fault;
+  bool   simulation;
+  char   thisDevice[64];
+  int    currentSet;
+  int    lastSet;
+
+};
+
+#endif
Index: /BAORadio/libindi/libindi/drivers/telescope/magellandriver.c
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/magellandriver.c	(revision 646)
+++ /BAORadio/libindi/libindi/drivers/telescope/magellandriver.c	(revision 646)
@@ -0,0 +1,214 @@
+#if 0
+    MAGELLAN Driver
+    Copyright (C) 2011 Onno Hommes  (ohommes@alumni.cmu.edu)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <math.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <time.h>
+
+#include "indicom.h"
+#include "indidevapi.h"
+#include "magellandriver.h"
+
+#ifndef _WIN32
+#include <termios.h>
+#endif
+
+/**************************************************************************
+ Connection Diagnostics
+ **************************************************************************/
+char ACK(int fd);
+int check_magellan_connection(int fd);
+
+/**************************************************************************
+ Get Commands: store data in the supplied buffer. 
+ Return 0 on success or -1 on failure 
+ **************************************************************************/
+ 
+/* Get Double from Sexagisemal */
+int getCommandSexa(int fd, double *value, const char *cmd);
+
+/* Get String */
+static int getCommandString(int fd, char *data, const char* cmd);
+
+/* Get Calender data */
+int getCalenderDate(int fd, char *date);
+
+
+/**************************************************************************
+ Driver Implementations
+ **************************************************************************/
+
+/* 
+   Check the Magellan Connection using any set command
+   Magellan 1 does not support any sey but still sends
+   'OK' for it
+*/
+int check_magellan_connection(int fd)
+{
+  int i=0;
+ 
+  /* Magellan I ALways Response OK for :S?# */
+  char ack[4] = ":S?#";
+
+  char Response[64];
+  int nbytes_read=0;
+
+  #ifdef INDI_DEBUG
+  IDLog("Testing telescope's connection...\n");
+  #endif
+
+  if (fd <= 0) return MAGELLAN_ERROR;
+
+  for (i=0; i < CONNECTION_RETRIES; i++)
+  {
+    if (write(fd, ack, 4) < 0) return MAGELLAN_ERROR;
+    
+    tty_read(fd, Response, 2, MAGELLAN_TIMEOUT, &nbytes_read);
+    
+    if (nbytes_read == 2) return MAGELLAN_OK;
+    
+    usleep(50000);
+  }
+
+  tcflush(fd, TCIFLUSH);
+  return MAGELLAN_ERROR;
+}
+
+
+/**********************************************************************
+* GET FUNCTIONS
+**********************************************************************/
+
+char ACK(int fd)
+{
+ 
+  /* Magellan I ALways Response OK for :S?# (any set will do)*/
+  char ack[4] = ":S?#";
+  char Response[64];
+  int nbytes_read=0;
+  int i=0;
+  int result = MAGELLAN_ERROR;
+
+  /* Check for Comm handle */
+  if (fd > 0) 
+  {
+    for (i=0; i < CONNECTION_RETRIES; i++)
+    {
+      /* Send ACK string to Magellan */
+      if (write(fd, ack, 4) >= 0)
+      {
+	/* Read Response */
+	tty_read(fd, Response, 2, MAGELLAN_TIMEOUT, &nbytes_read);
+	
+	/* If the two byte OK is returned we have an Ack */
+	if (nbytes_read == 2) 
+	{
+	  result = MAGELLAN_ACK;
+	  break; /* Force quick success return */
+	}
+	else usleep(50000);
+      }
+    }
+  }
+
+  tcflush(fd, TCIFLUSH);
+  return result;
+}
+
+int getCommandSexa(int fd, double *value, const char * cmd)
+{
+  char temp_string[16];
+  int result = MAGELLAN_ERROR;
+  int nbytes_write=0, nbytes_read=0;
+  
+  if ( (tty_write_string(fd, cmd, &nbytes_write)) == TTY_OK)
+  {
+    if ((tty_read_section(fd, temp_string, '#', MAGELLAN_TIMEOUT, &nbytes_read)) == TTY_OK)
+    {
+      temp_string[nbytes_read - 1] = '\0';
+
+      if (f_scansexa(temp_string, value))
+      {
+	#ifdef INDI_DEBUG
+	IDLog("unable to process [%s]\n", temp_string);
+	#endif
+      }
+      else
+      {
+	result = MAGELLAN_OK;
+      }
+    }
+  }
+  
+  tcflush(fd, TCIFLUSH);
+  return result;
+}
+
+static int getCommandString(int fd, char *data, const char* cmd)
+{
+    int nbytes_write=0, nbytes_read=0;
+    int result = MAGELLAN_ERROR;
+    
+   if ( (tty_write_string(fd, cmd, &nbytes_write)) == TTY_OK)
+   {
+      if ((tty_read_section(fd, data, '#', MAGELLAN_TIMEOUT, &nbytes_read)) == TTY_OK)
+      {
+	data[nbytes_read - 1] = '\0';
+	result = MAGELLAN_OK;
+      }
+   }
+
+   tcflush(fd, TCIFLUSH);
+   return result;
+}
+
+
+int getCalenderDate(int fd, char *date)
+{
+
+ int dd, mm, yy;
+ char century[3];
+ int result;
+
+ if ( (result = getCommandString(fd, date, "#:GC#")) )
+ {
+    /* Magellan format is MM/DD/YY */
+    if ((sscanf(date, "%d%*c%d%*c%d", &mm, &dd, &yy)) > 2)
+    {
+      /* Consider years 92 or more to be in the last century, anything less 
+	in the 21st century.*/
+      if (yy > CENTURY_THRESHOLD) strncpy(century, "19", 3);
+      else strncpy(century, "20", 3);
+
+      /* Format must be YYYY/MM/DD format */
+      snprintf(date, 16, "%s%02d/%02d/%02d", century, yy, mm, dd);
+    }
+ }
+
+ return result;
+}
+
+
Index: /BAORadio/libindi/libindi/drivers/telescope/magellandriver.h
===================================================================
--- /BAORadio/libindi/libindi/drivers/telescope/magellandriver.h	(revision 646)
+++ /BAORadio/libindi/libindi/drivers/telescope/magellandriver.h	(revision 646)
@@ -0,0 +1,68 @@
+/*
+    MAGELLAN Driver
+    Copyright (C) 2011 Onno Hommes  (ohommes@alumni.cmu.edu)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+    Boston, MA  02110-1301  USA
+    
+*/
+
+#ifndef MAGELLANDRIVER_H
+#define MAGELLANDRIVER_H
+
+/* Just use Default tracking for what ever telescope is feeding Magellan I */
+enum TFreq { MAGELLAN_TRACK_DEFAULT, MAGELLAN_TRACK_LUNAR, MAGELLAN_TRACK_MANUAL};
+
+/* Time Format */
+enum TTimeFormat { MAGELLAN_24, MAGELLAN_AM, MAGELLAN_PM};
+
+#define MAGELLAN_TIMEOUT	 5	/* FD timeout in seconds */
+#define MAGELLAN_ERROR		-1	/* Default Error Code */
+#define MAGELLAN_OK		 0	/* Default Success Code */
+#define MAGELLAN_ACK		'P'	/* Default Success Code */
+
+#define CENTURY_THRESHOLD	91      /* When to goto 21st Century */
+#define CONNECTION_RETRIES	 2	/* Retry Attempt cut-off */
+
+/* GET formatted sexagisemal value from device, return as double */
+#define getMAGELLANRA(fd, x)		getCommandSexa(fd, x, "#:GR#")
+#define getMAGELLANDEC(fd, x)		getCommandSexa(fd, x, "#:GD#")
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**************************************************************************
+ Diagnostics
+ **************************************************************************/
+char ACK(int fd);
+int check_magellan_connection(int fd);
+
+/**************************************************************************
+ Get Commands: store data in the supplied buffer. Return 0 on success or -1 
+ on failure 
+ **************************************************************************/
+ 
+/* Get Double from Sexagisemal */
+int getCommandSexa(int fd, double *value, const char *cmd);
+
+/* Get Calender data */
+int getCalenderDate(int fd, char *date);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /BAORadio/libindi/libindi/libs/indibase/indifilterinterface.cpp
===================================================================
--- /BAORadio/libindi/libindi/libs/indibase/indifilterinterface.cpp	(revision 646)
+++ /BAORadio/libindi/libindi/libs/indibase/indifilterinterface.cpp	(revision 646)
@@ -0,0 +1,55 @@
+/*
+    Filter Interface
+    Copyright (C) 2011 Jasem Mutlaq (mutlaqja@ikarustech.com)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+*/
+
+#include "indifilterinterface.h"
+
+INDI::FilterInterface::FilterInterface()
+{
+    FilterSlotNP = new INumberVectorProperty;
+    FilterNameTP = new ITextVectorProperty;
+    FilterNameT  = NULL;
+    MinFilter = MaxFilter = 0;
+}
+
+void INDI::FilterInterface::initFilterProperties(const char *deviceName, const char* groupName)
+{
+    IUFillNumber(&FilterSlotN[0],"FILTER_SLOT_VALUE","Filter","%3.0f",1.0,12.0,1.0,1.0);
+    IUFillNumberVector(FilterSlotNP,FilterSlotN,1,deviceName,"FILTER_SLOT","Filter",groupName,IP_RW,60,IPS_IDLE);
+}
+
+INDI::FilterInterface::~FilterInterface()
+{
+
+}
+
+void INDI::FilterInterface::SelectFilterDone(int f)
+{
+    //  The hardware has finished changing
+    //  filters
+    FilterSlotN[0].value=f;
+    FilterSlotNP->s=IPS_OK;
+    // Tell the clients we are done, and
+    //  filter is now useable
+    IDSetNumber(FilterSlotNP,NULL);
+}
+
+
+
+
Index: /BAORadio/libindi/libindi/libs/indibase/indifilterinterface.h
===================================================================
--- /BAORadio/libindi/libindi/libs/indibase/indifilterinterface.h	(revision 646)
+++ /BAORadio/libindi/libindi/libs/indibase/indifilterinterface.h	(revision 646)
@@ -0,0 +1,89 @@
+/*
+    Filter Interface
+    Copyright (C) 2011 Jasem Mutlaq (mutlaqja@ikarustech.com)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+*/
+
+#ifndef INDIFILTERINTERFACE_H
+#define INDIFILTERINTERFACE_H
+
+#include "indibase.h"
+
+/**
+ * \class INDI::FilterInterface
+   \brief Provides interface to implement Filter Wheel functionality.
+
+   A filter wheel can be an independent device, or an embedded filter wheel within another device (e.g. CCD camera). Child class must implement all the
+   pure virtual functions and call SelectFilterDone(int) when selection of a new filter position is complete in the hardware.
+
+   initFilterProperties() must be called before any other function to initilize the filter properties.
+\author Gerry Rozema, Jasem Mutlaq
+*/
+class INDI::FilterInterface
+{
+
+public:
+
+    /** \brief Return current filter position */
+    virtual int QueryFilter() = 0;
+
+    /** \brief Select a new filter position
+        \return True if operation is successful, false otherwise */
+    virtual bool SelectFilter(int position) = 0;
+
+    /** \brief Set filter names as defined by the client for each filter position.
+         Filter names should be saved in hardware if possible.
+         \return True if successful, false if supported or failed operation */
+    virtual bool SetFilterNames() = 0;
+
+    /** \brief Obtains a list of filter names from the hardware and initilizes the FilterNameTP property. The function should check for the number of filters
+      available in the filter wheel and build the FilterNameTP property accordingly.
+      \return True if successful, false if unsupported or failed operation
+      \see QSI CCD implementation of the FilterInterface. QSI CCD is available as a 3rd party INDI driver.
+    */
+    virtual bool GetFilterNames(const char *deviceName, const char* groupName) = 0;
+
+    /** \brief The child class calls this function when the hardware successfully finished selecting a new filter wheel position
+        \param newpos New position of the filter wheel
+    */
+    void SelectFilterDone(int newpos);
+
+
+protected:
+
+    FilterInterface();
+    ~FilterInterface();
+
+    /** \brief Initilize filter wheel properties. It is recommended to call this function within initProperties() of your primary device
+        \param deviceName Name of the primary device
+        \param groupName Group or tab name to be used to define filter wheel properties.
+    */
+    void initFilterProperties(const char *deviceName, const char* groupName);
+
+    INumberVectorProperty *FilterSlotNP;   //  A number vector for filter slot
+    INumber FilterSlotN[1];
+
+    ITextVectorProperty *FilterNameTP; //  A text vector that stores out physical port name
+    IText *FilterNameT;
+
+    int MinFilter;
+    int MaxFilter;
+    int CurrentFilter;
+    int TargetFilter;
+};
+
+#endif // INDIFILTERINTERFACE_H
Index: /BAORadio/libindi/libindi/libs/indibase/indiguiderinterface.cpp
===================================================================
--- /BAORadio/libindi/libindi/libs/indibase/indiguiderinterface.cpp	(revision 646)
+++ /BAORadio/libindi/libindi/libs/indibase/indiguiderinterface.cpp	(revision 646)
@@ -0,0 +1,46 @@
+/*
+    Guider Interface
+    Copyright (C) 2011 Jasem Mutlaq (mutlaqja@ikarustech.com)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+*/
+
+#include "indiguiderinterface.h"
+#include <indiapi.h>
+
+INDI::GuiderInterface::GuiderInterface()
+{
+    GuideNSP = new INumberVectorProperty;
+    GuideEWP = new INumberVectorProperty;
+}
+
+INDI::GuiderInterface::~GuiderInterface()
+{
+    delete GuideNSP;
+    delete GuideEWP;
+}
+
+void INDI::GuiderInterface::initGuiderProperties(const char *deviceName, const char* groupName)
+{
+
+    IUFillNumber(&GuideNS[0],"TIMED_GUIDE_N","North (sec)","%g",0,10,0.001,0);
+    IUFillNumber(&GuideNS[1],"TIMED_GUIDE_S","South (sec)","%g",0,10,0.001,0);
+    IUFillNumberVector(GuideNSP,GuideNS,2,deviceName,"TELESCOPE_TIMED_GUIDE_NS","Guide North/South",groupName,IP_RW,60,IPS_IDLE);
+
+    IUFillNumber(&GuideEW[0],"TIMED_GUIDE_E","East (sec)","%g",0,10,0.001,0);
+    IUFillNumber(&GuideEW[1],"TIMED_GUIDE_W","West (sec)","%g",0,10,0.001,0);
+    IUFillNumberVector(GuideEWP,GuideEW,2,deviceName,"TELESCOPE_TIMED_GUIDE_WE","Guide East/West",groupName,IP_RW,60,IPS_IDLE);
+}
Index: /BAORadio/libindi/libindi/libs/indibase/indiguiderinterface.h
===================================================================
--- /BAORadio/libindi/libindi/libs/indibase/indiguiderinterface.h	(revision 646)
+++ /BAORadio/libindi/libindi/libs/indibase/indiguiderinterface.h	(revision 646)
@@ -0,0 +1,75 @@
+/*
+    Guider Interface
+    Copyright (C) 2011 Jasem Mutlaq (mutlaqja@ikarustech.com)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+*/
+
+#ifndef GUIDERINTERFACE_H
+#define GUIDERINTERFACE_H
+
+#include "indibase.h"
+
+/**
+ * \class INDI::GuiderInterface
+   \brief Provides interface to implement guider (ST4) port functionality.
+
+   initFilterProperties() must be called before any other function to initilize the guider properties.
+\author Jasem Mutlaq
+*/
+class INDI::GuiderInterface
+{
+
+public:
+
+    /** \brief Guide north for ms milliseconds
+        \return True if OK, false otherwise
+    */
+    virtual bool GuideNorth(float ms) = 0;
+
+    /** \brief Guide south for ms milliseconds
+        \return True if OK, false otherwise
+    */
+    virtual bool GuideSouth(float ms) = 0;
+
+    /** \brief Guide east for ms milliseconds
+        \return True if OK, false otherwise
+    */
+    virtual bool GuideEast(float ms) = 0;
+
+    /** \brief Guide west for ms milliseconds
+        \return True if OK, false otherwise
+    */
+    virtual bool GuideWest(float ms) = 0;
+
+protected:
+
+    GuiderInterface();
+    ~GuiderInterface();
+
+    /** \brief Initilize guider properties. It is recommended to call this function within initProperties() of your primary device
+        \param deviceName Name of the primary device
+        \param groupName Group or tab name to be used to define guider properties.
+    */
+    void initGuiderProperties(const char *deviceName, const char* groupName);
+
+    INumber GuideNS[2];
+    INumberVectorProperty *GuideNSP;
+    INumber GuideEW[2];
+    INumberVectorProperty *GuideEWP;
+};
+
+#endif // GUIDERINTERFACE_H
