Configures device interface/alt settings.
#define INTF_NUMBER 0x00
#define ALT_SETTING_NUMBER 0x00
#define EP_READ 0x81
#define EP_WRITE 0x01
DWORD __cdecl main(int argc, char* argv[])
{
DWORD errorCode = ERROR_SUCCESS;
UCHAR pipeIndex = 0;
return GetLastError();
if (!Usb.
Init(&handle, deviceInfo))
{
errorCode = GetLastError();
printf("Usb.Init failed. ErrorCode: %08Xh\n", errorCode);
goto Done;
}
printf("Device opened successfully!\n");
if (!Usb.
ClaimInterface(handle, INTF_NUMBER, FALSE))
{
errorCode = GetLastError();
if (errorCode == ERROR_NO_MORE_ITEMS)
printf("Interface number %02Xh does not exists.\n", INTF_NUMBER);
else
printf("Usb.ClaimInterface failed. ErrorCode: %08Xh\n", errorCode);
goto Done;
}
if (!Usb.
QueryInterfaceSettings(handle, ALT_SETTING_NUMBER, &interfaceInfo))
{
errorCode = GetLastError();
if (errorCode == ERROR_NO_MORE_ITEMS)
printf("Alt Setting number %02Xh does not exists.\n", ALT_SETTING_NUMBER);
else
printf("Usb.QueryInterfaceSettings failed. ErrorCode: %08Xh\n", errorCode);
goto Done;
}
printf("Interface/alt setting number %02Xh/%02Xh found!\n",
memset(&readInfo, 0, sizeof(readInfo));
memset(&writeInfo, 0, sizeof(writeInfo));
while (Usb.
QueryPipe(handle, ALT_SETTING_NUMBER, pipeIndex++, &pipeInfo))
{
if (pipeInfo.
PipeId == EP_READ)
memcpy(&readInfo, &pipeInfo, sizeof(readInfo));
else if (pipeInfo.
PipeId == EP_WRITE)
memcpy(&writeInfo, &pipeInfo, sizeof(writeInfo));
}
{
printf("Read pipe %02Xh not found.\n", EP_READ);
goto Done;
}
else
printf(
"Read pipe %02Xh found!\n", readInfo.
PipeId);
{
printf("Write pipe %02Xh not found.\n", EP_WRITE);
goto Done;
}
else
printf(
"Write pipe %02Xh found!\n", writeInfo.
PipeId);
{
errorCode = GetLastError();
printf("Usb.SetCurrentAlternateSetting failed. bAlternateSetting: %u, ErrorCode: %08Xh\n",
goto Done;
}
else
{
}
Done:
if (handle) Usb.
Free(handle);
return errorCode;
}