<font face="courier new,monospace"><span class="Apple-style-span" style="font-family: arial; ">On Tue, Sep 14, 2010 at 2:08 PM, <span dir="ltr"><<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>></span> wrote:</span><br>
</font><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">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:0 0 0 .8ex;border-left:1px #ccc solid;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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
The code from your "self.read(7)" line to the end of that loop will probably</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">end up in a dataReceived method - but note that you'll have to do some</blockquote>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">buffering, as you can't be assured that dataReceived will get called with exactly</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;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's</div><div>the whole answer packet and than let it call e.g. packetRecieved() to process the</div>
<div>packet ... I'm mot sure if this asynchronous approach is what I need, because the</div><div>protocol I'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 & 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">mhubig@imko.de</a><br>internet: <a href="http://www.imko.de">www.imko.de</a><br>
_________________________________________________________________<br>