Since you do not have flow control, you must set the port recieve speed higher
than the modem connection speed or you can have overrun on recieve path.
When you transmit you'll have to pace it so you don't cause an overrun.
Also make sure where you are echoing the character to will handle a higher
speed than the modem connect speed. You could just be overrunning your console
for instance.
From: "BillBergeron" <>
Date: 2007/07/20 Fri AM 09:20:45 EST
To:
Subject: [ts-7000] Re: troubleshooting COM2 code
I can give you a possible anecdotal answer (as opposed to specific
code) to the problem. In my experience with passing data via the COM
ports, mostly with various modem connections both on the main board
and on the daughter boards, is they quickly overrun the buffer. This
seems to happen with available daemons (pppd), terminal programs
(minicom, microcom) or with code that I have written (well,
modified). Granted, I have little experience in managing data on a
hardware level like this so I may be speaking from ignorance but
maybe this will give you something to think about. And if you happen
to figure it out I would be interested in what you did...
Bill
--- In "lerougegorge" <>
wrote:
>
> I wrote the C program below to echo characters received on COM2
(19200
> 8N1) to the standard out, but I seem to be having the following
> problems:
>
> 1. It always drops the first character.
> 2. It only echoes about 15 - 20 characters (it varies).
> 3. It then outputs some random looking data (e.g. 0x1842C202) and
then
> stops echoing.
>
> I tested this by connecting via telnet and connecting COM2 to my
> computers' serial ports. I tried this on both a windows machine
with
> hyperterm and an Ubuntu machine with Minicom. Anyone have any idea
what
> is wrong?
>
> #include <stdio.h>
> #include <termios.h>
> #include <fcntl.h>
> #include <unistd.h>
>
> int main()
> {
> printf("Echo program starting\n");
>
> //Open COM2
> int fd = open("/dev/ttyAM1", O_RDWR | O_NOCTTY | O_NDELAY);
>
> if(fd <= 0)
> {
> printf("Error, failed to open COM2\n");
> return 0;
> }
>
> //Set for COM2 19200 8N1, non-blocking reads
> struct termios options;
> tcgetattr(fd, &options);
>
> options.c_cflag = CS8 | CLOCAL | CREAD;
> options.c_iflag = IGNPAR;
> options.c_oflag = 0;
> options.c_lflag = 0;
> options.c_cc[VTIME] = 0;
> options.c_cc[VMIN] = 0;
>
> cfsetispeed(&options, B19200);
> cfsetospeed(&options, B19200);
>
> tcflush(fd, TCIFLUSH);
> tcsetattr(fd, TCSANOW, &options);
>
> //Loop indefinitely and echo
> while(1)
> {
> char c;
> if(read(fd, &c, 1) > 0)
> printf("received %c\n", c);
> }
> }
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|