29 #include <libnova/transform.h>
67 int mountType = Equatorial;
70 MountTypeSP[Equatorial].
fill(
"Equatorial",
"Equatorial", mountType == Equatorial ?
ISS_ON :
ISS_OFF);
73 if (mountType == Equatorial)
92 verboseReport =
false;
97 Report[0].
fill(
"Report",
"GU",
"-");
100 IsTracking[0].
fill(
"IsTracking",
"n",
"-");
103 IsSlewCompleted[0].
fill(
"IsSlewCompleted",
"N",
"-");
106 IsParked[0].
fill(
"IsParked",
"p/P",
"-");
109 IsParkginInProgress[0].
fill(
"IsParkginInProgress",
"I",
"-");
112 IsAtHomePosition[0].
fill(
"IsAtHomePosition",
"H",
"-");
115 TrackSidereal[0].
fill(
"TrackSidereal",
"",
"-");
118 TrackLunar[0].
fill(
"TrackLunar",
"(",
"-");
121 TrackSolar[0].
fill(
"TrackSolar",
"O",
"-");
124 MountAltAz[0].
fill(
"MountAltAz",
"A",
"-");
127 MountEquatorial[0].
fill(
"MountEquatorial",
"E",
"-");
130 PierNone[0].
fill(
"PierNone",
"",
"-");
133 PierEast[0].
fill(
"PierEast",
"T",
"-");
136 PierWest[0].
fill(
"PierWest",
"W",
"-");
139 DoesRefractionComp[0].
fill(
"DoesRefractionComp",
"r",
"-");
142 WaitingAtHome[0].
fill(
"WaitingAtHome",
"w",
"-");
145 IsHomePaused[0].
fill(
"IsHomePaused",
"u",
"-");
148 ParkFailed[0].
fill(
"ParkFailed",
"F",
"-");
151 SlewingHome[0].
fill(
"SlewingHome",
"h",
"-");
180 char status[DRIVER_LEN] = {0};
181 if (sendCommand(
":GU#", status))
183 if(strchr(status,
'P'))
195 if(sendCommand(
":GX90#", status))
197 std::string c = status;
267 return "Pegasus NYX-101";
270 const char *
ON =
"ON";
280 propertyTxt[0].setText(
ON);
284 propertyTxt[0].setText(
OFF);
288 propertyTxt[0].setText(
"-");
299 bool _IsTracking =
true;
300 SetPropertyText(IsTracking,
IPS_OK);
302 bool _IsSlewCompleted =
false;
303 SetPropertyText(IsSlewCompleted,
IPS_BUSY);
305 bool _IsParked =
false;
306 SetPropertyText(IsParked,
IPS_BUSY);
309 SetPropertyText(IsParkginInProgress,
IPS_BUSY);
312 SetPropertyText(IsAtHomePosition,
IPS_BUSY);
321 SetPropertyText(DoesRefractionComp,
IPS_BUSY);
324 SetPropertyText(WaitingAtHome,
IPS_BUSY);
327 SetPropertyText(IsHomePaused,
IPS_BUSY);
330 SetPropertyText(ParkFailed,
IPS_BUSY);
333 SetPropertyText(SlewingHome,
IPS_BUSY);
338 char status[DRIVER_LEN] = {0};
339 if(sendCommand(
":GU#", status))
341 Report[0].text = status;
346 switch (status[index++])
350 SetPropertyText(IsTracking,
IPS_BUSY);
353 _IsSlewCompleted =
true;
354 SetPropertyText(IsSlewCompleted,
IPS_OK);
358 SetPropertyText(IsParked,
IPS_BUSY);
362 SetPropertyText(IsParked,
IPS_OK);
366 SetPropertyText(IsParkginInProgress,
IPS_OK);
370 SetPropertyText(IsAtHomePosition,
IPS_OK);
383 SetPropertyText(MountAltAz,
IPS_OK);
384 SetPropertyText(MountEquatorial,
IPS_BUSY);
388 SetPropertyText(MountEquatorial,
IPS_OK);
389 SetPropertyText(MountAltAz,
IPS_BUSY);
399 SetPropertyText(DoesRefractionComp,
IPS_OK);
403 SetPropertyText(WaitingAtHome,
IPS_OK);
407 SetPropertyText(IsHomePaused,
IPS_OK);
411 SetPropertyText(ParkFailed,
IPS_OK);
415 SetPropertyText(SlewingHome,
IPS_OK);
426 switch(_TrackingMode)
429 SetPropertyText(TrackSidereal,
IPS_OK);
430 SetPropertyText(TrackLunar,
IPS_BUSY);
431 SetPropertyText(TrackSolar,
IPS_BUSY);
434 SetPropertyText(TrackLunar,
IPS_OK);
435 SetPropertyText(TrackSidereal,
IPS_BUSY);
436 SetPropertyText(TrackSolar,
IPS_BUSY);
439 SetPropertyText(TrackSolar,
IPS_OK);
440 SetPropertyText(TrackSidereal,
IPS_BUSY);
441 SetPropertyText(TrackLunar,
IPS_BUSY);
450 SetPropertyText(PierNone,
IPS_OK);
451 SetPropertyText(PierEast,
IPS_BUSY);
452 SetPropertyText(PierWest,
IPS_BUSY);
455 SetPropertyText(PierEast,
IPS_OK);
456 SetPropertyText(PierNone,
IPS_BUSY);
457 SetPropertyText(PierWest,
IPS_BUSY);
460 SetPropertyText(PierWest,
IPS_OK);
461 SetPropertyText(PierEast,
IPS_BUSY);
462 SetPropertyText(PierNone,
IPS_BUSY);
469 if (_IsSlewCompleted)
472 LOG_INFO(
"Slew is complete. Tracking...");
482 if (wasTracking != _IsTracking)
496 char response[DRIVER_LEN] = {0};
497 if (sendCommand(
":Gm#", response))
499 if (response[0] ==
'W')
501 else if (response[0] ==
'E')
526 MountTypeSP.
update(states, names, n);
532 if (state ==
IPS_OK && previousType != targetType)
533 LOG_WARN(
"Restart mount in order to apply changes to Mount Type.");
542 GuideRateSP.
update(states, names, n);
548 if (state ==
IPS_OK && previousType != targetType)
549 LOG_WARN(
"RA and DEC guide rate changed.");
557 HomeSP.
update(states, names, n);
570 ResetHomeSP.
update(states, names, n);
583 VerboseReportSP.
update(states, names, n);
588 verboseReport =
true;
592 SetPropertyText(IsTracking,
IPS_IDLE);
593 SetPropertyText(IsSlewCompleted,
IPS_IDLE);
594 SetPropertyText(IsParked,
IPS_IDLE);
595 SetPropertyText(IsParkginInProgress,
IPS_IDLE);
596 SetPropertyText(IsAtHomePosition,
IPS_IDLE);
597 SetPropertyText(TrackSidereal,
IPS_IDLE);
598 SetPropertyText(TrackLunar,
IPS_IDLE);
599 SetPropertyText(TrackSolar,
IPS_IDLE);
600 SetPropertyText(MountAltAz,
IPS_IDLE);
601 SetPropertyText(MountEquatorial,
IPS_IDLE);
602 SetPropertyText(PierNone,
IPS_IDLE);
603 SetPropertyText(PierEast,
IPS_IDLE);
604 SetPropertyText(PierWest,
IPS_IDLE);
605 SetPropertyText(DoesRefractionComp,
IPS_IDLE);
606 SetPropertyText(WaitingAtHome,
IPS_IDLE);
607 SetPropertyText(IsHomePaused,
IPS_IDLE);
608 SetPropertyText(ParkFailed,
IPS_IDLE);
609 SetPropertyText(SlewingHome,
IPS_IDLE);
610 verboseReport =
false;
615 VerboseReportSP.
apply();
659 char decCommand[DRIVER_LEN] = {0};
660 snprintf(decCommand, DRIVER_LEN,
":RE%f#", value);
662 char raCommand[DRIVER_LEN] = {0};
663 snprintf(raCommand, DRIVER_LEN,
":RA%f#", value);
665 return sendCommand(decCommand) && sendCommand(raCommand);
668 bool LX200NYX101::setGuideRate(
int rate)
670 char command[DRIVER_LEN] = {0};
671 snprintf(command, DRIVER_LEN,
":R%d#", rate);
672 return sendCommand(command);
675 bool LX200NYX101::setMountType(
int type)
677 return sendCommand((
type == Equatorial) ?
":SXEM,1#" :
"::SXEM,3#");
680 bool LX200NYX101::goToPark()
683 return sendCommand(
":hP#");
686 bool LX200NYX101::goToUnPark()
688 return sendCommand(
":hR#");
693 bool rc = goToPark();
702 bool rc = goToUnPark();
711 char response[DRIVER_LEN] = {0};
712 bool rc = sendCommand(enabled ?
":Te#" :
":Td#", response, 4, 1);
713 return rc && response[0] ==
'1';
718 int h {0}, m {0}, s {0};
719 char command[DRIVER_LEN] = {0};
723 snprintf(command, DRIVER_LEN,
":SG%c%02d:%02d#", offset >= 0 ?
'+' :
'-', std::abs(h), m);
729 char command[DRIVER_LEN] = {0};
730 snprintf(command, DRIVER_LEN,
":SC%02d/%02d/%02d#", months, days, years % 100);
737 int d{0}, m{0}, s{0};
742 longitude = longitude - 360;
744 char command[DRIVER_LEN] = {0};
748 snprintf(command, DRIVER_LEN,
":Sg%c%03d*%02d:%02d#", longitude >= 0 ?
'+' :
'-', std::abs(d), m, s);
751 LOG_ERROR(
"Error setting site longitude coordinates");
756 snprintf(command, DRIVER_LEN,
":St%c%02d*%02d:%02d#", latitude >= 0 ?
'+' :
'-', std::abs(d), m, s);
759 LOG_ERROR(
"Error setting site latitude coordinates");
767 bool LX200NYX101::sendCommand(
const char *
cmd,
char * res,
int cmd_len,
int res_len)
769 int nbytes_written = 0, nbytes_read = 0, rc = -1;
771 tcflush(
PortFD, TCIOFLUSH);
775 char hex_cmd[DRIVER_LEN * 3] = {0};
776 hexDump(hex_cmd,
cmd, cmd_len);
790 LOGF_ERROR(
"Serial write error: %s.", errstr);
801 rc =
tty_read(
PortFD, res, res_len, DRIVER_TIMEOUT, &nbytes_read);
815 char hex_res[DRIVER_LEN * 3] = {0};
816 hexDump(hex_res, res, res_len);
824 tcflush(
PortFD, TCIOFLUSH);
829 void LX200NYX101::hexDump(
char * buf,
const char * data,
int size)
831 for (
int i = 0; i < size; i++)
832 sprintf(buf + 3 * i,
"%02X ",
static_cast<uint8_t
>(data[i]));
835 buf[3 * size - 1] =
'\0';
838 std::vector<std::string> LX200NYX101::split(
const std::string &input,
const std::string ®ex)
841 std::regex re(regex);
842 std::sregex_token_iterator
843 first{input.begin(), input.end(), re, -1},
845 return {first, last};
void setDefaultBaudRate(BaudRate newRate)
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by t...
const char * getDeviceName() const
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 setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
bool isNameMatch(const char *otherName) const
bool update(const ISState states[], const char *const names[], int n)
int findOnSwitchIndex() const
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, double timeout, IPState state)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
TelescopeStatus TrackState
void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount)
SetTelescopeCapability sets the Telescope capabilities. All capabilities must be initialized.
ISwitchVectorProperty SlewRateSP
Connection::Serial * serialConnection
virtual void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
INumberVectorProperty EqNP
@ TELESCOPE_HAS_PIER_SIDE
@ TELESCOPE_HAS_TRACK_MODE
@ TELESCOPE_CAN_CONTROL_TRACK
uint32_t GetTelescopeCapability() const
GetTelescopeCapability returns the capability of the Telescope.
void NewRaDec(double ra, double dec)
The child class calls this function when it has updates.
void setPierSide(TelescopePierSide side)
void SetParkDataType(TelescopeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool setUTCOffset(double offset) override
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years) override
virtual bool SetSlewRate(int index) override
SetSlewRate Set desired slew rate index.
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool Park() override
Park the telescope to its home position.
virtual const char * getDefaultName() override
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool ReadScopeStatus() override
Read telescope status.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
@ LX200_HAS_PULSE_GUIDING
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
void setLX200Capability(uint32_t cap)
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
void getSexComponents(double value, int *d, int *m, int *s)
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
Implementations for common driver routines.
void IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
int IUGetConfigOnSwitchIndex(const char *dev, const char *property, int *index)
IUGetConfigOnSwitchIndex Opens configuration file and reads single switch property to find ON switch ...
#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 * SETTINGS_TAB
int setStandardProcedure(int fd, const char *data)
#define getLX200DEC(fd, x)
#define getLX200RA(fd, x)