26 #include <libnova/julian_day.h>
60 LOGF_ERROR(
"Main board firmware is %s while minimum required firmware is %s. Please upgrade the mount firmware.",
79 std::string code = res;
82 return oneMount.code == code;
91 LOGF_ERROR(
"Mount with code %s is not recognized.", res);
104 char board[8] = {0}, controller[8] = {0};
106 strncpy(board, res, 6);
107 strncpy(controller, res + 6, 6);
124 char ra[8] = {0}, de[8] = {0};
127 strncpy(de, res + 6, 6);
214 snprintf(
cmd,
DRIVER_LEN,
":SR%d#", (
static_cast<int>(rate) + 1));
226 strcpy(
cmd,
":RT0#");
229 strcpy(
cmd,
":RT1#");
232 strcpy(
cmd,
":RT2#");
235 strcpy(
cmd,
":RT3#");
238 strcpy(
cmd,
":RT4#");
257 snprintf(
cmd,
DRIVER_LEN,
":RR%05d#",
static_cast<int>(rate * 1e5));
274 snprintf(
cmd,
DRIVER_LEN,
":RG%02d%02d#",
static_cast<int>(raRate * 100.0),
static_cast<int>(deRate * 100.0));
335 return res[0] ==
'1';
362 return res[0] ==
'1';
377 return sendCommand(enabled ?
":ST1#" :
":ST0#", res, -1, 1);
386 int ieqValue =
static_cast<int>(
ra * 60 * 60 * 1000);
399 int ieqValue =
static_cast<int>(fabs(
dec) * 60 * 60 * 100);
412 int ieqValue =
static_cast<int>(az * 60 * 60 * 100);
425 int ieqValue =
static_cast<int>(alt * 60 * 60 * 100);
427 snprintf(
cmd,
DRIVER_LEN,
":Sa%c%08d#", (alt >= 0) ?
'+' :
'-', ieqValue);
441 int ieqValue =
static_cast<int>(az * 60 * 60 * 100);
459 int ieqValue =
static_cast<int>(alt * 60 * 60 * 100);
471 int arcsecs =
static_cast<int>(fabs(longitude) * 60 * 60);
472 snprintf(
cmd,
DRIVER_LEN,
":Sg%c%06d#", (longitude >= 0) ?
'+' :
'-', arcsecs);
482 int arcsecs =
static_cast<int>(fabs(latitude) * 60 * 60);
483 snprintf(
cmd,
DRIVER_LEN,
":St%c%06d#", (latitude >= 0) ?
'+' :
'-', arcsecs);
511 return sendCommand(enabled ?
":SDS1#" :
":SDS0#", res, -1, 1);
519 int offset_minutes =
static_cast<int>(fabs(offset_hours) * 60.0);
520 snprintf(
cmd, 16,
":SG%c%03d#", (offset_hours >= 0) ?
'+' :
'-', offset_minutes);
553 ln_zonedate localTime;
556 localTime.years = *yy;
557 localTime.months = *mm;
558 localTime.days = *dd;
559 localTime.hours = *hh;
560 localTime.minutes = *minute;
561 localTime.seconds = *ss;
562 localTime.gmtoff =
static_cast<long>(*utc_hours * 3600);
564 ln_zonedate_to_date(&localTime, &utcTime);
567 *mm = utcTime.months;
570 *minute = utcTime.minutes;
571 *ss =
static_cast<int>(utcTime.seconds);
586 char longitude[8] = {0}, latitude[8] = {0}, status[8] = {0};
588 strncpy(longitude, res, 7);
589 strncpy(latitude, res + 7, 6);
590 strncpy(status, res + 13, 6);
647 axisHa = 18 - haAxis;
668 double decPA = info.
latitude >= 0 ? 90 - Dec : 90 +
671 if ((ha > 2 && ha < 10) || (ha < -2 && ha > -10))
675 reason =
"Hour Angle";
679 double decDiff = std::fabs(decPA - std::fabs(decAxis));
684 reason =
"pole angle";
689 reason =
"uncertain";
693 LOGF_DEBUG(
"getPierSide pole Axis %f, haAxis %f, axisHa %f, ha %f, decPa %f, %s pierSide %s", decAxis, haAxis, axisHa, ha,
705 int nbytes_written = 0, nbytes_read = 0, rc = -1;
726 LOGF_ERROR(
"Serial write error: %s.", errstr);
749 hexDump(hex_res, res, res_len);
764 for (
int i = 0; i < size; i++)
765 sprintf(buf + 3 * i,
"%02X ",
static_cast<uint8_t
>(data[i]));
768 buf[3 * size - 1] =
'\0';
774 if (command ==
"MSH")
781 LOG_ERROR(
"Finding home is only supported on CEM40, GEM45 and CEM60 mounts.");
786 else if (command ==
"RR")
791 LOG_ERROR(
"Tracking rate is not supported on Altitude-Azimuth mounts.");
795 else if (command ==
"RG" || command ==
"AG")
800 LOG_ERROR(
"Guide rate is not supported on Altitude-Azimuth mounts.");
804 if (command ==
"MP0" || command ==
"MP1" || command ==
"SPA" || command ==
"SPH")
812 LOG_ERROR(
"Parking only supported on CEM40, GEM45, CEM60, iEQPro 30 and iEQ Pro 45.");
828 strncpy(str, data, size);
830 int iVal = atoi(str);
static const uint8_t DRIVER_LEN
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 setCurrentHome()
virtual bool setRA(double ra)
virtual bool setSlewRate(SlewRate rate)
bool getStatus(Info *info)
FirmwareInfo m_FirmwareInfo
virtual bool setTrackEnabled(bool enabled)
bool initCommunication(int fd)
initCommunication Checks if communication with the mount is working
virtual bool setLocalDate(int yy, int mm, int dd)
constexpr static const double ieqHours
bool isCommandSupported(const std::string &command, bool silent=false)
isCommandSupported Check if specific iOptron command is supported for this mount model
virtual bool setAlt(double alt)
bool getCoords(double *ra, double *dec)
bool getPierSide(IEQ_PIER_SIDE *pierSide)
double DecodeString(const char *data, size_t size, double factor)
DecodeString converts the string to a double by dividing by the factor.
virtual bool setParkAlt(double alt)
virtual bool setLatitude(double latitude)
virtual bool setParkAz(double az)
constexpr static const double ieqDegrees
virtual bool getGuideRate(double *raRate, double *deRate)
virtual bool setAz(double az)
virtual bool setDE(double dec)
virtual bool setUTCOffset(double offset_hours)
virtual bool stopMotion(Direction dir)
virtual bool setGuideRate(double raRate, double deRate)
static const char DRIVER_STOP_CHAR
const std::vector< MountInfo > m_MountList
bool sendCommand(const char *cmd, char *res=nullptr, int cmd_len=-1, int res_len=-1)
sendCommand Send a string command to device.
virtual bool setDST(bool enabled)
bool getUTCDateTime(double *utc_hours, int *yy, int *mm, int *dd, int *hh, int *minute, int *ss)
virtual bool setLongitude(double longitude)
virtual bool setCustomRATrackRate(double rate)
static const uint8_t DRIVER_TIMEOUT
virtual bool startGuide(Direction dir, uint32_t ms)
virtual bool startMotion(Direction dir)
virtual bool setLocalTime(int hh, int mm, int ss)
virtual bool setTrackMode(TrackRate rate)
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
double rangeHA(double r)
rangeHA Limits the hour angle value to be between -12 —> 12
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 tty_nread_section(int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
double get_local_hour_angle(double sideral_time, double ra)
get_local_hour_angle Returns local hour angle of an object
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.
#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,...)
const char * pierSideStr(IEQ_PIER_SIDE ps)
std::string MainBoardFirmware
std::string ControllerFirmware
SystemStatus systemStatus