On Oct 21, 2013, at 6:57 AM, Robert Voigtländer wrote:

> Thanks for the fast reply.
> I don't yet understand your answer. I may have to dig more into Python.
> 
> On 21 October 2013 13:45, Itamar Turner-Trauring <ita...@itamarst.org> wrote:

<snip guidance to avoid threads>

> 
> 3. A reasonable place for the write() might be in your Protocol's 
> connectionMade method.
> 
> 



The Protocol has access to a .transport attribute, which is the SerialPort() 
instance. 

Therefore, you can write to the serial port (the transport) from within your 
protocol:


class Echo(LineReceiver):

    def connectionMade(self):
        self.transport.write('HELLO\n')

    def lineReceived(self, line):
        self.transport.write(line + '\n')


The connectionMade method will be called once the transport (the SerialPort 
instance) is ready (the serial port is open), making it an appropriate place to 
kick off an init sequence or similar.


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

Reply via email to