Is it possible to use python to get True Full Duplex on a Serial port?


Hendrik van Rooyen

Absolutely false.

No its true, if you open the serial port with the standard open() instead of And it is also true that I was not contradicted in the past. :)
All standard PC serial ports are full-duplex devices.
I know this, and I started the thread because they would not work full duplex
for me.

8< -------------------- pyserial baudot program link -----------------------
Actually, no. Dynamixel servos as used on the latest Bioloid robots
are multidrop serial RS-485. But outside the embedded world, nobody uses
that stuff any more. (Embedded is going Ethernet; it's overkill but
works fine and is now cheap.)

Exactly - it is no longer part of mainstream fashion. We also still use RS-485
because it is cheaper, and we have better control over timing.

I enclose two naive test implementations.
To run them you will need a loopback connector.
One can be made by shorting pin 2 and 3 together on the standard DB9.

The results are illuminating - on my development machine, (dual 64 bit, some
gigs), the last lines look like this:
The quick brown fox jumps over the lazy dog 1023
That took 3.91238284111 seconds - 3.82068636827 Millisecs per record,
261.733077152 recs per sec
The quick brown fox jumps over the lazy dog 1023
That took 3.90402388573 seconds - 3.81252332591 Millisecs per record,
262.293477185 recs per sec

Almost no difference between the two implementations.
This is basically because there is enough processing power to keep the link
running at full speed in both instances.

On the eBox, (486, 400MHz, 128Mb, no FP), the difference is startling:
The quick brown fox jumps over the lazy dog 1023
That took 69.2863521576 seconds - 67.6624532789 Millisecs per record,
14.7792453797 recs per sec

About eighteen times slower than the development machine.
The quick brown fox jumps over the lazy dog 1023
That took 10.391780138 seconds - 10.148222791 Millisecs per record,
98.5394211964 recs per sec

Less than three times slower than the development machine.

The little processor + Slackware + python cannot keep the link busy.
Python, as a character handler, well let us say that it is suboptimal,
because saying that something sucks, sucks.
An almost seven times ratio between the implementations is not to be sneezed

So the conclusions I have come to are the following:

1) Thou shalt not use ordinary python files for serial ports, on pain of
2) Thou shalt strive mightily to minimize python calls, doing all in thy
power to move away from character input to string input.
3) Thou shalt expend real treasure for real processing power as there is no
such thing as a free lunch.

I would like to thank everybody who took the trouble to respond to teach me
the error of my ways.

- Hendrik

Hendrik van Rooyen

That's very interesting. Is the pre-existing "serial" a
version of pyserial that the packager had pre-installed or is
it something else? I didn't know any distributions shipped

I am not too sure now - when I looked in the packages directory over the
weekend it was there. But I am really not sure how it got there - I cannot
recall downloading it myself, but that means nothing as I have been using
this machine for a while now, so it is possible that I did it some time ago
and forgotten about it, without ever using it. Possible, but unlikely. I
would like to think that if I downloaded it, I would have tried it, and then
I would have remembered.

Sorry to be so vague.

Does this help?

hvr@Linuxbox:~> python
Python 2.5.1 (r251:54863, Dec 6 2008, 10:49:39)
[GCC 4.2.1 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.['EIGHTBITS', 'FCNTL', 'FIVEBITS', 'FileLike', 'PARITY_EVEN', 'PARITY_NAMES',
'STOPBITS_TWO', 'Serial', 'SerialBase', 'SerialException', 'SerialTimeoutException',
'TIOCM_RNG', 'TIOCM_RTS', 'TIOCM_RTS_str', 'TIOCM_zero_str', 'VERSION', 'XOFF', 'XON',
'__builtins__', '__doc__', '__file__', '__name__', '__path__', 'device', 'errno', 'fcntl', 'os', 'plat',
'portNotOpenError', 'select', 'serialposix', 'serialutil', 'string', 'struct', 'sys', 'termios', 'writeTimeoutError']'1.27'

- Hendrik

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Latest member

Latest Threads