[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] How to find the exact time, when the serial data arrived?



On Fri, Sep 17, 1999 at 11:23:29AM +0200, E.L. Meijer Eric" wrote:
> On Fri, Sep 17, 1999 at 10:14:28AM +0200, Wojciech Zabolotny wrote:
> > Hi All!
> > 
> > I'm writing an application requiring the exact knowledge of arrival time
> > of serial data (resolution below 0.1 sec is desired).
> > Is there any way to arrange it in the standard Linux kernel, or should I
> > modify the serial driver? (Or even use the RT Linux?)
> 
> You can use gettimeofday, which returns the time in a struct:
> 
>        struct timeval {
>                long tv_sec;        /* seconds */
>                long tv_usec;  /* microseconds */
>        };
> 
> (see the man page)
> I think the real resolution of this is 0.01 seconds.  If that is not
> enough, there is high resolution timer device you can compile into the
> kernel.  If you look for it in the kernel configuration (make xconfig or
> equivalent) you should be able to find it.

Thanks, but the real problem is that I need to know when the serial data
reaches the port, not when my process receives them :-(.
My process may be suspended and other process may be running, when the data
arrives. The delay may be as long as a few seconds (especially in Debian,
when shortly after switching on, it performs the system scans, updatedb and
similar tasks :-) ).
What I really need is an information when the serial interrupt occured.
Probably it could be done by serious modification of the kernel's serial
driver so, that it would buffer not only the arriving chars, but their
arrival time too. (Or writing the own driver...).
I'd like to have a function like this:
int get_char_with_time(timeval * t);
returning the received char, and writing it's arrival time to the structure
t.

-- 
				TIA				
	                      Wojciech M. Zabolotny
	http://www.ise.pw.edu.pl/~wzab  <--> wzab@ise.pw.edu.pl

http://www.gnupg.org  Gnu Privacy Guard - protect your mail & data
                      with the FREE cryptographic system


Reply to: