- From: Jan Gukelberger <g.u.g.i_at_gmx.de>
- Date: Fri, 18 Mar 2005 00:13:14 +0100
On Wed, 2005-03-16 at 09:54 -0600, KULECZ, WALTER (JSC-SK) (WLS) wrote:
> I only lurk on comedi list since I ended up not using comedi, but I've an RT
> Linux application that pushes parallel port data (from a gray code optical
> shaft encoder) to a user space application via an RTL FIFO.
>
> Have you looked at using select() in a thread to wake when the FIFO has data
> to read?
> Your main program could do other things while the FIFO reading thread is
> blocked.
>
> If your data rate is low enough your thread will wake for every sample (FIFO
> write in the driver), otherwise you can read the entire FIFO worth every
> time it wakes in a single read and the last data in the array is most
> recent. This read will not block because select only woke thread because
> the FIFO had data to read. Its a very nice way to do things.
Well, my problem is that the DAQ module is pushing samples into the FIFO
much faster than the app can read them from the FIFO.
First, this wasn't a problem since I can make a big FIFO and read the
remaining samples after recording has stopped so I don't lose any
samples.
But now in another thread I need to query the /current/ state of some
ports from time to time. As far as I understand it, I can't
comedi_data_read() them because this way I'd lock the device in
userspace which means that the RT module can't read it and would in
effect completely destroy the module's timing reliability.
So I'm looking for a way for the RTAI module to provide the most recent
sample at any one time to the userspace so that the app can simply do a
single
current_sample = read( $(whatever) );
or something like that.
I think I'll establish a second FIFO and write each sample to both ones.
But before putting the next sample into the CurrentFifo I'd make the RT
module read the previous one itself. That way at any time there is only
the most recent sample in the CurrentFifo:
lsampl_t sample, dummy;
while( !break ) {
comedi_data_read( &sample );
rtf_put( RecordingFifo, sample );
rtf_get( CurrentFifo, &dummy );
rtf_put( CurrentFifo, sample );
rt_task_wait_period();
}
Obviously this isn't really how FIFOs are meant to work, but I didn't
find something substantially better in the RTAI API docs...
> --wally.
>
Thanks for your answer, anyway,
Jan
>
> -----Original Message-----
> From: comedi-admin_at_comedi.org [mailto:comedi-admin_at_comedi.org]On Behalf
> Of Jan Gukelberger
> Sent: Monday, February 28, 2005 7:27 PM
> To: khj_at_cs.appstate.edu
> Cc: Real-Time Application Interface; Control and Measurement Device
> Interface
> Subject: Re: RTAI and COMEDI - Simple Application?
>
>
> [Please direct any answers to the Comedi ML or CC me as I'm not on the
> RTAI ML.]
>
> PPS: I'm still looking for a way to additionally provide the most recent
> sample to the userspace app in a timely manner (because reading all
> samples from the FIFO takes quite a long time).
>
>
Received on 2005-03-17Z23:13:14