rtlinux comedi_poll() and ni_pcimio with continuous DMA

Frank,
Almost a month ago now you wrote
> > > comedi_poll() should work now with the ni_pcimio driver using dma.

Now that I have my system updated to work with the latest version of comedi
and comedilib (CVS from 4-20-2004), I am trying to put comedi_poll() to good
application in my real time interrupt routine and don't fully understand the
return values I am getting

Can you help me make some sense of it?  Comedi Poll is returning a value
of -5.  What does this mean?

Alex

Here is a code fragment from the real-time interrupt routine called every 50
microseconds:

// ---------------- excerpt from real-time interrupt routine ---------
    int ret1, ret2, err, dt;
...
   tv1= clock_gethrtime( CLOCK_REALTIME);
   dt= tv1-tv0;
   ret1= comedi_poll(cm_device,0);
   ret2= comedi_get_buffer_contents(cm_device, 0);
   rtl_printf("rtdma_mod.o: %d, dt= %6d nsec, poll= %d, get_buffer_contents=
%d\n", Count, dt, ret1, ret2);
   tv0= tv1;
   Count++;
   if (ret2!=0)
    comedi_mark_buffer_read(cm_device, 0, ret2);


here's the kernel log output (dmesg) from my real-time interrupt routine

// ------------ part of output from real-time DMA continuous acquisition
routine --------------

rtdma_mod.o: comedi buffer size= 65536 bytes
rtdma_mod.o: comedi buffer address= 0xd09d4000
rtdma_mod.o: command test 1 returned 0
rtdma_mod.o: command test 2 returned 0
comedi: cannot switch shared interrupt to RT priority
rtdma_mod.o: command exec returned 0
rtdma_mod.o: DMA thread: Start Task
rtdma_mod.o: 0, dt=   4096 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 1, dt=  60384 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 2, dt=  47328 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 3, dt=  49312 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 4, dt=  50080 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 5, dt=  50784 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 6, dt=  50400 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 7, dt=  50208 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 8, dt=  49088 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 9, dt=  49984 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 10, dt=  50272 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 11, dt=  48800 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 12, dt=  51552 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 13, dt=  52032 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 14, dt=  54976 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 15, dt=  42624 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 16, dt=  49312 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 17, dt=  50688 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 18, dt=  49504 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 19, dt=  51840 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 20, dt=  49984 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 21, dt=  50656 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 22, dt=  48800 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 23, dt=  49248 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 24, dt=  49696 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 25, dt=  49984 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 26, dt=  49184 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 27, dt=  52000 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 28, dt=  50112 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 29, dt=  49856 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 30, dt=  49376 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 31, dt=  48416 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 32, dt=  50944 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 33, dt=  49632 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 34, dt=  51616 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 35, dt=  50048 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 36, dt=  49632 nsec, poll= -5, get_buffer_contents= 4238
rtdma_mod.o: 37, dt=  87776 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 38, dt=   4352 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 39, dt=  57280 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 40, dt=  49440 nsec, poll= -5, get_buffer_contents= 0
rtdma_mod.o: 41, dt=  51520 nsec, poll= -5, get_buffer_contents= 0
etc
// -------------------------------------------------------------------------
--------

// -------------part of code that initiates continuous dma -------------

 cmd.subdev = 0;
 cmd.flags = 0;
 cmd.start_src = TRIG_NOW;
 cmd.start_arg = 0;
 cmd.scan_begin_src = TRIG_TIMER;
 cmd.scan_begin_arg = 800;
 cmd.convert_src = TRIG_TIMER;
 cmd.convert_arg = 800;
 cmd.scan_end_src = TRIG_COUNT;
 cmd.scan_end_arg = 1;
 cmd.stop_src = TRIG_NONE;
 cmd.stop_arg = 0;
 cmd.chanlist = chanlist;
 cmd.chanlist_len = 1;
 chanlist[0] = CR_PACK(ADC_SUBDEVICE,adc_range,AREF_GROUND);  // channel,
range, aref
 cmd.data=NULL;
 cmd.data_len= dma_map_size*sizeof(sampl_t);

 ret = comedi_command_test(cm_device,&cmd);
 rtl_printf("rtdma_mod.o: command test 1 returned %d\n",ret);

 cmd.chanlist = chanlist;
 cmd.chanlist_len = 1;
 cmd.data=NULL;
 cmd.data_len= dma_map_size*sizeof(sampl_t);

 ret = comedi_command_test(cm_device,&cmd);
 rtl_printf("rtdma_mod.o: command test 2 returned %d\n",ret);
 if(ret)return ret;

 cmd.chanlist = chanlist;
 cmd.chanlist_len = 1;
 cmd.data=NULL;
 cmd.data_len= dma_map_size*sizeof(sampl_t);

 ret = comedi_command(cm_device,&cmd);
 rtl_printf("rtdma_mod.o: command exec returned %d\n",ret);

// -------------------------------------------------------------


> > > ----- Original Message ----- 
> > > From: "Frank Mori Hess" <fmhess_at_users.sourceforge.net>
> > > To: "Alex Fielding" <afielding_at_adelphia.net>; <comedi_at_comedi.org>
> > > Sent: Sunday, March 21, 2004 1:55 PM
> > > Subject: Re: rtlinux dma get_buffer_contents number of bytes
transferred
> > >
> > >
> > > -----BEGIN PGP SIGNED MESSAGE-----
> > > Hash: SHA1
> > >
> > > On Sunday 14 March 2004 10:38 pm, Alex Fielding wrote:
> > > > For example, when I register a comedi callback with TRIG_WAKE_EOS,
> using
> > > > an 800 nsec scan and convert clock, I receive interrupts to the
> callback
> > > > approximately every 34 microseconds - that roughly coincides with a
4K
> > > > block transfer size other posters have discovered.  Setting the
> > > > cmd.flags for TRIG_WAKE_EOS or TRIG_RT has no effect on this
behavior.
> > >
> > > The TRIG_WAKE_EOS command flag, when used from kcomedilib to the ni
> > > drivers, should be fixed now.  End of scan callbacks should have
worked
> > > with the 0.7.68 code though, except you should have been passing the
> > > COMEDI_CB_EOS flag to comedi_register_callback().
> > >
> > > >
> > > > When I setup my own 1 msec (for example) RT thread to poll the DMA
> > > > status of my 800 nsec scan clock, even with a call to comedi_poll()
in
> > > > there, get_buffer_contents() will return 0 fifteen times in a row
> before
> > > > it returns values such as 4020, 15 more 0's then 4032, 17 more 0's
> then
> > > > 4224, 15 more 0's then 3978, etc.
> > >
> > > comedi_poll() should work now with the ni_pcimio driver using dma.
> > >
> > > - -- 
> > > Frank
> > >
> > > -----BEGIN PGP SIGNATURE-----
> > > Version: GnuPG v1.0.6 (GNU/Linux)
> > > Comment: For info see http://www.gnupg.org
> > >
> > > iD8DBQFAXdcM5vihyNWuA4URApjyAJ4zxv0vS+64HBHSvd2TjGLHPWaoEACfVc1F
> > > WmeVxnVX4nCG8vnsAwEpaE8=
> > > =RRri
> > > -----END PGP SIGNATURE-----
> > >
> > > _______________________________________________
> > > comedi mailing list
> > > comedi_at_comedi.org
> > > https://cvs.comedi.org/cgi-bin/mailman/listinfo/comedi
> > >
> >
> >
>

Received on 2004-04-29Z01:50:15