- From: L.C. Karssen <l.c.karssen_at_phys.uu.nl>
- Date: Fri, 25 May 2007 15:36:30 +0200
On Fri, 2007-05-25 at 11:46 +0200, L.C. Karssen wrote:
> On Fri, 2007-05-25 at 18:00 +0200, Paolo Mantegazza wrote:
> > L.C. Karssen wrote:
> > > On Fri, 2007-05-25 at 01:11 +0200, Paolo Mantegazza wrote:
> > >
> > >>Ciao,
> > >>
> > >>let's reset and see if I got something better, in the sense I likely
> > >>understood a possible mistake of mine after asking to my dept comedi
> > >>experts.
> > >>
> > >>So just try replacing the exsting comedi_dio_bitfield user space wrapper
> > >>with the following:
> > >>
> > >>
> > >>
> > >>RTAI_PROTO(int, comedi_dio_bitfield,(void *dev, unsigned int subdev,
> > >>unsigned int mask, unsigned int *bits))
> > >>{
> > >> int retval;
> > >> unsigned int lbits = *bits;
> > >> struct { void *dev; unsigned long subdev; unsigned long mask;
> > >>unsigned int *bits; } arg = { dev, subdev, mask, &lbits };
> > >> retval = rtai_lxrt(FUN_COMEDI_LXRT_INDX, COMEDI_LXRT_SIZARG,
> > >>_KCOMEDI_DIO_BITFIELD, &arg).i[LOW];
> > >> *bits = lbits;
> > >> return retval;
> > >>}
> > >>
> > >>Notice that the only change is the following:
> > >>unsigned int lbits = *bits;
> > >>
> > >>Reports the result please!
> > >
> > > Hi Paolo,
> > >
> > > Of course! I should have seen that myself. Without the assignment no
> > > bits were ever written (or probably only zeros). That's why calling
> > > bitfield() in my initialisation worked: it sets all bits to zero.
> > > I tested with this new wrapper in rtai_comedi.h and it works perfectly.
> > >
> >
> > What counts is to solve the problem. Just one check more please: can you
> > check if "*bits = lbits;" is useless. After your answer I'll clean it up
> > and commit the fix to the CVS. Thanks.
>
> I don't think it's useless, since comedi_dio_bitfield() can also be used
> to read DIO bits. This is what the comedi docs say about it:
>
> "For each bit in write_mask that is set to 1, the cooresponding bit in
> *bits is written to the digital output channel. After writing all the
> output channels, each channel is read, and the result placed in the
> approprate bits in *bits. The result of reading an output channel is
> undefined."
>
> So in order to return these readings the statement is needed. I will
> check this later this afternoon.
I checked my statement above. When removing the line "*bits = lbits;"
from rtai_comedi.h and configuring the DIO device for reading the bits
that are returned by comedi_dio_bitfield() are rubbish. When the line is
included the returned bits actually reflect the DIO levels.
So, the line should stay.
Lennart.
>
>
> Lennart.
> >
> > Paolo.
> > >
> > > Thanks,
> > >
> > > Lennart.
> > >
> > >
> > >
> > >>
> > >>Paolo.
> >
--
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
L.C. Karssen
Department of Physics and Astronomy
Faculty of Science
Utrecht University
Princetonplein 1
3584 CC Utrecht
The Netherlands
tel.: +31 (0)30-253-2208
fax.: +31 (0)30-253-7468
e-mail: L.C.Karssen_at_phys.uu.nl
www: http://www1.phys.uu.nl/wwwaoud
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Received on 2007-05-25Z12:36:30