使用ffs从USB读取数据

发布于 2025-01-14 05:39:05 字数 763 浏览 3 评论 0原文

我面临的问题是无法从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文