Markus, I wonder if you've seen this really excellent tutorial:
http://krondo.com/?page_id=1327 It is one of the finest tutorials I've seen anywhere on the web, on any topic. In fact, I think the Twisted leadership should put links to this tutorial all over their home page. While the finger "tutorial" is OK, this tutorial is much much much better, actually explaining *why* you make certain classes, etc. Vic On Tue, Sep 14, 2010 at 9:32 AM, Markus Hubig <mhu...@imko.de> wrote: > On Tue, Sep 14, 2010 at 2:08 PM, <exar...@twistedmatrix.com> wrote: > >> See the serialport examples on the website. A couple are linked from >> http://twistedmatrix.com/documents/current/core/examples/. >> > > The examples I found are mouse.py and gpsfix.py and there only listening on > the serial line. It seems that with twisted I have some sort of a thread > running > which will trigger some methods (e.g. dataRecieved) as it reads something > from the serial line. How could I send data then? > > >> You do indeed want a Protocol subclass. > > > Ok I see, and the Protocol subclass provides the dataReceived method!? > > >> The code from your "self.read(7)" line to the end of that loop will >> probably > > end up in a dataReceived method - but note that you'll have to do some > > buffering, as you can't be assured that dataReceived will get called with >> exactly > > the number of bytes you want at a time, so you may have to collect data >> from >> multiple dataReceived calls (likewise you may get more than you want at >> once, and need to split it up). >> > > Hmm ok so I have to design dataReceived() to buffer the received data until > it get's > the whole answer packet and than let it call e.g. packetRecieved() to > process the > packet ... I'm mot sure if this asynchronous approach is what I need, > because the > protocol I'm implementing is strict Master-Slave. > > - Markus > > -- > __________________________________________________________________ > > IMKO Micromodultechnik GmbH > Markus Hubig > System Administration & Development > Im Stoeck 2 > D-76275 Ettlingen / GERMANY > > HR: HRB 360936 Amtsgericht Mannheim > President: Dipl.-Ing. (FH) Kurt Koehler > > Tel: 0049-(0)7243-5921-26 > Fax: 0049-(0)7243-5921-40 > e-mail: mhu...@imko.de > internet: www.imko.de > _________________________________________________________________ > > _______________________________________________ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > > -- “A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.” -- Antoine de Saint Exupéry
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python