Re: Timing serial events precisely.

Ian Stirling (root@mauve.demon.co.uk)
Fri, 26 Nov 1999 16:10:00 +0000 (GMT)


>
> > > To do this, I need to get a series of bytes/overruns/parity errors/...
> > > from the serial port, with accurate timing (to within 10us or so, if
> > > possible)
> > > AIUI, a userspace solution is impossible.
> >
> > I would believe you are correct.
>
> I'm curious why. it's not hard to do us-resolution stuff in user-space,
> albeit busy-waiting and at RT priority. I've done this extensively,
> using rdtsc, synchronizing with video retrace, banging the parallel, serial
> and game ports directly.

I'll explain what I need more fully.

> > > I suspect something heavily borrowing from the serial driver, which
> > > instead of returning bytes, returned arrays of timestamps+events.
> >
> > Maybe. You might actually want to bitbang the hardware and also look at
> > using RTLinux for it. I dont think its going to be trivial
>
> oh, perhaps you meant responding to many interrupts separated by
> only microseconds...

I am.

I'm trying to recieve (at least well enough to learn, possibly not well
enough to recieve from a distance) standard TV/video remote controll signals,
through the uart that's connected to all IRDA ports.

On a few, this uart can also do direct reception, but not on all (or
even a majority, or more importantly, my hardware).

The data is in the form of a 40Khz squarewave, pulsed on and off to signal.
When this is recieved by the UART, connected to an IR reciever, it
recieves various characters, (A single keypress generates around 500
bytes, at 115200 (N81), some framing errors, mostly [#' "] )

If these data bytes arrival are timed, then the original pulsed squarewave
can be reconstructed.

Ideally, the timing would be under 10us or so, as this would let the
phase of the 40Khz signal be tracked, enhancing reliability.
It must certainly be under .5ms, as much more will degrade the signals
readability.

I need times for each byte, so the fifo can't be used, but on the other
hand, if a few percent of the chars get lost, it's not a big problem.
I want this to be useable.

Unfortunately, there is no portable way of (on a 16550, or similar)
asking what the current input state is.

Transmitting the IR code back is simple.
Just send a serial bitstream, with the squarewave encoded into it.
Though there will be a lot of noise, IR recievers are designed to
cope with a lot of noise, and there will be enough signal hitting
the recievers passband to activate it.

I'd want this to be useable on someones PC, without rebooting, or
complex setup, so RTlinux is out.

> regards, mark hahn.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/