29#define FOCUSNAMEF1 "FocusLynx F1"
30#define FOCUSNAMEF2 "FocusLynx F2"
32static std::unique_ptr<FocusLynxF1> lynxDriveF1(
new FocusLynxF1(
"F1"));
33static std::unique_ptr<FocusLynxF2> lynxDriveF2(
new FocusLynxF2(
"F2"));
95 IUFillText(&WifiT[3],
"Firm. Version OK",
"",
"");
98 IUFillText(&WifiT[6],
"Security mode",
"",
"");
159 lynxDriveF2->RemoteDisconnect();
193 LOG_INFO(
"HUB parameters updated.");
196 LOG_ERROR(
"Failed to retrieve HUB configuration settings...");
213bool FocusLynxF1::getHubConfig()
218 char response[32] = {0};
220 int nbytes_written = 0;
244 memset(response, 0,
sizeof(response));
246 strncpy(
cmd,
"<FHGETHUBINFO>", 16);
251 strncpy(response,
"HUB INFO\n", 16);
252 nbytes_read = strlen(response);
276 response[nbytes_read - 1] =
'\0';
279 if (strcmp(response,
"HUB INFO"))
283 memset(response, 0,
sizeof(response));
288 strncpy(response,
"Hub FVer = 2.0.4\n", 32);
289 nbytes_read = strlen(response);
297 response[nbytes_read - 1] =
'\0';
300 int rc = sscanf(response,
"%15[^=]=%15[^\n]s", key, text);
315 memset(response, 0,
sizeof(response));
316 memset(text, 0,
sizeof(text));
321 strncpy(response,
"Sleeping = 0\n", 16);
322 nbytes_read = strlen(response);
330 response[nbytes_read - 1] =
'\0';
333 rc = sscanf(response,
"%15[^=]=%s", key, text);
345 memset(response, 0,
sizeof(response));
346 memset(text, 0,
sizeof(text));
351 strncpy(response,
"Wired IP = 169.168.1.10\n", 32);
352 nbytes_read = strlen(response);
360 response[nbytes_read - 1] =
'\0';
363 rc = sscanf(response,
"%15[^=]=%s", key, text);
375 memset(response, 0,
sizeof(response));
376 memset(text, 0,
sizeof(text));
381 strncpy(response,
"DHCPisOn = 1\n", 32);
382 nbytes_read = strlen(response);
390 response[nbytes_read - 1] =
'\0';
393 rc = sscanf(response,
"%15[^=]=%15[^\n]s", key, text);
405 memset(response, 0,
sizeof(response));
406 memset(text, 0,
sizeof(text));
411 strncpy(response,
"WF Atchd = 1\n", 32);
412 nbytes_read = strlen(response);
420 response[nbytes_read - 1] =
'\0';
423 rc = sscanf(response,
"%15[^=]=%s", key, text);
434 memset(response, 0,
sizeof(response));
435 memset(text, 0,
sizeof(text));
440 strncpy(response,
"WF Conn = 1\n", 32);
441 nbytes_read = strlen(response);
449 response[nbytes_read - 1] =
'\0';
452 rc = sscanf(response,
"%15[^=]=%s", key, text);
463 memset(response, 0,
sizeof(response));
464 memset(text, 0,
sizeof(text));
469 strncpy(response,
"WF FVer = 1.0.0\n", 32);
470 nbytes_read = strlen(response);
478 response[nbytes_read - 1] =
'\0';
481 rc = sscanf(response,
"%15[^=]=%s", key, text);
492 memset(response, 0,
sizeof(response));
493 memset(text, 0,
sizeof(text));
498 strncpy(response,
"WF FV OK = 1\n", 32);
499 nbytes_read = strlen(response);
507 response[nbytes_read - 1] =
'\0';
510 rc = sscanf(response,
"%15[^=]=%s", key, text);
521 memset(response, 0,
sizeof(response));
522 memset(text, 0,
sizeof(text));
527 strncpy(response,
"WF SSID = FocusLynxConfig\n", 32);
528 nbytes_read = strlen(response);
536 response[nbytes_read - 1] =
'\0';
539 rc = sscanf(response,
"%15[^=]=%s", key, text);
550 memset(response, 0,
sizeof(response));
551 memset(text, 0,
sizeof(text));
556 strncpy(response,
"WF IP = 192.168.1.11\n", 32);
557 nbytes_read = strlen(response);
565 response[nbytes_read - 1] =
'\0';
568 rc = sscanf(response,
"%15[^=]=%s", key, text);
579 memset(response, 0,
sizeof(response));
580 memset(text, 0,
sizeof(text));
585 strncpy(response,
"WF SecMd = A\n", 32);
586 nbytes_read = strlen(response);
594 response[nbytes_read - 1] =
'\0';
597 rc = sscanf(response,
"%15[^=]= %s", key, text);
608 memset(response, 0,
sizeof(response));
609 memset(text, 0,
sizeof(text));
614 strncpy(response,
"WF SecKy =\n", 32);
615 nbytes_read = strlen(response);
623 response[nbytes_read - 1] =
'\0';
626 rc = sscanf(response,
"%15[^=]=%s", key, text);
637 memset(response, 0,
sizeof(response));
638 memset(text, 0,
sizeof(text));
643 strncpy(response,
"WF WepKI = 0\n", 32);
644 nbytes_read = strlen(response);
652 response[nbytes_read - 1] =
'\0';
655 rc = sscanf(response,
"%15[^=]=%s", key, text);
666 memset(response, 0,
sizeof(response));
667 memset(text, 0,
sizeof(text));
670 if (!strcmp(WifiT[0].text,
"0"))
672 LOGF_INFO(
"Wifi module = %s", WifiT[0].text);
680 strncpy(response,
"END\n", 16);
681 nbytes_read = strlen(response);
692 response[nbytes_read - 1] =
'\0';
697 if (strcmp(response,
"END"))
701 tcflush(
PortFD, TCIFLUSH);
708 LOGF_INFO(
"Version major: %d, minor: %d, subversion: %d", a, b, c);
710 LOG_INFO(
"Couldn't get version information");
722 lynxDriveF2->setSimulation(enable);
732 lynxDriveF2->setDebug(enable);
801 if (!lynxDriveF1->isConnected())
803 if (!lynxDriveF1->Connect())
805 LOG_INFO(
"Focus F1 should be connected before try to connect F2");
808 lynxDriveF1->setConnected(
true,
IPS_OK);
809 lynxDriveF1->updateProperties();
811 PortFD = lynxDriveF1->getPortFD();
816 LOG_INFO(
"FocusLynx is online. Getting focus parameters...");
822 LOG_INFO(
"Error retrieving data from FocusLynx, please ensure FocusLynx controller is powered and the port is correct.");
850 PortFD = lynxDriveF1->getPortFD();
void setDefaultBaudRate(BaudRate newRate)
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by t...
void setDefaultPort(uint32_t addressPort)
INumberVectorProperty LedNP
virtual int getVersion(int *major, int *minor, int *sub)
bool configurationComplete
void setFocusTarget(const char *target)
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
virtual void setDebug(bool enable)
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual bool Disconnect() override
Disconnect from device.
FocusLynxF1(const char *target)
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
const char * getDefaultName() override
virtual void simulationTriggered(bool enable) override
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual bool RemoteDisconnect()
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
FocusLynxF2(const char *target)
virtual void setDebug(bool enable)
virtual void setSimulation(bool enable)
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
const char * getDefaultName() override
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool Disconnect() override
Disconnect from device.
void setDeviceName(const char *dev)
Set the device name.
void setSimulation(bool enable)
Toggle driver simulation status A driver can run in simulation mode if Simulation option is enabled b...
virtual bool Disconnect()
Disconnect from device.
virtual void setConnected(bool status, IPState state=IPS_OK, const char *msg=nullptr)
Set connection switch status in the client.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
virtual void simulationTriggered(bool enable)
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
void defineProperty(INumberVectorProperty *property)
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
void setDebug(bool enable)
Toggle driver debug status A driver can be more verbose if Debug option is enabled by the client.
bool isSimulation() const
virtual void debugTriggered(bool enable)
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
Connection::Interface * getActiveConnection()
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
virtual bool Connect()
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
Connection::TCP * tcpConnection
Connection::Serial * serialConnection
void setSupportedConnections(const uint8_t &value)
#define LYNXFOCUS_TIMEOUT
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 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 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 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,...)