[Twisted-Python] Add serial connection to a daemon

Itamar Turner-Trauring itamar at futurefoundries.com
Thu Feb 7 11:19:42 EST 2013


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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20130207/c7f59e28/attachment.htm 


More information about the Twisted-Python mailing list