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