[Twisted-Python] Selectable SerialPort Windows/Linux
mhubig at imko.de
Tue Sep 14 09:32:29 EDT 2010
On Tue, Sep 14, 2010 at 2:08 PM, <exarkun at twistedmatrix.com> wrote:
> See the serialport examples on the website. A couple are linked from
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
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
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
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
the whole answer packet and than let it call e.g. packetRecieved() to
packet ... I'm mot sure if this asynchronous approach is what I need,
protocol I'm implementing is strict Master-Slave.
IMKO Micromodultechnik GmbH
System Administration & Development
Im Stoeck 2
D-76275 Ettlingen / GERMANY
HR: HRB 360936 Amtsgericht Mannheim
President: Dipl.-Ing. (FH) Kurt Koehler
e-mail: mhubig at imko.de
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python