36 #define DMFC_TIMEOUT 3
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";
133 bool 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();
202 bool PegasusProdigyMF::move(uint32_t newPosition)
204 int nbytes_written = 0, rc = -1;
207 snprintf(
cmd, 16,
"M:%ud", newPosition);
221 this->ignoreResponse();
240 if (strcmp(name, MaxSpeedNP.
name) == 0)
243 bool rc = setMaxSpeed(MaxSpeedN[0].value);
254 void PegasusProdigyMF::ignoreResponse()
261 bool PegasusProdigyMF::updateFocusParams()
263 int nbytes_written = 0, nbytes_read = 0, rc = -1;
272 tcflush(
PortFD, TCIOFLUSH);
277 LOGF_ERROR(
"GetFocusParams error: %s.", errstr);
285 LOGF_ERROR(
"GetFocusParams error: %s.", errstr);
289 res[nbytes_read - 1] = 0;
292 if( res[nbytes_read - 2] ==
'\r') res[nbytes_read - 2] = 0;
296 tcflush(
PortFD, TCIOFLUSH);
298 char *token = std::strtok(res,
":");
301 if (token ==
nullptr || (strstr(token,
"OK_PRDG") ==
nullptr))
303 LOGF_ERROR(
"Invalid status response. %s", res);
308 token = std::strtok(
nullptr,
":");
310 if (token ==
nullptr)
316 if (FirmwareVersionT[0].text ==
nullptr || strcmp(FirmwareVersionT[0].text, token))
324 token = std::strtok(
nullptr,
":");
327 token = std::strtok(
nullptr,
":");
329 if (token ==
nullptr)
331 LOG_ERROR(
"Invalid temperature response.");
335 double temperature = atof(token);
336 if (temperature == -127)
345 TemperatureN[0].value = temperature;
352 token = std::strtok(
nullptr,
":");
354 if (token ==
nullptr)
360 currentPosition = atoi(token);
368 token = std::strtok(
nullptr,
":");
370 if (token ==
nullptr)
372 LOG_ERROR(
"Invalid moving status response.");
376 isMoving = (token[0] ==
'1');
379 token = std::strtok(
nullptr,
":");
384 token = std::strtok(
nullptr,
":");
386 if (token ==
nullptr)
392 int reverseStatus = atoi(token);
393 if (reverseStatus >= 0 && reverseStatus <= 1)
403 token = std::strtok(
nullptr,
":");
407 token = std::strtok(
nullptr,
":");
413 bool PegasusProdigyMF::setMaxSpeed(uint16_t speed)
415 int nbytes_written = 0, rc = -1;
418 snprintf(
cmd, 16,
"S:%d", speed);
423 tcflush(
PortFD, TCIOFLUSH);
434 this->ignoreResponse();
440 int nbytes_written = 0, rc = -1;
443 snprintf(
cmd, 16,
"N:%d", enabled ? 1 : 0);
448 tcflush(
PortFD, TCIOFLUSH);
459 this->ignoreResponse();
467 targetPosition = targetTicks;
469 bool rc = move(targetPosition);
481 double newPosition = 0;
489 rc = move(newPosition);
508 bool rc = updateFocusParams();
514 if (isMoving ==
false)
520 LOG_INFO(
"Focuser reached requested position.");
531 char cmd[2] = {
'H', 0xA };
539 this->ignoreResponse();
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 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.
INumberVectorProperty FocusAbsPosNP
INumberVectorProperty FocusRelPosNP
ISwitchVectorProperty FocusReverseSP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Connection::Serial * serialConnection
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
perform handshake with device to check communication
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
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
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 IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
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,...)
void IDSetSwitch(const ISwitchVectorProperty *svp, 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,...)
#define TEMPERATURE_THRESHOLD
#define FOCUS_SETTINGS_TAB