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

2011-02-03 Thread Albert Brandl
Hi!

On Mon, Jan 31, 2011 at 10:18:00PM -, exar...@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?

> If you can accomplish your goals without making a new kind of IService 
> implementation, then great!

Right now, this is sufficient for my purposes.

Thanks and best regards,

Albert
-- 
Albert Brandl
Weiermayer Solutions GmbH  | Abteistraße 12, A-4813 Altmünster
phone: +43 (0) 720 70 30 14| fax: +43 (0) 7612 20 3 56
web: http://www.weiermayer.com

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


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

2011-02-03 Thread exarkun
On 10:18 am, albert.bra...@weiermayer.com wrote:
>Hi!
>
>On Mon, Jan 31, 2011 at 10:18:00PM -, exar...@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

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] ClientFactory: implementing Request/Response with a persistent connection

2011-02-03 Thread Johann Borck
On 02/03/2011 02:01 AM, Wolfgang Powisch wrote:
> Hello,
>
> I need to talk to a Line-based TCP service from a Twisted Application.
> The remote server will accept requests and send a response.
>
> I do NOT want to open a NEW TCP-Connection for each request.

Hi,
you only have to avoid closing the connection after your first 
request/response pair, which you would otherwise do by calling 
self.transport.loseConnection() in your protocol. Twisted doesn't make 
that decision for you. Of course it also depends on the server/protocol 
supporting it.

Then there's a project called txconnpool at 
http://pypi.python.org/pypi/txconnpool, maybe it does what you want.

regards,
Johann


___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python