问题描述
我正在尝试在我的Windows嵌入式压缩7设备(WinCE设备< - > PC)上实现串行通信。
I'm trying to implement serial communication on my Windows embedded compact 7 device (WinCE device <-> PC).
在设备上:我使用USB功能串行客户端。我已根据我的需要设置了相应的注册表设置(禁用ActiveSync,专有供应商/产品ID等)。我做一个CreateFile()并做ReadFile / WriteFile来接收/传输数据。
On the device: I use the USB function serial client. I have setup the corresponding registry settings according to my needs (ActiveSync disabled, proprietary vendor/product id's, etc.). I do a CreateFile() and do ReadFile/WriteFile to receive/transmit data.
在PC上:我使用WinUSB(如http://support.microsoft.com/kb中所述) / 968204)。
On the PC: I use WinUSB (as suggested in http://support.microsoft.com/kb/968204).
现在,当我将设备连接到PC的USB端口时,它会被识别并按预期显示在PC的设备管理器中。
PC测试应用程序我可以打开通信并发送数据,由于某种原因,设备上的测试应用程序无法接收这些数据。但是 - 令人惊讶的是 - PC应用程序可以接收从设备发送的数据。由于某种原因,设备上的ReadFile()
操作无法读取。
Now, when I connect the device to the PC's USB port it gets recognized and appears in the PC's device manager as expected.
With my PC test application I can open the communication and send data, which for some reason doesn't get received by the test app on the device. But - surprisingly - data sent from the device can be received by the PC app. For some reason the ReadFile()
operation on the device fails to read.
在2010年11月的这个网站上,一个名叫Bulma的人正好描述了同样的问题 - ReadFile()返回
零字节。他自己解决了。调用SetCommState()并将DCB结构的fDsrSensitivity参数设置为TRUE可以解决问题。
In a thread on this site of november 2010 a guy named Bulma described exactly the same problem - ReadFile() returning
zero bytes. He solved it himself. A call to SetCommState() and setting the fDsrSensitivity parameter of the DCB structure to TRUE fixed the problem.
充满希望我也试过这个但是没有成功,ReadFile()仍然失败。
Rife with hope I tryed this too but with no success, ReadFile() still fails.
我还检查了其他类似主题的线程,但我找不到任何提示。
I also checked other threads with similar topics but I couldn't find any hint.
有谁知道什么会使ReadFile失败( )操作?
Has anybody any idea what could make fail the ReadFile() operation?
为什么WriteFile()工作和ReadFile()失败。
Why does WriteFile() work and ReadFile() fail.
提前致谢!
推荐答案
能告诉我们返回错误代码吗?还要检查驱动程序超时设置。您可以使用GetCommTimeouts()API获取当前的驱动程序超时设置,并使用SetCommTimeouts()设置正确的超时
。
Rakesh。
这篇关于USB串行通信,ReadFile()返回零字节读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!