CR_CHAN in di_rbits function

We have written a driver for a digital input card and it appears that no 
matter what we try the driver always receives channel 0 as the channel 
to be read when using CR_CHAN.  Below is the application used to test 
the driver:

> #include <stdio.h>				/* for printf() */
> #include <comedilib.h>
> 
> unsigned int cSubDev = 0;	/* change this to your input subdevice */
> unsigned int chan = 4;		/* change this to your channel */
> 
> int main(int argc,char *argv[])
> {
> 	comedi_t *cDev;
> 	unsigned int chanStatus = 0, ret = 0;
> 	int stype;
> 	double minRange, maxRange, volts;
> 
> 	cDev = comedi_open("/dev/comedi2");
> 	if(!cDev)
> 	{
> 		printf("Comedi Open Failed 2\n");
> 		return 0;
> 	}
> 	
> 	for (chan = 1; chan < 16; chan++)
> 	{
> 		ret = comedi_dio_config(cDev, cSubDev, chan, COMEDI_INPUT);	// Configure all channels as Input
> 		printf("Chan%2d: Return -> %4d\n", chan, ret); 
> 	}
> 
> 	/*
> 	for (chan = 0; chan < 16; chan++)
> 	{
> 		ret = comedi_dio_read(cDev, cSubDev, chan, &chanStatus);
> 		printf("Channel->%d:\tStatus->%d\n", chan, chanStatus);
> 	}*/
> 
> 	comedi_close(cDev);
> 	return 0;
> }

The digital input function is very basic:

> static int my_di_rbits(dev, s, insn, data)
> 	comedi_device *dev;
> 	comedi_subdevice *s;
> 	comedi_insn *insn;
> 	lsampl_t *data;
> {
> 	int i, ret;
> 	unsigned int channel;
> 	lsampl_t sample = 0;
> 
> 	channel = CR_CHAN(insn->chanspec);
> 	printk("my_di_rbits:\tChannel %d\tinsn->n = %d\n", channel, insn->n);
> return(2);
> }

The system log always prints channel 0.  Any suggestions?

Bob

Received on 2007-04-04Z03:57:00