Networking Forums

Networking Forums > Computer Networking > Linux Networking > Serial (RS232) communication - failing to detect stop bit

Reply
Thread Tools Display Modes

Serial (RS232) communication - failing to detect stop bit

 
 
arka.n.roy
Guest
Posts: n/a

 
      08-25-2007, 06:45 PM
I need to use my Gentoo machine to obtain data from an external
instrument via a 9-pin serial port. Very old stuff.

It was not working, so I have been trying to diagnose the problem.

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 the setup:

PC-1: Gentoo OS
PC-2: Has partitions for both Windows XP and Xandros Linux.

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?)

 
Reply With Quote
 
 
 
 
Robert Harris
Guest
Posts: n/a

 
      08-25-2007, 07:19 PM
arka.n.roy wrote:
> I need to use my Gentoo machine to obtain data from an external
> instrument via a 9-pin serial port. Very old stuff.
>
> It was not working, so I have been trying to diagnose the problem.
>
> 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 the setup:
>
> PC-1: Gentoo OS
> PC-2: Has partitions for both Windows XP and Xandros Linux.
>
> 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?)
>

Do most characters transfer OK?

Robert
 
Reply With Quote
 
David M
Guest
Posts: n/a

 
      08-26-2007, 12:26 AM
On Sat, 25 Aug 2007 18:45:03 +0000, arka.n.roy rearranged some electrons
to form:


>
> 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.


Not likely. If you were not detecting the stop bits, you would see many
framing errors, not just 2.

>
> 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.


Even old kernels can use serial ports correctly. My guess is that
you have programmed something incorrectly.


Try reading this:

http://tldp.org/HOWTO/Serial-HOWTO.html
http://tldp.org/HOWTO/Serial-Program...WTO/index.html



--
David M (dmacchiarolo)
sled351 Linux 2.4.18-14 has been up 14 days 23:20

 
Reply With Quote
 
arka.n.roy
Guest
Posts: n/a

 
      08-26-2007, 03:40 AM
Robert and David, thanks for your replies.

I have not programmed anything myself, I am using the terminal program
Minicom between the machines. I'm sorry, I left out some key points
so I will summarize it again with the background information:

1) The ultimate objective is to use the Gentoo machine to collect data
from an external instrument (via serial cable cable connection).

2) It didn't work, indicating that there is a problem with serial
communications on that machine. Another factor that points to this
possibility is the fact that we had the same problem on the Gentoo
machine at my client's site. My machine was set up using an HDD image
from his machine so the software environment is the same.

3) In order to diagnose this I bought the cross cable, and set up
Minicom on both machines to see if I can send text (such as "hello
world") back and forth between the machines. Needless to say I have
set the exact same settings (baud, parity, stop bit, flow control,
linefeeds, local echo, etc) on both sides.

4) Characters from PC-2 (the Gentoo box) to PC-1 (the Xandros box)
transfer fine. They show up in Minicom on Xandros. However the
reverse is not the case, nothing I type on Xandros shows up in Minicom
on Gentoo.

5) On the command line of Gentoo I type
# cat /proc/tty/driver/serial
and it tells me the number of bytes transfered by rx and tx.
Both are correct, the tx value is indeed the number of bytes I have
typed on that machine, and the rx value is indeed the number of bytes
I have typed on the Xandros machine. So this indicates the data is
being received, just not showing up in Minicom. I also get fe:2,
which I assume means two frame errors.

6) Some other relevant observations:

- The Xandros PC also has a Windows XP partition, and I tried the
exact same thing on Windows using Hyperterminal. It was the exact
same situation - I could send from Gentoo to Windows but not from
Windows to Gentoo.

- On the Gentoo machine I also tried communicating with the other PC
using MATLAB instead of Minicom. MATLAB is a sophisticated
mathematical modeling package but its command line has some high-level
commands to send and receive from the serial port. Sending was
successful but receiving wasn't, just like in Minicom. In MATLAB when
I would try to receive I would get a message to the effect that it
timed out without detecting a terminator. (this may be the stop bit?)


 
Reply With Quote
 
arka.n.roy
Guest
Posts: n/a

 
      08-26-2007, 05:28 AM
Sorry David, I may have mistakenly pressed "Reply to author" and it
went to you as a mail.

Here it is again, so that everyone can see it.


On Aug 26, 9:26 am, David M <NOS...@nospam.com> wrote:
> On Sat, 25 Aug 2007 18:45:03 +0000, arka.n.roy rearranged some electrons
> to form:
>
>
> > 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.

