[Twisted-Python] Re: python-list query re sockets, select or: twisted and other file-descriptors & twisted question

Andrew Bennetts andrew-pythonlist at puzzling.org
Sun Nov 30 02:08:53 EST 2003


On Sat, Nov 29, 2003 at 08:26:50PM -0800, John Benson wrote:
> 
> So, select might not yet work on Windows serial ports as well as sockets.

That's correct.  Windows select is from the Winsock library, and only works
with sockets.

> This is also a subject of interest to me, but all I can think of is handling
> the sockets via select() and polling periodically for data on the serial
> port using callLater() and some win32 calls. Maybe the win32 serial port
> handling could even be wrapped in a 'waitable object' as described above for
> use with the Python select() call.

Thankfully, pySerial has already taken care of the details of cross-platform
serial-port access (apparently, I've never used it):

    http://pyserial.sourceforge.net/

> I recall reading somewhere that the twisted framework has the ability to
> handle serial communications in connection with Global Positioning System
> device interaction, but don't have any information about it. I'm going to
> post this to the twisted mailing list :
> 
> Question for twisted folks: How can I add serial Windows serial port
> communications as a twisted protocol? Please cross-post back to the
> python-list.

Twisted uses pySerial, so the platform you're running Twisted on shouldn't
matter.  There are some examples in the doc/examples directory of Twisted
that use the serial port:

    mouse.py -- example using MouseMan protocol with the SerialPort
                transport
    gpsfix.py -- example using the SerialPort transport and the NMEA 0183
                 and Rockwell Zodiac GPS protocols to display fix data as it
                 is received from the device.

-Andrew.





More information about the Twisted-Python mailing list