使用ffs从USB读取数据
我面临的问题是无法从 USB 端点可靠地读取数据。我的 ffs 定义了以下 eps:
Ep0 = control
Ep1 = in
Ep2 = out
我有一个简单的 ::read()
调用,该调用在 int fd = ::open(ep1, O_RDONLY) 上被阻止。问题是,在 Ep1 上执行 ::close()
对 ::read 调用没有影响,我几乎永远被阻止。我尝试应用 select 和 poll Ep1 但这些立即返回,即使终点上没有实际数据,我后来也尝试在 Ep0 上应用 poll() 和 select() 方法,但是即使我尝试使用 WinUSB 提交数据,这些数据也会无限期地挂起。我一定错过了一些东西......不知道什么
编辑:
int fd_control_ = ::open("/dev/usb-ffs/ABC/ep0", O_RDWR);
int fd_read = ::open("/dev/usb-ffs/ABC/ep1", O_RDWR);
pollfd fd;
fd.events = POLLIN|POLLOUT;
fd.fd = fd_control_;
int ret = poll(&fd, 1, -1) // this never returns
return ::read(fd_read_, buffer, bufferSize); // without the poll, ::close never release ::read()
I’m facing a problem where I’m unable to reliably read data from my usb endpoints. My ffs defines the following eps:
Ep0 = control
Ep1 = in
Ep2 = out
I have a simple ::read()
call that is blocked on int fd = ::open(ep1, O_RDONLY). Problem is that executing ::close()
on Ep1 has no effect on the ::read call and I’m pretty much blocked forever. I tried to apply select and poll Ep1 but these returned immediately even though no actual data was present on the end point, I later on also tried to apply the poll() and select()
methods on Ep0 but those hanged indefinitely even though I tried to submit data with WinUSB which also hanged up. I must be missing something… not sure what
Edit:
int fd_control_ = ::open("/dev/usb-ffs/ABC/ep0", O_RDWR);
int fd_read = ::open("/dev/usb-ffs/ABC/ep1", O_RDWR);
pollfd fd;
fd.events = POLLIN|POLLOUT;
fd.fd = fd_control_;
int ret = poll(&fd, 1, -1) // this never returns
return ::read(fd_read_, buffer, bufferSize); // without the poll, ::close never release ::read()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论