>
> Not likely. If you were not detecting the stop bits, you would see many
> framing errors, not just 2.
>


When I do a
# cat /proc/tty/driver/serial
I wonder if the "fe:2" that gets displayed really means there were 2
instances of not detecting the stop bit or if it is just a fixed value
that gets displayed if such a thing occurred at all in the last
received data.

I set Minicom to send breaks.
# cat /proc/tty/driver/serial
displays "brk:1" in this case. However it continues to display 1,
even though I continue my experiment (meaning that I continue sending
breaks). This value doesn't increase. I am wondering if the fe value
may be something like this.


> Even old kernels can use serial ports correctly. My guess is that
> you have programmed something incorrectly.
>

This is Minicom, not anything I have programmed. The Gentoo kernel
gets pretty customized when you first set it up. I didn't do it
myself but received it from someone who did, in fact my machine was
set up from an HDD image of his. I am wondering if he made any
mistakes in configuring it... he doesn't seem to know. He is far away
and I have not been able to conduct the same serial port testing on
his machine, but he did the same initial problem as me of not being
able to get data from a measuring instrument via serial connection.

Do you think it is plausible that some kernel (mis)configuration can
cause this?


> Try reading this:
>
> http://tldp.org/HOWTO/Serial-HOWTO.html
> http://tldp.org/HOWTO/Serial-Program...WTO/index.html
>


Thanks!


 
Reply With Quote
 
Robert Harris
Guest
Posts: n/a

 
      08-26-2007, 08:07 AM
arka.n.roy wrote:
> Sorry David, I may have mistakenly pressed "Reply to author" and it
> went to you as a mail.
>
> Here it is again, so that everyone can see it.
>
>
> On Aug 26, 9:26 am, David M <NOS...@nospam.com> wrote:
>> On Sat, 25 Aug 2007 18:45:03 +0000, arka.n.roy rearranged some electrons
>> to form:
>>
>>
>>> 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.

>> Not likely. If you were not detecting the stop bits, you would see many
>> framing errors, not just 2.
>>

>
> When I do a
> # cat /proc/tty/driver/serial
> I wonder if the "fe:2" that gets displayed really means there were 2
> instances of not detecting the stop bit or if it is just a fixed value
> that gets displayed if such a thing occurred at all in the last
> received data.
>
> I set Minicom to send breaks.
> # cat /proc/tty/driver/serial
> displays "brk:1" in this case. However it continues to display 1,
> even though I continue my experiment (meaning that I continue sending
> breaks). This value doesn't increase. I am wondering if the fe value
> may be something like this.
>
>
>> Even old kernels can use serial ports correctly. My guess is that
>> you have programmed something incorrectly.
>>

> This is Minicom, not anything I have programmed. The Gentoo kernel
> gets pretty customized when you first set it up. I didn't do it
> myself but received it from someone who did, in fact my machine was
> set up from an HDD image of his. I am wondering if he made any
> mistakes in configuring it... he doesn't seem to know. He is far away
> and I have not been able to conduct the same serial port testing on
> his machine, but he did the same initial problem as me of not being
> able to get data from a measuring instrument via serial connection.
>
> Do you think it is plausible that some kernel (mis)configuration can
> cause this?
>
>
>> Try reading this:
>>
>> http://tldp.org/HOWTO/Serial-HOWTO.html
>> http://tldp.org/HOWTO/Serial-Program...WTO/index.html
>>

>
> Thanks!
>
>

Try sending with two stop bits and receiving with one stop bit.


Robert
 
Reply With Quote
 
Mark Hobley
Guest
Posts: n/a

 
      08-26-2007, 08:08 AM
arka.n.roy <(E-Mail Removed)> wrote:

> I wonder if the "fe:2" that gets displayed really means there were 2
> instances of not detecting the stop bit or if it is just a fixed value
> that gets displayed if such a thing occurred at all in the last
> received data.


Are you sure that you are displaying raw data, and that neither end are
expecting some form of protocol like kermit, or zmodem on the transmission?

You could try a file transfer using a terminal emulator both ends.

Are the serial ports set to 2400,8,N,1 at both ends?

I have no RS232 setup here, so I am unable to experiment.

