本文整理汇总了C++中DevicePtr::InterfaceClaimed方法的典型用法代码示例。如果您正苦于以下问题:C++ DevicePtr::InterfaceClaimed方法的具体用法?C++ DevicePtr::InterfaceClaimed怎么用?C++ DevicePtr::InterfaceClaimed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DevicePtr
的用法示例。
在下文中一共展示了DevicePtr::InterfaceClaimed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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;
}
示例4: 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);
}