29 #define FOCUSNAMEF1 "FocusLynx F1"
30 #define FOCUSNAMEF2 "FocusLynx F2"
32 static std::unique_ptr<FocusLynxF1> lynxDriveF1(
new FocusLynxF1(
"F1"));
33 static std::unique_ptr<FocusLynxF2> lynxDriveF2(
new FocusLynxF2(
"F2"));
93 IUFillText(&WifiT[3],
"Firm. Version OK",
"",
"");
96 IUFillText(&WifiT[6],
"Security mode",
"",
"");
157 lynxDriveF2->RemoteDisconnect();
191 LOG_INFO(
"HUB parameters updated.");
194 LOG_ERROR(
"Failed to retrieve HUB configuration settings...");
211 bool FocusLynxF1::getHubConfig()
216 char response[32] = {0};
218 int nbytes_written = 0;
242 memset(response, 0,
sizeof(response));
244 strncpy(
cmd,
"<FHGETHUBINFO>", 16);
249 strncpy(response,
"HUB INFO\n", 16);
250 nbytes_read = strlen(response);
274 response[nbytes_read - 1] =
'\0';
277 if (strcmp(response,
"HUB INFO"))
281 memset(response, 0,
sizeof(response));
286 strncpy(response,
"Hub FVer = 2.0.4\n", 32);
287 nbytes_read = strlen(response);
295 response[nbytes_read - 1] =
'\0';
298 int rc = sscanf(response,
"%15[^=]=%15[^\n]s", key, text);
313 memset(response, 0,
sizeof(response));
314 memset(text, 0,
sizeof(text));
319 strncpy(response,
"Sleeping = 0\n", 16);
320 nbytes_read = strlen(response);
328 response[nbytes_read - 1] =
'\0';
331 rc = sscanf(response,
"%15[^=]=%s", key, text);
343 memset(response, 0,
sizeof(response));
344 memset(text, 0,
sizeof(text));
349 strncpy(response,
"Wired IP = 169.168.1.10\n", 32);
350 nbytes_read = strlen(response);
358 response[nbytes_read - 1] =
'\0';
361 rc = sscanf(response,
"%15[^=]=%s", key, text);
373 memset(response, 0,
sizeof(response));
374 memset(text, 0,
sizeof(text));
379 strncpy(response,
"DHCPisOn = 1\n", 32);
380 nbytes_read = strlen(response);
388 response[nbytes_read - 1] =
'\0';
391 rc = sscanf(response,
"%15[^=]=%15[^\n]s", key, text);
403 memset(response, 0,
sizeof(response));
404 memset(text, 0,
sizeof(text));
409 strncpy(response,
"WF Atchd = 1\n", 32);
410 nbytes_read = strlen(response);
418 response[nbytes_read - 1] =
'\0';
421 rc = sscanf(response,
"%15[^=]=%s", key, text);
432 memset(response, 0,
sizeof(response));
433 memset(text, 0,
sizeof(text));
438 strncpy(response,
"WF Conn = 1\n", 32);
439 nbytes_read = strlen(response);
447 response[nbytes_read - 1] =
'\0';
450 rc = sscanf(response,
"%15[^=]=%s", key, text);
461 memset(response, 0,
sizeof(response));
462 memset(text, 0,
sizeof(text));
467 strncpy(response,
"WF FVer = 1.0.0\n", 32);
468 nbytes_read = strlen(response);
476 response[nbytes_read - 1] =
'\0';
479 rc = sscanf(response,
"%15[^=]=%s", key, text);
490 memset(response, 0,
sizeof(response));
491 memset(text, 0,
sizeof(text));
496 strncpy(response,
"WF FV OK = 1\n", 32);
497 nbytes_read = strlen(response);
505 response[nbytes_read - 1] =
'\0';
508 rc = sscanf(response,
"%15[^=]=%s", key, text);
519 memset(response, 0,
sizeof(response));
520 memset(text, 0,
sizeof(text));
525 strncpy(response,
"WF SSID = FocusLynxConfig\n", 32);
526 nbytes_read = strlen(response);
534 response[nbytes_read - 1] =
'\0';
537 rc = sscanf(response,
"%15[^=]=%s", key, text);
548 memset(response, 0,
sizeof(response));
549 memset(text, 0,
sizeof(text));
554 strncpy(response,
"WF IP = 192.168.1.11\n", 32);
555 nbytes_read = strlen(response);
563 response[nbytes_read - 1] =
'\0';
566 rc = sscanf(response,
"%15[^=]=%s", key, text);
577 memset(response, 0,
sizeof(response));
578 memset(text, 0,
sizeof(text));
583 strncpy(response,
"WF SecMd = A\n", 32);
584 nbytes_read = strlen(response);
592 response[nbytes_read - 1] =
'\0';
595 rc = sscanf(response,
"%15[^=]= %s", key, text);
606 memset(response, 0,
sizeof(response));
607 memset(text, 0,
sizeof(text));
612 strncpy(response,
"WF SecKy =\n", 32);
613 nbytes_read = strlen(response);
621 response[nbytes_read - 1] =
'\0';
624 rc = sscanf(response,
"%15[^=]=%s", key, text);
635 memset(response, 0,
sizeof(response));
636 memset(text, 0,
sizeof(text));
641 strncpy(response,
"WF WepKI = 0\n", 32);
642 nbytes_read = strlen(response);
650 response[nbytes_read - 1] =
'\0';
653 rc = sscanf(response,
"%15[^=]=%s", key, text);
664 memset(response, 0,
sizeof(response));
665 memset(text, 0,
sizeof(text));
668 if (!strcmp(WifiT[0].text,
"0"))
670 LOGF_INFO(
"Wifi module = %s", WifiT[0].text);
678 strncpy(response,
"END\n", 16);
679 nbytes_read = strlen(response);
690 response[nbytes_read - 1] =
'\0';
695 if (strcmp(response,
"END"))
699 tcflush(
PortFD, TCIFLUSH);
706 LOGF_INFO(
"Version major: %d, minor: %d, subversion: %d", a, b, c);
708 LOG_INFO(
"Couldn't get version information");
720 lynxDriveF2->setSimulation(enable);
730 lynxDriveF2->setDebug(enable);
797 if (!lynxDriveF1->isConnected())
799 if (!lynxDriveF1->Connect())
801 LOG_INFO(
"Focus F1 should be connected before try to connect F2");
804 lynxDriveF1->setConnected(
true,
IPS_OK);
805 lynxDriveF1->updateProperties();
807 PortFD = lynxDriveF1->getPortFD();
812 LOG_INFO(
"FocusLynx is online. Getting focus parameters...");
818 LOG_INFO(
"Error retrieving data from FocusLynx, please ensure FocusLynx controller is powered and the port is correct.");
846 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
Initilize properties initial state and value. The child class must implement this function.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool Handshake() override
perform handshake with device to check communication
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
Initilize properties initial state and value. The child class must implement this function.
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
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
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
Initilize properties initial state and value. The child class must implement this function.
virtual bool Disconnect() override
Disconnect from device.
const char * getDeviceName() const
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)
setConnection Set Focuser connection mode. Child class should call this in the constructor before Foc...
#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,...)
@ key
the parser read a key of a value in an object