Markus,<br><br>I wonder if you&#39;ve seen this really excellent tutorial:<br><br><a href="http://krondo.com/?page_id=1327">http://krondo.com/?page_id=1327</a><br><br>It is one of the finest tutorials I&#39;ve seen anywhere on the web, on any topic.<br>
<br>In fact, I think the Twisted leadership should put links to this tutorial all over their home page.  While the finger &quot;tutorial&quot; is OK, this tutorial is much much much better, actually explaining *why* you make certain classes, etc.<br>
<br>Vic<br><br><div class="gmail_quote">On Tue, Sep 14, 2010 at 9:32 AM, Markus Hubig <span dir="ltr">&lt;<a href="mailto:mhubig@imko.de">mhubig@imko.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<font face="courier new,monospace"><span style="font-family: arial;">On Tue, Sep 14, 2010 at 2:08 PM,  <span dir="ltr">&lt;<a href="mailto:exarkun@twistedmatrix.com" target="_blank">exarkun@twistedmatrix.com</a>&gt;</span> wrote:</span><br>

</font><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div>See the serialport examples on the website.  A couple are linked from</div>


<a href="http://twistedmatrix.com/documents/current/core/examples/" target="_blank">http://twistedmatrix.com/documents/current/core/examples/</a>.<br></blockquote><div><br></div><div>The examples I found are mouse.py and gpsfix.py and there only listening on</div>

<div>the serial line. It seems that with twisted I have some sort of a thread running</div><div>which will trigger some methods (e.g. dataRecieved) as it reads something</div><div>from the serial line. How could I send data then?</div>

<div> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
You do indeed want a Protocol subclass. </blockquote><div><br></div><div>Ok I see, and the Protocol subclass provides the dataReceived method!?</div><div> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

The code from your &quot;self.read(7)&quot; line to the end of that loop will probably</blockquote><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
end up in a dataReceived method - but note that you&#39;ll have to do some</blockquote>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">buffering, as you can&#39;t be assured that dataReceived will get called with exactly</blockquote>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
the number of bytes you want at a time, so you may have to collect data from<br>
multiple dataReceived calls (likewise you may get more than you want at<br>
once, and need to split it up).<br></blockquote><div><br></div><div>Hmm ok so I have to design dataReceived() to buffer the received data until it get&#39;s</div><div>the whole answer packet and than let it call e.g. packetRecieved() to process the</div>

<div>packet ... I&#39;m mot sure if this asynchronous approach is what I need, because the</div><div>protocol I&#39;m implementing is strict Master-Slave.</div><div><br></div><div>- Markus</div><div><br></div></div>-- <br>

__________________________________________________________________<br><br>IMKO Micromodultechnik GmbH<br>Markus Hubig<br>System Administration &amp; Development<br>Im Stoeck 2<br>D-76275 Ettlingen / GERMANY<br><br>HR: HRB 360936 Amtsgericht Mannheim<br>

President: Dipl.-Ing. (FH) Kurt Koehler<br><br>Tel: 0049-(0)7243-5921-26<br>Fax: 0049-(0)7243-5921-40<br>e-mail: <a href="mailto:mhubig@imko.de" target="_blank">mhubig@imko.de</a><br>internet: <a href="http://www.imko.de" target="_blank">www.imko.de</a><br>

_________________________________________________________________<br>
<br>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>“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<br><br>