[Twisted-Python] Using SerialPort with t.a.s.Application

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Thu Feb 3 12:00:39 MST 2011


On 10:18 am, albert.brandl at weiermayer.com wrote:
>Hi!
>
>On Mon, Jan 31, 2011 at 10:18:00PM -0000, exarkun at twistedmatrix.com 
>wrote:
>>
>>I think that now the way it would make sense to add this is to add a
>>serialport endpoint.  This would be usable with
>>twisted.internet.endpoints.serverFromEndpoint (or clientFromEndpoint, 
>>I
>>can never remember which one a serial port is more like).
>
>Cool. I think you talked about serverFromString, but this was enough to
>get me started. I've added the necessary functions and classes so that 
>I
>can create a server listening to the serial line with something like:
>
>    serial_server = strports.service("SERIAL:/dev/ttyS0:baudrate=38400")
>
>But injecting the necessary functions and classes into t.i.endpoints is
>rather ugly. Would it be ok to create a ticket to properly enhance the
>module with an endpoint encapsulating SerialPort?

That probably makes sense, but first, does the endpoints string 
description plugin API help?  You can provide 
IStreamServerEndpointStringParser (defined in 
twisted.internet.interfaces) plugins to extend the parser for those 
strings.  This might clean things up your serial port endpoint is 
actually included in a release of Twisted.

There are some tickets filed already for adding some other kinds of 
endpoints (eg an IPv6 endpoint - 
http://twistedmatrix.com/trac/ticket/4470), but it doesn't look like 
there's one for serial port, so yea - it would be great if you could 
file that one.

Jean-Paul




More information about the Twisted-Python mailing list