Re: Serial port latency

Pavel Machek
2001-03-23T11:48:00Z

Hi!

> My program controls a device (a programmer for microcontrollers) via the
> serial port. The program sits in a tight loop, writing a few (typical 6)
> bytes to the port, and waits for a few (typ. two) bytes to be returned from
> the programmer.
>
> The program works, but it is very slow. I use an oscilloscope to monitor the
> serial lines, and notices that there is a large delay between the returned
> data, and the next new command. I really don't know if the delay is on the
> sending or the receiving side (or both).
>
> This is what the program does:
>
> fd=open("/dev/ttyS0",O_NOCTTY | O_RDWR);
>
> tcsetattr(fd,TCSANOW, &tio); /* setting baud, parity, raw mode, etc */
>
> while() {
> write( 6 bytes); /* send command */
> read( 2 bytes); /* wait for reply */
> }
>
>
> The device on the serial port responds in typ. 10 ms, but the software uses
> over 500ms to get the reply and send the next command. Why is this happening ?
> I have a feeling that there is something obvious I am missing (like line
> buffering, but that's a stdio (libc) thing, isn't it ?).

Set HZ=1000 in include/asm/params.h and see if it helps.

Pavel
--
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at discuss@linmodems.org