当前位置: 首页>>代码示例>>C++>>正文


C++ Loader::Connect方法代码示例

本文整理汇总了C++中Loader::Connect方法的典型用法代码示例。如果您正苦于以下问题:C++ Loader::Connect方法的具体用法?C++ Loader::Connect怎么用?C++ Loader::Connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Loader的用法示例。


在下文中一共展示了Loader::Connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Connect

bool SSAG::Connect(bool bootload) {
  if ((this->handle = libusb_open_device_with_vid_pid(ctx, SSAG_VENDOR_ID, SSAG_PRODUCT_ID)) == NULL) {
    if (bootload) {
      Loader *loader = new Loader();
      if (loader->Connect()) {
        if (!loader->LoadFirmware()) {
          DBG("Failed to upload firmware to the device");
          return false;
        }
        loader->Disconnect();
        for (int i = 0; i < RENUMERATE_TIMEOUT; i++) {
          if (this->Connect(false))
            return true;
          sleep(1);
        }
        DBG("Device did not renumerate. Timed out.");
        return false;
      } else {
        DBG("Failed to connect loader");
        return false;
      }
    } else {
      return false;
    }
  }
  
  int rc;
  if (libusb_kernel_driver_active(this->handle, 0) == 1) {
    rc = libusb_detach_kernel_driver(this->handle, 0);
    if (rc < 0) {
      DBG("Can't detach kernel driver (%d)", rc);
    }
  }
  
  rc = libusb_set_configuration(this->handle, 1);
  if (rc < 0) {
    DBG("Can't set configuration (%d)", rc);
  }

  rc = libusb_claim_interface(this->handle, 0);
  if (rc < 0) {
    DBG("Can't claim interface (%d)", rc);
  }
  
  this->SetBufferMode();
  this->SetGain(1);
  this->InitSequence();
  
  return true;
}
开发者ID:mp77,项目名称:indi,代码行数:50,代码来源:openssag.cpp

示例2: Connect

bool SSAG::Connect(bool bootload)
{
    if (!usb_open_device(&this->handle, SSAG_VENDOR_ID, SSAG_PRODUCT_ID, NULL)) {
        if (bootload) {
            Loader *loader = new Loader();
            if (loader->Connect()) {
                if (!loader->LoadFirmware()) {
                    fprintf(stderr, "ERROR:  Failed to upload firmware to the device\n");
                    return false;
                }
                loader->Disconnect();
                for (time_t t = time(NULL) + RENUMERATE_TIMEOUT; time(NULL) < t;) {
                    DBG("Checking if camera has renumerated...");
                    if (EnumerateDevices()) {
                        DBG("Yes\n");
                        return this->Connect(false);
                    }
                    DBG("No\n");
                    sleep(1);
                }
                DBG("ERROR:  Device did not renumerate. Timed out.\n");
                /* Timed out */
                return false;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }

    this->SetBufferMode();
    this->SetGain(1);
    this->InitSequence();

    return true;
}
开发者ID:raffienficiaud,项目名称:openssag,代码行数:37,代码来源:openssag.cpp


注:本文中的Loader::Connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。