WinUsb_WritePipe进入无限循环

时间:2017-05-29 13:55:47

标签: c++ infinite-loop winusb

我正在使用WinUsb_WritePipe function在USB设备上写入数据。

唯一的麻烦是该函数执行无限循环。

//bulkOutPipe is a pipeId set precedently
//ucBuffer is an unsigned char array
//uiBytesToWrite corresponds to the size of the array
//ulBytesWritten is a unsigned long to stock the bytes written

std::cout << "Started writing" << std::endl;

WinUsb_WritePipe(devInfo->winUsbHandle, devInfo->bulkOutPipe, ucBuffer, uiBytesToWrite, &ulBytesWritten, 0);

//never gets here

此函数used to return false但现在它不会返回任何内容。

1 个答案:

答案 0 :(得分:0)

为了避免无限循环,我建议总是为这样的I / O操作设置超时。您可以使用WinUSB Functions for Pipe Policy Modification