Example #1
0
/************************************************************************************
 *
* ***********************************************************************************/
bool FocusLynxF2::Connect()
/* Overide of connect() function
 * different for F2 or F1 focuser
 * F2 don't connect himself to the hub
 */
{
    configurationComplete = false;

    if (!lynxDriveF1->isConnected())
    {
        if (!lynxDriveF1->Connect())
        {
            DEBUG(INDI::Logger::DBG_SESSION, "Focus F1 should be connected before try to connect F2");
            return false;
        }
        lynxDriveF1->setConnected(true, IPS_OK);
        lynxDriveF1->updateProperties();
    }
    PortFD = lynxDriveF1->getPortFD(); //Get the socket descriptor open by focuser F1 connect()
    DEBUGF(INDI::Logger::DBG_SESSION, "F2 PortFD : %d", PortFD);

    int modelIndex = IUFindOnSwitchIndex(&ModelSP);

    if (ack())
    {
        DEBUG(INDI::Logger::DBG_SESSION, "FocusLynx is online. Getting focus parameters...");
        setDeviceType(modelIndex);
        SetTimer(POLLMS);
        return true;
    }

    DEBUG(INDI::Logger::DBG_SESSION,
          "Error retreiving data from FocusLynx, please ensure FocusLynx controller is powered and the port is correct.");
    return false;
}
Example #2
0
/************************************************************************************
 *
* ***********************************************************************************/
bool FocusLynxF2::Connect()
/* Overide of connect() function
 * different for F2 or F1 focuser
 * F2 don't connect himself to the hub
 */
{
    configurationComplete = false;

    if (!lynxDriveF1->isConnected())
    {
        if (!lynxDriveF1->Connect())
        {
            LOG_INFO("Focus F1 should be connected before try to connect F2");
            return false;
        }
        lynxDriveF1->setConnected(true, IPS_OK);
        lynxDriveF1->updateProperties();
    }
    PortFD = lynxDriveF1->getPortFD(); //Get the socket descriptor open by focuser F1 connect()
    LOGF_INFO("F2 PortFD : %d", PortFD);

    if (ack())
    {
        LOG_INFO("FocusLynx is online. Getting focus parameters...");
        // as DefaultDevice::Connect() is not involved, initiate the timer.
        SetTimer(POLLMS);
        return true;
    }

    LOG_INFO("Error retreiving data from FocusLynx, please ensure FocusLynx controller is powered and the port is correct.");
    return false;
}
Example #3
0
/************************************************************************************
 *
* ***********************************************************************************/
bool FocusLynxF2::RemoteDisconnect()
{
  if (isConnected())
  {
    setConnected(false, IPS_IDLE);
    updateProperties();
  }

  // When called by F1, the PortFD should be -1; For debbug purpose
  PortFD = lynxDriveF1->getPortFD();
  DEBUGF(INDI::Logger::DBG_SESSION,"Remote disconnection: %s is offline.", getDeviceName());
  DEBUGF(INDI::Logger::DBG_SESSION, "Value of F2 PortFD = %d", PortFD);
  return true;
}
Example #4
0
bool MoonLiteDRO::Connect()
{
    if (m_ID == 1)
        return INDI::Focuser::Connect();

    if (dro1->isConnected() == false)
    {
        LOG_ERROR("You must connect DRO Focuser #1 first before connecting to DRO Focuser #2.");
        return false;
    }

    PortFD = dro1->getPortFD();
    SetTimer(POLLMS);
    return true;
}
Example #5
0
bool MoonLiteDRO::Ack()
{
    // For First Focuser, try to get the serial/tcp connection port FD
    if (m_ID == 1)
    {
        if (serialConnection == getActiveConnection())
            PortFD = serialConnection->getPortFD();
        else
            PortFD = tcpConnection->getPortFD();
    }
    // For second focuser, try to get the port FD of the first focuser
    else if (m_ID == 2)
    {
        // We need to get Serial Port file descriptor from first focuser
        // Since we need to have only a SINGLE serial connection to the DRO and not two.
        PortFD = dro1->getPortFD();
        if (PortFD == -1)
        {
            LOG_WARN("You must connect DRO Focuser #1 first before connecting to DRO Focuser #2.");
            return false;
        }

        // If we have a valid Port FD then we are good to go
        return true;
    }

    int nbytes_written = 0, nbytes_read = 0, rc = -1;
    char errstr[MAXRBUF];
    char resp[5]={0};
    short pos = -1;

    tcflush(PortFD, TCIOFLUSH);

    //Try to request the position of the focuser
    //Test for success on transmission and response
    //If either one fails, try again, up to 3 times, waiting 1 sec each time
    //If that fails, then return false.

    int numChecks = 0;
    bool success = false;
    while(numChecks < 3 && !success)
    {
        numChecks++;
        sleep(1); //wait 1 second between each test.

        bool transmissionSuccess = (rc = tty_write(PortFD, ":GP#", 4, &nbytes_written)) == TTY_OK;
        if(!transmissionSuccess)
        {
            tty_error_msg(rc, errstr, MAXRBUF);
            LOGF_ERROR("Handshake Attempt %i, tty transmission error: %s.", numChecks, errstr);
        }

        bool responseSuccess = (rc = tty_read(PortFD, resp, 5, MOONLITEDRO_TIMEOUT, &nbytes_read)) == TTY_OK;
        if(!responseSuccess)
        {
            tty_error_msg(rc, errstr, MAXRBUF);
            LOGF_ERROR("Handshake Attempt %i, updatePosition response error: %s.", numChecks, errstr);
        }

        success = transmissionSuccess && responseSuccess;
    }

    if(!success)
    {
        LOG_INFO("Handshake failed after 3 attempts");
        return false;
    }

    tcflush(PortFD, TCIOFLUSH);

    rc = sscanf(resp, "%hX#", &pos);

    return rc > 0;
}