One trick that I have used in the past, is to set up a terminal emulator, and
switch off handshaking and the local echo. When you type, you see nothing,
because the typing is supposed to go to the other terminal. Now, short pins
two and three on the far side of your cable, and again type at your terminal.
What you type should now start to appear on your terminal screen, because you
are feeding your transmitted data into the RX pin.

Regards,

Mark.

--
Mark Hobley
393 Quinton Road West
QUINTON
Birmingham
B32 1QE

Email: markhobley at hotpop dot donottypethisbit com

http://markhobley.yi.org/

 
Reply With Quote
 
David M
Guest
Posts: n/a

 
      08-26-2007, 09:50 AM
On Sat, 25 Aug 2007 20:40:13 -0700, arka.n.roy rearranged some electrons
to form:

> Robert and David, thanks for your replies.
>
> I have not programmed anything myself, I am using the terminal program
> Minicom between the machines. I'm sorry, I left out some key points
> so I will summarize it again with the background information:
>
> 1) The ultimate objective is to use the Gentoo machine to collect data
> from an external instrument (via serial cable cable connection).
>
> 2) It didn't work, indicating that there is a problem with serial
> communications on that machine. Another factor that points to this
> possibility is the fact that we had the same problem on the Gentoo
> machine at my client's site. My machine was set up using an HDD image
> from his machine so the software environment is the same.
>
> 3) In order to diagnose this I bought the cross cable, and set up
> Minicom on both machines to see if I can send text (such as "hello
> world") back and forth between the machines. Needless to say I have
> set the exact same settings (baud, parity, stop bit, flow control,
> linefeeds, local echo, etc) on both sides.
>
> 4) Characters from PC-2 (the Gentoo box) to PC-1 (the Xandros box)
> transfer fine. They show up in Minicom on Xandros. However the
> reverse is not the case, nothing I type on Xandros shows up in Minicom
> on Gentoo.
>
> 5) On the command line of Gentoo I type
> # cat /proc/tty/driver/serial
> and it tells me the number of bytes transfered by rx and tx.
> Both are correct, the tx value is indeed the number of bytes I have
> typed on that machine, and the rx value is indeed the number of bytes
> I have typed on the Xandros machine. So this indicates the data is
> being received, just not showing up in Minicom. I also get fe:2,
> which I assume means two frame errors.
>
> 6) Some other relevant observations:
>
> - The Xandros PC also has a Windows XP partition, and I tried the
> exact same thing on Windows using Hyperterminal. It was the exact
> same situation - I could send from Gentoo to Windows but not from
> Windows to Gentoo.
>
> - On the Gentoo machine I also tried communicating with the other PC
> using MATLAB instead of Minicom. MATLAB is a sophisticated
> mathematical modeling package but its command line has some high-level
> commands to send and receive from the serial port. Sending was
> successful but receiving wasn't, just like in Minicom. In MATLAB when
> I would try to receive I would get a message to the effect that it
> timed out without detecting a terminator. (this may be the stop bit?)


I doubt the problem is as complicated as you're making it. As someone
else suggested, try shorting pins 2 & 3 together on the machine in
question to create a local loopback.

What baud rate are you trying to run at? Some hardware will not support
high baud rates? Try slowing it down.

--
David M (dmacchiarolo)

 
Reply With Quote
 
arka.n.roy
Guest
Posts: n/a

 
      09-12-2007, 06:34 PM
OK...

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-20...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!



 
Reply With Quote
 
Robert Harris
Guest
Posts: n/a

 
      09-12-2007, 07:32 PM
arka.n.roy wrote:
> OK...
>
> 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.


All distributions use basically the same kernel and the serial driver is
part of the kernel. But what you describe below is probably the effect
of line buffering in your Linux PC: by default the serial driver
considers a line ended when it receives a Line Feed (0x0A) but Windows
terminates lines by default with carriage returns (0x0D). You can no
doubt get Hyperterminal and/or Minicom to modify their behaviour.

Robert

>
>
> 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-20...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!
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
serial RS232 down writethem Linux Networking 3 09-22-2007 07:04 AM
USB Serial Converters to RS232 Grahame Linux Networking 4 10-04-2004 02:37 AM
USB serial converter to RS232- HELP Please. Grahame Linux Networking 2 10-01-2004 10:59 PM
wireless 9-pin serial/rs232 Dan Irwin Wireless Internet 13 04-06-2004 03:16 AM
Can I share internet over a RS232 serial link from ADSL ? Tom A Windows Networking 9 09-15-2003 03:54 PM



1 2 3 4 5 6 7 8 9 10 11