All I want to do is connect two PCs by RS232 serial cable (cross
cable), start up the Linux (Unix) console and be able to type messages
to each other.
There are two scenarios:
1) Two Linux machines, in which case I would like to just use the
console.
2) A Linux machine connected to a Windows XP machine. In this case I
would like to use the console on the Linux machine and a terminal
program on Windoze, such as HyperTerminal or Tera Term.
I would just like to send messages back and forth, chat-like, such as
"How are you?" and "I am fine".
I know this sounds useless and antiquated, I just want to do it for
study.
I have not been able to find information through my Googling.
In fact, I find that with HyperTerminal or Tera Term on Windows you
can't even really type. The main window just displays stuff that
arrives.
There are basically two "simple" ways to provide the
functionality you ask about. They are simple only if
you have a *lot* of experience...
The first method is exactly what you have in mind and
have described. First, there is a RS-232 connect
between serial ports on two computers. The RS-232
connection can be about as simple as it gets with just
three wires (TxData on each host is connected to RxData
on the other host, and the third wire is Signal Ground).
Then you need a "terminal program" running on each
computer. HyperTerminal is one such program for
Windows. On a Linux box you can run Seyon, Minicom, or
several others (including just redirecting input and
output of an Xterm, but that is not recommended.)
Normally a terminal program only displays what is
received, and not what is sent. That is because they
expect the distant end to "echo" back whatever is sent.
But the terminal program itself does not echo what it
receives back, of course, and in this case it's two
terminal programs talking to each other. So the trick
is to configure the terminal programs for what is called
"half duplex", which isn't quite what it actually does
do, but that is what the configuration option is called.
What it does is echo everything you send to your own
screen.
A second method is significantly more complicated than
the above simple RS-232 connection, but provides
significantly more flexibility. For example, it would
be entirely possible to have not just two, but many
computers connected this way, all talking to each other
at once. And the connections need not all be via serial
ports, as the exact same user interface is used for an
Internet connection too.
This method is to set up a Point-to-Point Protocol (PPP)
TCP/IP link via the serial port RS-232 connection. The
way to do this is to use the /pppd/ program on a Linux
box, and use the dialup networking configuration on a
Windows box. Neither is a simple project. The first
problem is that the RS-232 connection, and the cable
used, is necessarily a bit more complex. In addition to
the three wires described above, others are required to
deal with this method. A fully functional "Null Modem"
cable will be needed. They can be purchased for a
relatively small price.
Once the two computers have a PPP connection, any
program that uses TCP/IP can be used between them. For
your project you want a /talk/ program. Some of them
are also labeled /ntalk/, or /ytalk/, and I suppose
there are others.
--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) fl...@apaflo.com
>
> There are basically two "simple" ways to provide the
> functionality you ask about. They are simple only if
> you have a *lot* of experience...
>
Alas, that is what it looks like :)
> The first method is exactly what you have in mind and
> have described. First, there is a RS-232 connect
> between serial ports on two computers. The RS-232
> connection can be about as simple as it gets with just
> three wires (TxData on each host is connected to RxData
> on the other host, and the third wire is Signal Ground).
>
So far I am just using a cross-cable. I know the machine are
"talking". This is because I have MATLAB installed on the Linux box,
and it has a pretty high-level language for serial communication. On
the other (Windows) machine I have HyperTerminal running. If I send
"Hello World" from MATLAB on the Linux machine, it actually shows up
in Hyperterminal on the Windows machine.
I guess this means that in terms of physical connection things are
correct as they are, right?
> Then you need a "terminal program" running on each
> computer. HyperTerminal is one such program for
> Windows. On a Linux box you can run Seyon, Minicom, or
> several others (including just redirecting input and
> output of an Xterm, but that is not recommended.)
>
Can I just use the command-line console?
> Normally a terminal program only displays what is
> received, and not what is sent. That is because they
> expect the distant end to "echo" back whatever is sent.
> But the terminal program itself does not echo what it
> receives back, of course, and in this case it's two
> terminal programs talking to each other. So the trick
> is to configure the terminal programs for what is called
> "half duplex", which isn't quite what it actually does
> do, but that is what the configuration option is called.
> What it does is echo everything you send to your own
> screen.
>
So does this mean that if I type something with the focus on
Hyperterminal's main window, it is actually getting "typed", even
though I can't see it? And when I hit return it is actually getting
sent across the serial cable?
The problem was that I was not able to receive this text (e.g. "Hello
to you too") in MATLAB on the Linux machine. I might as well state my
objective at this juncture, I avoided doing so since it may lead the
discussion off-topic, but I want to find out if I am doing something
wrong in MATLAB, or if there is a problem with sending from the
Windows box and receiving on the Linux box. I thought terminals would
be an easy way to check this.
> A second method is significantly more complicated than
> the above simple RS-232 connection, but provides
> significantly more flexibility. For example, it would
> be entirely possible to have not just two, but many
> computers connected this way, all talking to each other
> at once. And the connections need not all be via serial
> ports, as the exact same user interface is used for an
> Internet connection too.
>
> This method is to set up a Point-to-Point Protocol (PPP)
> TCP/IP link via the serial port RS-232 connection. The
> way to do this is to use the /pppd/ program on a Linux
> box, and use the dialup networking configuration on a
> Windows box. Neither is a simple project. The first
> problem is that the RS-232 connection, and the cable
> used, is necessarily a bit more complex. In addition to
> the three wires described above, others are required to
> deal with this method. A fully functional "Null Modem"
> cable will be needed. They can be purchased for a
> relatively small price.
>
> Once the two computers have a PPP connection, any
> program that uses TCP/IP can be used between them. For
> your project you want a /talk/ program. Some of them
> are also labeled /ntalk/, or /ytalk/, and I suppose
> there are others.
>
This sounds interesting, but for now it goes way beyond my objective,
which is to just test the serial communication between the two
machines.
Thanks again, I was pleasantly surprised to get such a thought-out
answer in such a short time!
Arka
At least in that direction. (I'm not familiar with MATLAB.)
Try running minicom on the Linux box first, until you
get the serial port link working as it should. Minicom
will allow you to see something coming from the Windows
box, and it allows you to try just about anything in the
way of configuration.
However, trying to configure minicom's default settings can
be a little tricky. Here is a list of steps that I've posted
a few times in years past:
1) su to root.
2) invoke "minicom -s".
3) set the serial port to ttyS0, set speed, parity, whatever.
4) save the settings to either default, or
to some named configuration, such as "port1".
5) exit minicom.
6) exit root.
7) invoke minicom, as "minicom" to get the default config,
or as "minicom port1" to get the port1 configuration.
>> Then you need a "terminal program" running on each
>> computer. HyperTerminal is one such program for
>> Windows. On a Linux box you can run Seyon, Minicom, or
>> several others (including just redirecting input and
>> output of an Xterm, but that is not recommended.)
>
>Can I just use the command-line console?
It can be done, but trust me that you *do* *NOT* want
to do that!
...
>> "half duplex", which isn't quite what it actually does
>> do, but that is what the configuration option is called.
>> What it does is echo everything you send to your own
>> screen.
>>
>
>So does this mean that if I type something with the focus on
>Hyperterminal's main window, it is actually getting "typed", even
>though I can't see it? And when I hit return it is actually getting
>sent across the serial cable?
It should be. It probably is being sent one character at
at time as it is being typed (rather than as a line when
you hit return).
>The problem was that I was not able to receive this text (e.g. "Hello
>to you too") in MATLAB on the Linux machine.
But using MATLAB we don't know what isn't working. So
you'll need to test it with something more flexible to
start with.
>I might as well state my
>objective at this juncture, I avoided doing so since it may lead the
>discussion off-topic, but I want to find out if I am doing something
>wrong in MATLAB, or if there is a problem with sending from the
>Windows box and receiving on the Linux box. I thought terminals would
>be an easy way to check this.
Exactly true. Test using a terminal program (one
designed for use with serial ports, which the system
console is not).
>Thanks again, I was pleasantly surprised to get such a thought-out
>answer in such a short time!
Help on Usenet is crap shoot. :-)
Here is how things have gone since then.
I bought a cable that is called a "cross cable" in Japan (where I am
located), I think this corresponds to what is called a "null-modem
cable" in America. Both ends are female, and it is used to directly
connect 2 PCs.
So here is my setup:
PC-1: Gentoo OS
PC-2: Has partitions for both Windows XP and Xandros Linux.
I installed Minicom on PC-1
On PC-2, in Xandros I also installed Minicom. In the Windows side I
use Hyper Terminal.
I connected the PCs, started up the terminal programs on both boxes,
and would type messages such as "Hello World".
Whether I used Xandros or Windows on PC-2, the result was always the
same: I could send messages from PC-1 and it would show up in the
terminal program of PC-2, however the other way round never worked.
Nothing I ever typed in PC-2 showed up in PC-1.
On both machines I checked the serial port permissions. The Xandros
machine result was as below.
[code]
# ls -l /dev/ttyS0
crw-rw-rw- 1 root tty 4, 64 Aug 24 16:31 /dev/ttyS0[/code]
However in the case of the Gentoo machine, the permissions were as
follows:
crw-rw----
I set them to crw-rw-rw- using chmod, to be the same as the Xandros
setting. It didn't help anything.
Grasping for straws, I even disconnected the cross cable from the
computers, and reconnected reversing the ends. Still no luck.
Is it possible that the Gentoo OS is set up in such a way that it can
send from the serial port and not receive? Does this kind of thing
happen? :oops: Does anyone know where I should look next?
(As for the possibility that the problem lies in PC-2, in that it can
receive and not send, well, I am disinclined to think that since the
results were the same whether or not the OS was Xandros or Windows.
Mind you, whether it is running Xandros or Windows, it is still the
same box and consequently using the same physical serial port)
I have narrowed things down to where I realize I am getting the
following.
If I run the following command on the Gentoo machine (PC-1):
cat /proc/tty/driver/serial
I get, along with the number of bytes transfered by rx and tx, I also
get fe:2, which I assume means two frame errors.
The rx figure is correct in that it jives with the number of bytes I
sent from PC-2... this indicates that the Gentoo machine IS receiving
data. However maybe the fe:2 means that it is not detecting the stop
bits, and this is preventing it from displaying output text in
minicom.
I have checked and rechecked that all the settings (bit rate, parity
etc) all match on both machines. I am wondering if there is some
factor in the kernel that is making it not recognize the stop bit. I
have had other indications as well that a stop bit or a terminator is
not being detected (long story). What are some possible causes?
(e.g. the OS is doing too much interrupting or not enough?)
I have come to the conclusion that there is something fishy about the
serial driver in Gentoo. Below I describe the tests that led me to
this conclusion.
I conducted a series of chat tests between 2 machines, PC-1 and PC-2,
using terminal software on both machines and connected the serial
ports of the PCs using an RS232 cross cable (this may be called a NULL
modem cable in some regions).
PC-1 has Gentoo Linux installed. PC-2 has 3 partitions: Windows XP,
Windows 2000, and Xandros Linux.
The terminal software used was Minicom on Gentoo, and HyperTerminal on
Windows.
The connection settings on both sides were as follows.
-------------------
Bit rate: 9600
Data size: 8 bit
Parity: none
Stop bits: 1
Flow control: none
In short form: 9600, 8N1
-------------------
I tested to see if text typed in the terminal of one machine properly
showed up in the other machine or not. I also made use of the
following Linux (Unix) command to view the number of bytes sent (tx)
and received (rx):
# cat /proc/tty/driver/serial
Here are my test results
(1) Gentoo Linux and Windows XP
PC-1: Ran Gentoo Linux off HDD, used Minicom
PC-2: Ran Windows XP off HDD partition, used HyperTerminal
Results:
FAILURE :(
Text typed on PC-1 is correctly displayed on PC-2. However text typed
on PC-2 is NOT displayed on PC-1.
Using # cat /proc/tty/driver/serial on PC-1, I could see that the
number of received bytes was increasing correctly. So the bytes from
PC-2 are being received, just not showing up in Minicom.
(2) Gentoo Linux and Windows 2000
PC-1: Ran Gentoo Linux off HDD, used Minicom
PC-2: Ran Windows 2000 off HDD partition, used HyperTerminal
Results:
FAILURE :(
Exactly the same results as in test (1).
(3) Gentoo Linux and Xandros Linux
PC-1: Ran Gentoo Linux off HDD, used Minicom
PC-2: Ran Xandros Linux off HDD partition, used Minicom
Results:
FAILURE :(
Exactly the same results as in test (1).
... Now at this point, if you are starting to suspect a hardware issue
on PC-1, this is where things get interesting and I prove this is not
the case!
(4) Knoppix Linux and Xandros Linux
PC-1: Ran Knoppix Linux off a live CD, used Minicom
PC-2: Ran Xandros Linux off HDD partition, used Minicom
Results:
SUCCESS!!! :)
Everything typed on one machine shows up in the other machine's
terminal. This indicates that the hardware on PC-1 is fine.
(5) Ubuntu Linux and Xandros Linux
PC-1: Ran Ubuntu Linux off a live CD, used Minicom
PC-2: Ran Xandros Linux off HDD partition, used Minicom
Results:
SUCCESS!!! :)
Results identical to test (4) above.
... Now, to make sure that it is not a problem with the way I have
installed Gentoo, I used a live CD version of Gentoo from the CD
enclosed in a recent book, Linux Bible 2007 Edition, which should have
much more credibility than my own installation (since I am a newbie,
and those guys are authors). In fact, here is the book:
http://www.amazon.com/Linux-Bible-2007-KNOPPIX-Distributions/dp/0470082798/
(5) Gentoo Linux from live CD and Xandros Linux
PC-1: Ran Gentoo Linux off a live CD, used Minicom
PC-2: Ran Xandros Linux off HDD partition, used Minicom
Results:
FAILURE :(
Results identical to test (1) above. So the live CD Gentoo is
behaving the same way as my own Gentoo installation.
(6) Gentoo Linux and Windows 2000, on seperate machines at my client's
site.
FAILURE :(
I asked my client to do exactly what I did in test (2) above, using
their machines. The results were exactly the same as my test (2)
results, which further reinforce the probability that I don't have a
hardware problem and that my Gentoo installation is not the problem.
So this leaves me with the conclusion that there is something flawed
in Gentoo itself.
I am not very knowledgeable about serial drivers. I would like to
compare the serial driver versions between my Gentoo machine and my
Xandros machine (as well as the versions of the serial drivers in the
live CD Knoppix and Ubuntu). Does anyone know what specific files I
need to look at and compare?
Also, does anyone have any idea as to how I should go about solving
this problem? I need to have proper serial data receive functionality
on my Gentoo machine, since that will be used to get data from a
measuring instrument.
Thanks!
> I have come to the conclusion that there is something fishy about the
> serial driver in Gentoo. Below I describe the tests that led me to
> this conclusion.
Please don't multi-post. I already responded to this same
posting in a different group.
--
Grant Edwards grante Yow! VICARIOUSLY experience
at some reason to LIVE!!
visi.com