Jean-Paul Calderone <exar...@divmod.com> wrote: > It's true that the serial port support in Twisted isn't the most used > feature. :) These days, serial ports are on the way out, I think. That > said, much of the way a serial port is used in Twisted is the same as the > way a TCP connection is used. This means that the Twisted documentation > for TCP connections is largely applicable to using serial ports. The only > major difference is how you set up the "connection". You can see examples > of using the serial port support here (one of them seems to suggest that > it won't work on Windows, but I think this is a mistake): > > http://twistedmatrix.com/projects/core/documentation/examples/gpsfix.py > http://twistedmatrix.com/projects/core/documentation/examples/mouse.py > > The 2nd to last line of each example shows how to "connect" to the serial > port. These basic documents describe how to implement a protocol. Though > in the context of TCP, the protocol implementation ideas apply to working > with serial ports as well: > > http://twistedmatrix.com/projects/core/documentation/howto/servers.html > http://twistedmatrix.com/projects/core/documentation/howto/clients.html > > You can ignore the parts about factories, since they're not used with serial > ports.
I wrote a serial port to TCP proxy (with logging) with twisted. The problem I had was that twisted serial ports didn't seem to have any back pressure. By that I mean I could pump data into a 9600 baud serial port at 10 Mbit/s. Twisted would then buffer the data for me using 10s or 100s or Megabytes of RAM. No data would be lost, but there would be hours of latency and my program would use up all my RAM and explode. What I wanted to happen was for twisted to stop taking the data when the serial port buffer was full and to only take the data at 9600 baud. I never did solve that problem :-( -- Nick Craig-Wood <n...@craig-wood.com> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list