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


C++ USBDevice::open方法代码示例

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


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

示例1: getUSBDevice

JNIEXPORT void JNICALL Java_com_stericsson_sdk_equipment_io_usb_internal_USBNativeDevice_open(
		JNIEnv *env, jobject src) {
	try {
		USBDevice *device = getUSBDevice(env, src);

		if (device) {
			device->open();
		} else {
			Logger::getInstance()->error(LP, "Cannot find device!");
		}
	} catch (const char *errorString) {
		env->ThrowNew(env->FindClass(EX_NATIVE_EXCEPTION), errorString);
	} catch (...) {
		env->ThrowNew(env->FindClass(EX_NATIVE_EXCEPTION),
				"Unexpected native call failure in method open!");
	}
}
开发者ID:Meticulus,项目名称:vendor_st-ericsson_u8500,代码行数:17,代码来源:libusb_jni.cpp

示例2: usbDeviceArrived

void FCServer::usbDeviceArrived(libusb_device *device)
{
    /*
     * New USB device. Is this a device we recognize?
     */

    USBDevice *dev;

    if (FCDevice::probe(device)) {
        dev = new FCDevice(device, mVerbose);

    } else if (EnttecDMXDevice::probe(device)) {
        dev = new EnttecDMXDevice(device, mVerbose);

    } else {
        return;
    }

    int r = dev->open();
    if (r < 0) {
        if (mVerbose) {
            switch (r) {

                // Errors that may occur transiently while a device is connecting...
                case LIBUSB_ERROR_NOT_FOUND:
                case LIBUSB_ERROR_NOT_SUPPORTED:
                    #ifdef OS_WINDOWS
                        std::clog << "Waiting for Windows to install " << dev->getName() << " driver. This may take a moment...\n";
                    #endif
                    #ifdef OS_LINUX
                        // Try again in ~100ms or so.
                        mPollForDevicesOnce = true;
                    #endif
                    break;

                default:
                    std::clog << "Error opening " << dev->getName() << ": " << libusb_strerror(libusb_error(r)) << "\n";
                    break;
            }
        }
        delete dev;
        return;
    }

    if (!dev->probeAfterOpening()) {
        // We were mistaken, this device isn't actually one we want.
        delete dev;
        return;
    }

    for (unsigned i = 0; i < mDevices.Size(); ++i) {
        if (dev->matchConfiguration(mDevices[i])) {
            // Found a matching configuration for this device. We're keeping it!

            dev->loadConfiguration(mDevices[i]);
            dev->writeColorCorrection(mColor);
            mUSBDevices.push_back(dev);

            if (mVerbose) {
                std::clog << "USB device " << dev->getName() << " attached.\n";
            }
            jsonConnectedDevicesChanged();
            return;
        }
    }

    if (mVerbose) {
        std::clog << "USB device " << dev->getName() << " has no matching configuration. Not using it.\n";
    }
    delete dev;
}
开发者ID:Elfkay,项目名称:fadecandy,代码行数:71,代码来源:fcserver.cpp


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