37#define FOCUS_SETTINGS_TAB "Settings"
38#define TEMPERATURE_THRESHOLD 0.1
58 IUFillNumber(&TemperatureN[0],
"TEMPERATURE",
"Celsius",
"%6.2f", -50, 70., 0., 0.);
63 IUFillNumber(&MaxSpeedN[0],
"Value",
"",
"%6.2f", 100, 1000., 100., 400.);
69 IUFillText(&FirmwareVersionT[0],
"Version",
"Version",
"");
124 "Error retrieving data from %s, please ensure device is powered and the port is correct.", this->
getDeviceName());
130 return "Pegasus ProdigyMF";
133bool PegasusProdigyMF::ack()
135 int nbytes_written = 0, nbytes_read = 0, rc = -1;
145 tcflush(
PortFD, TCIOFLUSH);
162 res[nbytes_read - 1] = 0;
165 if( res[nbytes_read - 2] ==
'\r') res[nbytes_read - 2] = 0;
169 tcflush(
PortFD, TCIOFLUSH);
171 if(strstr(res,
"OK_PRDG") !=
nullptr)
180 int nbytes_written = 0, rc = -1;
183 snprintf(
cmd, 16,
"W:%ud", ticks);
197 this->ignoreResponse();
202bool PegasusProdigyMF::move(uint32_t newPosition)
204 int nbytes_written = 0, rc = -1;
207 snprintf(
cmd, 16,
"M:%ud", newPosition);
221 this->ignoreResponse();
231 if (strcmp(name, MaxSpeedNP.
name) == 0)
234 bool rc = setMaxSpeed(MaxSpeedN[0].value);
245void PegasusProdigyMF::ignoreResponse()
252bool PegasusProdigyMF::updateFocusParams()
254 int nbytes_written = 0, nbytes_read = 0, rc = -1;
263 tcflush(
PortFD, TCIOFLUSH);
268 LOGF_ERROR(
"GetFocusParams error: %s.", errstr);
276 LOGF_ERROR(
"GetFocusParams error: %s.", errstr);
280 res[nbytes_read - 1] = 0;
283 if( res[nbytes_read - 2] ==
'\r') res[nbytes_read - 2] = 0;
287 tcflush(
PortFD, TCIOFLUSH);
289 char *token = std::strtok(res,
":");
292 if (token ==
nullptr || (strstr(token,
"OK_PRDG") ==
nullptr))
294 LOGF_ERROR(
"Invalid status response. %s", res);
299 token = std::strtok(
nullptr,
":");
301 if (token ==
nullptr)
307 if (FirmwareVersionT[0].text ==
nullptr || strcmp(FirmwareVersionT[0].text, token))
315 token = std::strtok(
nullptr,
":");
318 token = std::strtok(
nullptr,
":");
320 if (token ==
nullptr)
322 LOG_ERROR(
"Invalid temperature response.");
343 token = std::strtok(
nullptr,
":");
345 if (token ==
nullptr)
351 currentPosition = atoi(token);
359 token = std::strtok(
nullptr,
":");
361 if (token ==
nullptr)
363 LOG_ERROR(
"Invalid moving status response.");
367 isMoving = (token[0] ==
'1');
370 token = std::strtok(
nullptr,
":");
375 token = std::strtok(
nullptr,
":");
377 if (token ==
nullptr)
383 int reverseStatus = atoi(token);
384 if (reverseStatus >= 0 && reverseStatus <= 1)
394 token = std::strtok(
nullptr,
":");
398 token = std::strtok(
nullptr,
":");
404bool PegasusProdigyMF::setMaxSpeed(uint16_t speed)
406 int nbytes_written = 0, rc = -1;
409 snprintf(
cmd, 16,
"S:%d", speed);
414 tcflush(
PortFD, TCIOFLUSH);
425 this->ignoreResponse();
431 int nbytes_written = 0, rc = -1;
434 snprintf(
cmd, 16,
"N:%d", enabled ? 1 : 0);
439 tcflush(
PortFD, TCIOFLUSH);
450 this->ignoreResponse();
458 targetPosition = targetTicks;
460 bool rc = move(targetPosition);
472 double newPosition = 0;
480 rc = move(newPosition);
499 bool rc = updateFocusParams();
505 if (isMoving ==
false)
511 LOG_INFO(
"Focuser reached requested position.");
522 char cmd[2] = {
'H', 0xA };
530 this->ignoreResponse();
void setDefaultBaudRate(BaudRate newRate)
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by t...
void setDefaultPollingPeriod(uint32_t msec)
setDefaultPollingPeriod Change the default polling period to call TimerHit() function in the driver.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
void addDebugControl()
Add Debug control to the driver.
INDI::PropertyNumber FocusRelPosNP
INDI::PropertySwitch FocusReverseSP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
INDI::PropertyNumber FocusMaxPosNP
INDI::PropertyNumber FocusAbsPosNP
virtual bool saveConfigItems(FILE *fp) override
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
Connection::Serial * serialConnection
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
const char * getDefaultName() override
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
virtual bool saveConfigItems(FILE *fp) override
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
#define TEMPERATURE_THRESHOLD
#define FOCUS_SETTINGS_TAB
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
Implementations for common driver routines.
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 IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
void IUSaveText(IText *tp, const char *newtext)
Function to reliably save new text in a IText.
void IUSaveConfigNumber(FILE *fp, const INumberVectorProperty *nvp)
Add a number vector property value to the configuration file.
void IUFillText(IText *tp, const char *name, const char *label, const char *initialText)
Assign attributes for a text property. The text'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 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.
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)
#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,...)