23 #include <libnova/sidereal_time.h>
24 #include <libnova/transform.h>
51 return "Mount Driver";
147 char cmd[DRIVER_LEN] = {0}, res[DRIVER_LEN] = {0};
156 return res[0] ==
'S';
166 char cmd[DRIVER_LEN] = {0}, res[DRIVER_LEN] = {0};
172 sscanf(res,
"%lf:%lf", &
currentRA, ¤tDE);
174 char RAStr[DRIVER_LEN] = {0}, DecStr[DRIVER_LEN] = {0};
176 fs_sexa(DecStr, currentDE, 2, 3600);
177 LOGF_DEBUG(
"Current RA: %s Current DEC: %s", RAStr, DecStr);
188 memset(res, 0, DRIVER_LEN);
199 char cmd[DRIVER_LEN] = {0}, res[DRIVER_LEN] = {0};
202 snprintf(
cmd, DRIVER_LEN,
"sendCoords %g:%g", RA, DE);
212 char RAStr[DRIVER_LEN] = {0}, DecStr[DRIVER_LEN] = {0};
215 LOGF_INFO(
"Slewing to RA: %s - DEC: %s", RAStr, DecStr);
221 char cmd[DRIVER_LEN] = {0}, res[DRIVER_LEN] = {0};
224 snprintf(
cmd, DRIVER_LEN,
"syncCoords %g:%g", RA, DE);
241 LOG_INFO(
"Parking telescope in progress...");
256 if (strcmp(name,
"GUIDE_RATE") == 0)
289 LOG_ERROR(
"Please unpark the mount before issuing any motion commands.");
303 LOG_ERROR(
"Please unpark the mount before issuing any motion commands.");
339 m_GeographicLocation.lng = longitude;
341 if (m_GeographicLocation.lng > 180)
342 m_GeographicLocation.lng -= 360;
343 m_GeographicLocation.lat = latitude;
348 LOGF_INFO(
"Location updated: Longitude (%g) Latitude (%g)", m_GeographicLocation.lng, m_GeographicLocation.lat);
416 int nbytes_written = 0, nbytes_read = 0, rc = -1;
418 tcflush(
PortFD, TCIOFLUSH);
422 char hex_cmd[DRIVER_LEN * 3] = {0};
437 LOGF_ERROR(
"Serial write error: %s.", errstr);
445 rc =
tty_read(
PortFD, res, res_len, DRIVER_TIMEOUT, &nbytes_read);
459 char hex_res[DRIVER_LEN * 3] = {0};
460 hexDump(hex_res, res, res_len);
468 tcflush(
PortFD, TCIOFLUSH);
475 for (
int i = 0; i < size; i++)
476 sprintf(buf + 3 * i,
"%02X ",
static_cast<uint8_t
>(data[i]));
479 buf[3 * size - 1] =
'\0';
const char * getDeviceName() const
void setDefaultPollingPeriod(uint32_t msec)
setDefaultPollingPeriod Change the default polling period to call TimerHit() function in the driver.
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
void setDriverInterface(uint16_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
uint16_t getDriverInterface() const
void addDebugControl()
Add Debug control to the driver.
INumberVectorProperty GuideNSNP
void initGuiderProperties(const char *deviceName, const char *groupName)
Initilize guider properties. It is recommended to call this function within initProperties() of your ...
INumberVectorProperty GuideWENP
void processGuiderProperties(const char *name, double values[], char *names[], int n)
Call this function whenever client updates GuideNSNP or GuideWSP properties in the primary device....
TelescopeStatus TrackState
void SetAxis1Park(double value)
SetRAPark Set current RA/AZ parking position. The data park file (stored in ~/.indi/ParkData....
void SetAxis1ParkDefault(double steps)
SetRAPark Set default RA/AZ parking position.
void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount)
SetTelescopeCapability sets the Telescope capabilities. All capabilities must be initialized.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual int AddTrackMode(const char *name, const char *label, bool isDefault=false)
AddTrackMode.
ISwitchVectorProperty SlewRateSP
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
@ TELESCOPE_HAS_TRACK_RATE
@ TELESCOPE_HAS_PIER_SIDE
@ TELESCOPE_HAS_TRACK_MODE
@ TELESCOPE_CAN_CONTROL_TRACK
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
void NewRaDec(double ra, double dec)
The child class calls this function when it has updates.
void setPierSide(TelescopePierSide side)
bool InitPark()
InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status and parking...
void SetAxis2Park(double steps)
SetDEPark Set current DEC/ALT parking position. The data park file (stored in ~/.indi/ParkData....
void SetParkDataType(TelescopeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
void SetAxis2ParkDefault(double steps)
SetDEParkDefault Set default DEC/ALT parking position.
The MountDriver class provides a simple example for development of a new mount driver....
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
virtual const char * getDefaultName() override
virtual bool Park() override
Parking commands.
bool sendCommand(const char *cmd, char *res=nullptr, int cmd_len=-1, int res_len=-1)
Utility Functions.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool Abort() override
Abort Abort all motion. If tracking, stop it.
virtual bool SetTrackMode(uint8_t mode) override
Tracking Commands.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool Handshake() override
Communication Commands.
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
void hexDump(char *buf, const char *data, int size)
hexDump Helper function to print non-string commands to the logger so it is easier to debug
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
MoveWE Start or Stop motion in the East/West RA Axis.
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
virtual bool Sync(double RA, double DE) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate Set custom tracking rates.
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Motions commands.
virtual IPState GuideNorth(uint32_t ms) override
Pulse Guiding Commands.
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Time, Date & Location commands.
virtual bool Goto(double RA, double DE) override
GOTO & Sync commands.
virtual bool ReadScopeStatus() override
ReadScopeStatus Query the mount status, coordinate, any status indicators, pier side....
const char * MOTION_TAB
MOTION_TAB Where all the motion control properties of the device are located.
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
int fs_sexa(char *out, double a, int w, int fracbase)
Converts a sexagesimal number to a string. sprint the variable a in sexagesimal format into out[].
int tty_nread_section(int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
Implementations for common driver routines.
double get_local_sidereal_time(double longitude)
get_local_sidereal_time Returns local sideral time given longitude and system clock.
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s)
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
void IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max, double step, double value)
Assign attributes for a number property. The number's auxiliary elements will be set to NULL.
void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name, const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s)
Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
#define LOGF_INFO(fmt,...)
#define LOGF_DEBUG(fmt,...)
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
#define LOGF_ERROR(fmt,...)
std::unique_ptr< ScopeSim > telescope_sim(new ScopeSim())