[Twisted-Python] Add serial connection to a daemon

Joel Tremblet joel.tremblet at openflyers.com
Thu Feb 7 22:33:42 EST 2013


Thank you, It works
Twisted is so simple !
:-)

Joël

Le Thu, 7 Feb 2013 11:19:42 -0500 Itamar Turner-Trauring  
<itamar at futurefoundries.com> a écrit :

> On Wed, Feb 6, 2013 at 10:29 PM, Joel Tremblet <joel.tremblet at openflyers.com
>> wrote:
>
>>
>> Can I integrated this serial connection into my daemon
>>
>
> You want to make a custom service:
>
> from twisted.application.service import Service
> from twisted.internet import reactor
>
> class CommandService(Service):
>     def startService(self):
>         reactor.listenTCP(8001, tcpfactory)
>         SerialPort(USBClient(tcpfactory), COM_PORT, reactor,
> baudrate=BAUD_RATE)
>
> and now you can add an instance of this service to the Application in your
> .tac file, e.g.:
>
> CommandService().setServiceParent(application)
>



More information about the Twisted-Python mailing list