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.]

On Sun, 2005-02-27 at 20:52 -0500, Kenneth Jacker wrote: 
> [Debian sarge/testing; kernel-2.6.8; RTAI/COMEDI from CVS]
> 
> Two years ago I successfully used RTAI 24.x and COMEDI to create
> applications via loadable kernel modules.  Though I've got today's
> versions of RTAI and COMEDI built and installed correctly (I
> believe!), I can't seem to get the entire procedure to work on an
> actual application.
> 
> Does anyone have a simple (maybe just digital I/O), kernel module
> based, RTAI/COMEDI application including scripts to build, load and
> run everything?

I've run through this two months ago and found the lack of compact
example code quite frustrating, too. (Especially in this combination;
RTAI-only is demonstrated nicely in the testsuite apps.)
So I've planned to create and post some sample code myself once I
figured out how to get everything going.
Well, nowadays I seem to have working code but haven't had the time to
extract and test a condensed example in my free time.

But as you ask for it now I'm just attaching the relevant parts of the
module I've wrote. Note that while it should compile and run (assuming
no copy&paste errors) there's no warranty that it does what I intended
it to, i.e. I haven't checked the values read with this code.

It's a RT module meant to partially compensate for the lack of
affordable Comedi-supported DIN streaming devices. It reads the lines of
a DIO subdevice with a fixed sampling rate and pushes the samples into
an RTAI FIFO from where they can be read by an application in userspace.

Note that I use rtai packages from Debian Sarge repository (RTAI v3.1)
and a Measurement Computing PCI-DAS6025 board.

If you want to get a quick overview over the module code you might want
do delete all error handling and debugging output code from the Sample
and __daq_init functions.

For making daq-module start or stop the acquisition a userspace app
issues:
rtf_sem_post( m_iSampleFifo )

Acquired samples are read from the FIFO with:
struct TSample tSample;
iReadSamples = rtf_read_timed( m_iSampleFifo, &tSample,
       sizeof( tSample ),
       m_iSamplingTimeout );


Regards,
Jan

PS: Any comments on the code would be greatly appreciated. 

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-01Z01:27:21