On Sun, Feb 12, 2012 at 7:10 PM, Phil Mayers <p.may...@imperial.ac.uk>wrote:
> On 02/12/2012 04:13 AM, Donal McMullan wrote: > > I'm trying to integrate Twisted with libusb-1 > > > > The libusb-1 Python wrapper offers a USBPoller class to "allow > > integration of USB event polling in a file-descriptor monitoring event > > loop." The class expects to receive a 'poller' object, again quoting > > from the documentation: > > > > poller is a polling instance implementing the following methods: > > - register(fd, event_flags) > > event_flags have the same meaning as in poll API (POLLIN& > POLLOUT) > > - unregister(fd) > > - poll(timeout) > > timeout being a float in seconds, or None if there is no timeout. > > It must return a list of (descriptor, event) pairs. > > Note: USBPoller is itself a valid poller. > > > > I feel like it should be obvious, but I can't see what would be the > > correct way to integrate this with Twisted. My particular application > > is to enable networking over the ANT+ protocol via a small USB key. > > I've only quickly scanned it, but actually it doesn't look obvious to me > at all. > > I *think* that you want to ignore USBPoller entirely; it looks like it's > some sort of mini reactor thing, although it's not obvious to me how it > ever DOES anything. > > USBContext looks to be the "thing" that you plug in an event loop to. > > However, I'm not certain (perhaps others will comment) that it makes > sense to integrate it into the Twisted event loop - the file descriptor > "ready" events don't seem to trigger corresponding "read" events, and > the USB protocol implementation isn't accessible, so the Twisted model of: > > file ready event -> transport does read -> protocol dataReceived > > ...doesn't really apply. > > It may be just as easy to write wrapper around your protocol in plain > non-Twisted python, and talk to it from Twisted over a > pipe/process/whatever. > > the most simplest way is probably to use another thread to handle all possible events and use twisted's thread functions to leverage the whole system though it is inefficient. > _______________________________________________ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python >
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python