|
USB读写时,能通过CreateFile获取句柄,调用WriteFile或者ReadFile时总是返回失败,错误码是997,下面是写入HID的代码 if(m_hUsb==INVALID_HANDLE_VALUE)return; unsigned char OutputBuffer[70]; DWORD nWriteBytes; HANDLE WriteEvent = CreateEvent(NULL, true, false, NULL); OVERLAPPED writeOverlap; writeOverlap.hEvent = WriteEvent; writeOverlap.Offset = 0; writeOverlap.OffsetHigh = 0; UpdateData(TRUE); OutputBuffer[0] = 0x00; OutputBuffer[1] = 0x01; OutputBuffer[2] = 0x02; OutputBuffer[3] = 0x03; // for(int i=1; i-1<m_SendStr.GetLength();i++) // { // OutputBuffer = m_SendStr.GetAt(i-1); // //WideCharToMultiByte // } ResetEvent(WriteEvent); DWORD len = m_SendStr.GetLength() + 1; if (WriteFile(m_hUsb, &OutputBuffer, 65, &nWriteBytes, &writeOverlap)) { AfxMessageBox(_T("Succ write")); }else { DWORD Err = GetLastError(); cout<<Err; } 求指点,谢谢 |
Your UAT Feedback is needed within today.
STM32_USB_Device_Library
用STM32F4 Cube MX生成的USB Device C代码的BUG
STM32F446 USB和串口1 冲突
STM32f407ZG使用STM32CubeMX创建USB应用失败
请教stm32F105 USB开发资料去哪里下载
STM32F103VE-USB-VCOM发不出数据
STM32cubemx 配置出的 USB HID 电脑无法识别
[STM32L496] 求助USBCDC通信,PC端总是需要插拔USB线问题
STM32F USB DFU下载无法识别USB设备
微信公众号
手机版
https://www.stmcu.org.cn/module/ ... &fromuid=366506
(出处: 意法半导体STM32/STM8技术社区)
供参考
// MessageId: ERROR_IO_PENDING
//
// MessageText:
//
// Overlapped I/O operation is in progress.
//
#define ERROR_IO_PENDING 997L // dderror
WriteFile返回了 但WriteFile操作没有完成 而已
自己处理下这个错误码.