serial port communication problem with null modem

serial port communication problem with null modem

Post by prakas » Fri, 18 Feb 2005 23:56:24



I am trying to establish a connection b/w port1 and port2 ( com ports
of PC)
/dev/sttyS0 and dev/sttyS1

I am able to do initial configuration as opening port communications
properly for both the ports
I have two different programs
swrite.c
sread.c
for writing and reading simultaneously from port1 to port2 or vice
versa

but I am unable to see the data coming from port 1 to port 2 when the
lenght of string wrriten oat one end exceeds 16 characters.

sometimes the configuration with baud rates as 19200 and 9600 does not
work at all.
I am very much Puzzeled..
want HELP !!!!!!!!!!!!ASAP

 
 
 

serial port communication problem with null modem

Post by Floyd L. Davids » Sat, 19 Feb 2005 01:09:33



>I am trying to establish a connection b/w port1 and port2 ( com ports
>of PC)
>/dev/sttyS0 and dev/sttyS1

Generally, data sent via a serial port on one computer is not
synchronized to the cpu of receiving computer, but when you send
and receive with ports on the same computer, the cpu necessarily
services each in a sequential order and can never do both at the
same time.  The two ports are timed in lock step...

For that reason it is never a good idea to develop serial port
code using a connection between two ports on the same computer.
As soon as you move the code to two distinct computers,
everything relating to timing changes...

Quote:>I am able to do initial configuration as opening port communications
>properly for both the ports
>I have two different programs
>swrite.c
>sread.c
>for writing and reading simultaneously from port1 to port2 or vice
>versa

>but I am unable to see the data coming from port 1 to port 2 when the
>lenght of string wrriten oat one end exceeds 16 characters.

Very likely your code would appear to "work" as you expect if it
ran on two distinct computers, though perhaps not.  It's more
difficult to read "x or more" data bytes from a serial port than
it is to read "x or fewer".

For example, if the send port is being given 16 bytes max per
interrupt, between interrupts the receive side will see 16 bytes
max per call to read.  At that point the CPU goes through the
cycle again.  Hence you get data in 16 byte chunks.  On a pair
of computers...  you might see 16 on one read, and 64 on the
next!  If the sending system is servicing the serial port more
frequently than the receiving system is, most reads will produce
larger numbers of bytes, though obviously it could also be
exactly the other way around too!

Quote:>sometimes the configuration with baud rates as 19200 and 9600 does not
>work at all.
>I am very much Puzzeled..
>want HELP !!!!!!!!!!!!ASAP

The only way anyone can help debug your code is if you make the
code available.  If you can make it small enough, post the
pertinent parts.  If not, put it on a web page, and post a URL.

(Is this code for HPUX, or for Linux?  You've posted to an odd
set of newsgroups...)

--
Floyd L. Davidson           <http://web.newsguy.com/floyd_davidson>


 
 
 

serial port communication problem with null modem

Post by Alex van Denze » Sat, 19 Feb 2005 05:04:01




>>I am trying to establish a connection b/w port1 and port2 ( com ports
>>of PC)
>>/dev/sttyS0 and dev/sttyS1

> Generally, data sent via a serial port on one computer is not
> synchronized to the cpu of receiving computer, but when you send
> and receive with ports on the same computer, the cpu necessarily
> services each in a sequential order and can never do both at the
> same time.  The two ports are timed in lock step...

I have had success using two minicom sessions on the same PC with a
null-modem cable between the two serial ports (neither Linux nor HP-UX,
but NetBSD, but that's not the point).

--
Alex.

 
 
 

serial port communication problem with null modem

Post by Bryan Batte » Sat, 19 Feb 2005 07:34:59



> ...
> but I am unable to see the data coming from port 1 to port 2 when the
> lenght of string wrriten oat one end exceeds 16 characters.

> sometimes the configuration with baud rates as 19200 and 9600 does not
> work at all.
> I am very much Puzzeled..
> want HELP !!!!!!!!!!!!ASAP

Are you checking the return from the write() to see how many
characters are actually sent? In general, successfully completing an
I/O simply means that at least one, and at most the number of
characters requested, is transferred.

B

 
 
 

serial port communication problem with null modem

Post by Floyd L. Davids » Sat, 19 Feb 2005 10:21:52





>>>I am trying to establish a connection b/w port1 and port2 ( com ports
>>>of PC)
>>>/dev/sttyS0 and dev/sttyS1
>> Generally, data sent via a serial port on one computer is not
>> synchronized to the cpu of receiving computer, but when you send
>> and receive with ports on the same computer, the cpu necessarily
>> services each in a sequential order and can never do both at the
>> same time.  The two ports are timed in lock step...

>I have had success using two minicom sessions on the same PC
>with a null-modem cable between the two serial ports (neither
>Linux nor HP-UX, but NetBSD, but that's not the point).

Sure, but minicom is well written... and was developed using
two separate computers.

The point is not that you can't do it; just that if you develop
software (and particularly if you are learning how serial port
data comm works at the same time), what you'll find with two
ports on one system is a *very different* beast than what you'll
find using two completely different systems.

--
Floyd L. Davidson           <http://web.newsguy.com/floyd_davidson>

 
 
 

serial port communication problem with null modem

Post by prakas » Sat, 19 Feb 2005 20:04:31


I am trying to establish a connection b/w port1 and port2 ( com ports
of PC)
/dev/sttyS0 and dev/sttyS1

I am able to do initial configuration as opening port communications
properly for both the ports
I have two different programs
swrite.c
sread.c
for writing and reading simultaneously from port1 to port2 or vice
versa

but I am unable to see the data coming from port 1 to port 2 when the
lenght of string wrriten oat one end exceeds 16 characters.

sometimes the configuration with baud rates as 19200 and 9600 does not
work at all.
I am very much Puzzeled..
want HELP !!!!!!!!!!!!ASAP

 
 
 

serial port communication problem with null modem

Post by Laurenz Alb » Sat, 19 Feb 2005 20:36:39



<snip exactly the same stuff he posted recently>

Go away!

Laurenz Albe