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


C++ DevicePtr::ClaimInterface方法代码示例

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


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

示例1: IsPipeHalted

BOOL OpenContext::IsPipeHalted(LPUKWD_ENDPOINT_INFO lpEndpointInfo, LPBOOL halted)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), lpEndpointInfo->lpDevice);
	if (!Validate(dev) || halted == NULL) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}

	// Find the interface for this device
	DWORD dwInterface = -1;
	if (lpEndpointInfo->Endpoint != 0) {
		if (!dev->FindInterface(lpEndpointInfo->Endpoint, dwInterface)) {
			ERROR_MSG((TEXT("USBKWrapperDrv!OpenContext::IsPipeHalted() - ")
				TEXT("failed to find interface for endpoint %d on device 0x%08x\r\n"),
				lpEndpointInfo->Endpoint, lpEndpointInfo->lpDevice));
			SetLastError(ERROR_INVALID_PARAMETER);
			return FALSE;
		}

		// See if it's already been claimed
		if (!dev->InterfaceClaimed(dwInterface, this)) {
			WARN_MSG((TEXT("USBKWrapperDrv!OpenContext::IsPipeHalted() - ")
				TEXT("using interface %d on device 0x%08x without claiming\r\n"),
				dwInterface, lpEndpointInfo->lpDevice));
			if (!dev->ClaimInterface(dwInterface, this)) {
				return FALSE;
			}
		}
	}

	return dev->IsEndpointHalted(dwInterface, lpEndpointInfo->Endpoint, *halted);
}
开发者ID:dsdwew,项目名称:CEUSBKWrapper,代码行数:33,代码来源:OpenContext.cpp

示例2: SetAltSetting

BOOL OpenContext::SetAltSetting(LPUKWD_SET_ALTSETTING_INFO lpSetAltSettingInfo)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), lpSetAltSettingInfo->lpDevice);
	if (!Validate(dev)) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}

	// Interface can't be used if device has closed
	if (dev->Closed()) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}

	if (!dev->InterfaceClaimed(lpSetAltSettingInfo->dwInterface, this)) {
		WARN_MSG((TEXT("USBKWrapperDrv!OpenContext::SetAltSetting() - ")
			TEXT("using interface %d on device 0x%08x without claiming\r\n"),
			lpSetAltSettingInfo->dwInterface, lpSetAltSettingInfo->lpDevice));
		if (!dev->ClaimInterface(lpSetAltSettingInfo->dwInterface, this)) {
			return FALSE;
		}
	}
	return dev->SetAltSetting(lpSetAltSettingInfo->dwInterface,
						lpSetAltSettingInfo->dwAlternateSetting);
}
开发者ID:CecilHarvey,项目名称:CEUSBKWrapper,代码行数:26,代码来源:OpenContext.cpp

示例3: StartBulkTransfer

BOOL OpenContext::StartBulkTransfer(LPUKWD_BULK_TRANSFER_INFO lpTransferInfo)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), lpTransferInfo->lpDevice);
	if (!Validate(dev)) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}

	// Interface can't be used if device has closed
	if (dev->Closed()) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}

	// Find the interface for this transfer
	DWORD dwInterface;
	if (!dev->FindInterface(lpTransferInfo->Endpoint, dwInterface)) {
		ERROR_MSG((TEXT("USBKWrapperDrv!OpenContext::StartBulkTransfer() - ")
			TEXT("failed to find interface for endpoint %d on device 0x%08x\r\n"),
			lpTransferInfo->Endpoint, lpTransferInfo->lpDevice));
		SetLastError(ERROR_INVALID_PARAMETER);
		return FALSE;
	}

	// See if it's already been claimed
	if (!dev->InterfaceClaimed(dwInterface, this)) {
		WARN_MSG((TEXT("USBKWrapperDrv!OpenContext::StartBulkTransfer() - ")
			TEXT("using interface %d on device 0x%08x without claiming\r\n"),
			dwInterface, lpTransferInfo->lpDevice));
		if (!dev->ClaimInterface(dwInterface, this)) {
			return FALSE;
		}
	}

	TRANSFERLIFETIME_MSG((TEXT("USBKWrapperDrv!OpenContext::StartBulkTransfer() on ep %x, flag 0x%08x and size %d\r\n"),
		lpTransferInfo->Endpoint, lpTransferInfo->dwFlags, lpTransferInfo->dwDataBufferSize));

	// Construct and start the bulk transfer
	BulkTransfer* bt = new (std::nothrow) BulkTransfer(
			this, dev, dwInterface, lpTransferInfo);
	if (!bt) {
		ERROR_MSG((TEXT("USBKWrapperDrv!OpenContext::StartBulkTransfer() - failed to create bulk transfer, aborting\r\n")));
		SetLastError(ERROR_NOT_ENOUGH_MEMORY);
		return FALSE;
	}
	BOOL ret = bt->Start();
	mTransferList->PutTransfer(bt);
	bt = NULL;
	if (!ret) {
		ERROR_MSG((TEXT("USBKWrapperDrv!OpenContext::StartBulkTransfer() - failed to start bulk transfer %d\r\n"), GetLastError()));
		return FALSE;
	}
	// Ownership of ct has passed to the transfer callback
	return TRUE;
}
开发者ID:CecilHarvey,项目名称:CEUSBKWrapper,代码行数:56,代码来源:OpenContext.cpp

示例4: ClaimInterface

BOOL OpenContext::ClaimInterface(LPUKWD_INTERFACE_INFO lpInterfaceInfo)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), lpInterfaceInfo->lpDevice);
	if (!Validate(dev)) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}

	return dev->ClaimInterface(lpInterfaceInfo->dwInterface, this);
}
开发者ID:dsdwew,项目名称:CEUSBKWrapper,代码行数:11,代码来源:OpenContext.cpp

示例5: ClearHaltDevice

BOOL OpenContext::ClearHaltDevice(LPUKWD_ENDPOINT_INFO lpEndpointInfo)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), lpEndpointInfo->lpDevice);
	if (!Validate(dev)) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}

	// Interface can't be used if device has closed
	if (dev->Closed()) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}

	// Find the interface for this device
	DWORD dwInterface;
	if (!dev->FindInterface(lpEndpointInfo->Endpoint, dwInterface)) {
		ERROR_MSG((TEXT("USBKWrapperDrv!OpenContext::ClearHalt() - ")
			TEXT("failed to find interface for endpoint %d on device 0x%08x\r\n"),
			lpEndpointInfo->Endpoint, lpEndpointInfo->lpDevice));
		SetLastError(ERROR_INVALID_PARAMETER);
		return FALSE;
	}

	// See if it's already been claimed
	if (!dev->InterfaceClaimed(dwInterface, this)) {
		WARN_MSG((TEXT("USBKWrapperDrv!OpenContext::ClearHalt() - ")
			TEXT("using interface %d on device 0x%08x without claiming\r\n"),
			dwInterface, lpEndpointInfo->lpDevice));
		if (!dev->ClaimInterface(dwInterface, this)) {
			return FALSE;
		}
	}

	return dev->ClearHaltDevice(dwInterface, lpEndpointInfo->Endpoint);
}
开发者ID:CecilHarvey,项目名称:CEUSBKWrapper,代码行数:37,代码来源:OpenContext.cpp


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