Re: data[] for digital I/O

On Friday 26 October 2007 17:36, jeremy theler wrote:
> that's the first thing I tried, as I also own a pcl711 and have its
> manual, but I can't figure out what this function is doing when checking
> if (data[0]) below

data[0] is a bitmask of all the channels whose output is being changed.  
data[1] is the values the channels are being set to, and is used to read 
back the state of the channels.

> /* Digital port write - Untested on 8112 */
> static int pcl711_do_insn_bits(comedi_device * dev, comedi_subdevice *
> s, comedi_insn *insn,lsampl_t *data)
> {
> 	if(insn->n!=2)return -EINVAL;
>
> 	if(data[0]){
> 		s->state &= ~data[0];
> 		s->state |= data[0]&data[1];
> 	}
> 	if(data[0]&0x00ff)
> 		outb(s->state & 0xff, dev->iobase + PCL711_DO_LO);
> 	if(data[0]&0xff00)
> 		outb((s->state >> 8), dev->iobase + PCL711_DO_HI);
>
> 	data[1]=s->state;
>
> 	return 2;
> }
>

> for example, if I want to put the 4th bit to 1, should I do
>
> $ demo/outp 8

No

> or
>
> $ demo/outp -c 4 1

Yes

-- 
Frank

Received on 2007-10-28Z16:14:43