pyserial question

Grant Edwards invalid at invalid
Fri Jun 19 10:41:53 EDT 2009


On 2009-06-19, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
> On Thu, 18 Jun 2009 14:24:42 +0300, Piter_ <x.piter at gmail.com> declaimed

>> I cant find out how to set "Handshaking RST on TX" in pyserial.
>
> 	Never encountered "RST" mode... "RTS" mode is common.
>
>>From the source -- a port can be initialized with:

[nothing relevent]

> If RTS/CTS is not doing what you need... You may have to go
> very low-level -- programmatically setting and clearing the
> control lines. 

[...]

That's not what wants.  He wants RTS to be automatically
asserted while data is being transmitted, and de-asserted while
data is being received. That feature is called "RTS toggle" in
MS-Window-speak.  The rest of us usually call it half-duplex
RTS control or auto-line-direction or something like that.
Trying to do it manually from user-space is generally futile.
If you're very lucky, you'll be able to get it to work some of
the time on some platforms.

[ example of manually setting/clearing RTS]

> Again, both of those clips are readily viewable by just
> looking at the .py files in the serial package.

AFAIK, pyserial doesn't support RTS toggle -- it's a feature
not supportted my some platforms and/or serial drivers.
However, it is supported by the standard Win32 drivers, so you
can enable it by setting the appropriate values in the DCB
passed SetCommState().  I'm not a windows guy, so you're going
to have to go search the Win32 API docs for details.

You might be able to use pyserial to open the port, then get
the file handle to do whatever low-level configuration tweaks
you want, and then use pyserial to read/write data.

NB: RTS toggle in Windows drivers isn't generally very
    reliable, since it's implemented in software by polling the
    UART status register.  Not all UARTS set the tx shift
    register empty bit at the correct point in time.

-- 
Grant Edwards                   grante             Yow! Like I always say
                                  at               -- nothing can beat
                               visi.com            the BRATWURST here in
                                                   DUSSELDORF!!



More information about the Python-list mailing list