Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Jul 2010 20:21:48 +0200
From:      Peer Stritzinger <peerst@gmail.com>
To:        Hans Petter Selasky <hselasky@c2i.net>
Cc:        freebsd-usb@freebsd.org
Subject:   Re: FreeBSD 8: libusb async mode + select(2) = nogo?
Message-ID:  <AANLkTinYObeC8GsCu_MLBf0LzQf4S5zwYYMO_yrX__sK@mail.gmail.com>
In-Reply-To: <201007231921.45803.hselasky@c2i.net>
References:  <AANLkTikk7L-63c6wQb0YKoYovGKPcT932Lc9n6mRrmK9@mail.gmail.com> <201007231657.47682.hselasky@c2i.net> <AANLkTi=a__R7gNvE371zs1vNpMXLFXS-09joihFQc-_H@mail.gmail.com> <201007231921.45803.hselasky@c2i.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

On Fri, Jul 23, 2010 at 7:21 PM, Hans Petter Selasky <hselasky@c2i.net> wro=
te:

> Should work, but it might be that the second poll, when you try to proces=
s the
> events, don't work like expected. After any event on the two fd's you sho=
uld
> call "libusb_handle_events_locked()" using a "tv =3D NULL".

Added some debug printing to make watching these easier:

active config: num_interfaces: 1
interface 0: num_altsetting: 1
if_desc 0: n_ep=3D4 if_nr=3D0
max packet on 3.2.6 =3D 512
setup_usb_fds: read 3
setup_usb_fds: read 6
setup_usb_fds: write 6
setup_usb_fds: nfds 6
calling select ...
returned 1                  -> so select returns once (always as it looks)
check_usb_fds: found desc 3 in readfds
calling libusb_handle_events_timeout
transfer_completed: actual_len: 52    -> and also gets a transfer from
the usb (this resubmits the IN transfer)
setup_usb_fds: read 3
setup_usb_fds: read 6
setup_usb_fds: write 6
setup_usb_fds: nfds 6
calling select ...            -> but here it hangs until a signal

The code that did output this still using libusb_handle_events_timeout()

  rv =3D libusb_submit_transfer(tr);
  assert(rv =3D=3D 0);

  sp.pollfds =3D libusb_get_pollfds(ctx);

  while (1)
    {
      timeout_pending =3D libusb_get_next_timeout(ctx, &timeout);
      setup_usb_fds (&sp);
      printf("calling select ...\n");
      rv =3D select(sp.nfds, &sp.readfds, &sp.writefds, &sp.exceptfds,
	     (timeout_pending) ? &timeout : NULL);
      printf("returned %d\n", rv);
      assert (rv >=3D 0 || errno =3D=3D EINTR);

      if (rv =3D=3D 0 || (rv > 0 && check_usb_fds (&sp)))
	{
	  printf ("calling libusb_handle_events_timeout\n");
	  libusb_handle_events_timeout(ctx, NULL);
	}
    }

=A0-- Peer



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinYObeC8GsCu_MLBf0LzQf4S5zwYYMO_yrX__sK>