Instrument Neutral Distributed Interface INDI
1.9.5
|
Go to the documentation of this file.
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,
"%16[^=]=%16[^\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,
"%16[^=]=%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,
"%16[^=]=%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,
"%16[^=]=%16[^\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,
"%16[^=]=%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,
"%16[^=]=%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,
"%16[^=]=%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,
"%16[^=]=%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,
"%32[^=]=%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,
"%16[^=]=%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,
"%16[^=]= %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,
"%16[^=]=%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,
"%16[^=]=%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);
798 if (!lynxDriveF1->isConnected())
800 if (!lynxDriveF1->Connect())
802 LOG_INFO(
"Focus F1 should be connected before try to connect F2");
805 lynxDriveF1->setConnected(
true,
IPS_OK);
806 lynxDriveF1->updateProperties();
808 PortFD = lynxDriveF1->getPortFD();
813 LOG_INFO(
"FocusLynx is online. Getting focus parameters...");
819 LOG_INFO(
"Error retrieving data from FocusLynx, please ensure FocusLynx controller is powered and the port is correct.");
847 PortFD = lynxDriveF1->getPortFD();
virtual void simulationTriggered(bool enable)
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
virtual bool Disconnect() override
Disconnect from device.
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
virtual bool Handshake() override
perform handshake with device to check communication
#define LOGF_ERROR(fmt,...)
virtual void setConnected(bool status, IPState state=IPS_OK, const char *msg=nullptr)
Set connection switch status in the client.
Implementations for common driver routines.
void IDSetText(const ITextVectorProperty *t, const char *msg,...) ATTRIBUTE_FORMAT_PRINTF(2
Tell client to update an existing text vector property.
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
const char * getDefaultName() override
bool isSimulation() const
void defineProperty(INumberVectorProperty *property)
FocusLynxF1(const char *target)
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.
virtual void setDebug(bool enable)
INumberVectorProperty LedNP
const char * getDeviceName() const
Connection::Serial * serialConnection
virtual bool Disconnect() override
Disconnect from device.
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
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.
virtual int getVersion(int *major, int *minor, int *sub)
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
virtual void setSimulation(bool enable)
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
#define LOGF_DEBUG(fmt,...)
void setDefaultBaudRate(BaudRate newRate)
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by t...
virtual bool RemoteDisconnect()
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
virtual void simulationTriggered(bool enable) override
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
void setFocusTarget(const char *target)
virtual void debugTriggered(bool enable)
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
virtual bool Connect()
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
FocusLynxF2(const char *target)
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Connection::TCP * tcpConnection
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
void setSimulation(bool enable)
Toggle driver simulation status A driver can run in simulation mode if Simulation option is enabled b...
void setDebug(bool enable)
Toggle driver debug status A driver can be more verbose if Debug option is enabled by the client.
#define LOGF_INFO(fmt,...)
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
void IUSaveText(IText *tp, const char *newtext)
Function to reliably save new text in a IText.
#define LYNXFOCUS_TIMEOUT
void setDefaultPort(uint32_t addressPort)
virtual void setDebug(bool enable)
const char * getDefaultName() override
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
void setSupportedConnections(const uint8_t &value)
setConnection Set Focuser connection mode. Child class should call this in the constructor before Foc...
bool configurationComplete
virtual bool Disconnect()
Disconnect from device.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
Connection::Interface * getActiveConnection()