PCI-6251 strange input channels reading

I am new to Comedi so please do not punish me too much if i am doing
something wrong.

I downloaded Comedi from CVS yesterday.
I have managed to install comedi and comedilib on 2.6.20-1.2944 kernel
(Fedora 6). I am using PCI-6251.
After I compiled a simple program (see below)-just read all 16 input
channels. It seems like it's working but the readings do not seem right. All
of them are the same and indifferent to any applied voltage to channels.

#include <stdio.h>
#include <comedilib.h>

int subdev = 0;
int range = 0;
int aref = AREF_GROUND;

int main(int argc,char *argv[])
{
comedi_t *cf;
lsampl_t data;
int maxdata,i;
double volts = 0;
comedi_range* crange;

cf=comedi_open("/dev/comedi0");
if (cf==NULL){
    printf("Failed to open device. \n\r");
}else{
    printf("Device opened. \n\r");

for(i=0;i<16;i++){
  maxdata=comedi_get_maxdata(cf,subdev,i);
  crange = comedi_get_range(cf,subdev,i,range);
  if (comedi_data_read(cf,subdev,i,range,aref,&data)==-1)
 {
    printf("Read failed!!! \n\r");
 }
 volts = comedi_to_phys(data,crange,maxdata);
 printf("channel %d: %d %g\n\r",i, data,volts);
}}
return 0;
}

the output is :

Device opened.
channel 0: 32768 0.00015259
channel 1: 32768 0.00015259
channel 2: 32768 0.00015259
channel 3: 32768 0.00015259
channel 4: 32768 0.00015259
channel 5: 32768 0.00015259
channel 6: 32768 0.00015259
channel 7: 32768 0.00015259
channel 8: 32768 0.00015259
channel 9: 32768 0.00015259
channel 10: 32768 0.00015259
channel 11: 32768 0.00015259
channel 12: 32768 0.00015259
channel 13: 32768 0.00015259
channel 14: 32768 0.00015259
channel 15: 32768 0.00015259

Too beautiful to be true ...
The ./inpn example reads exactly the same set of values. I tried
./ao_waveform and it works
- i can see a waveform. ./board_info also works like it should.

In addition i tried to read the same channel 15 times, i thought may be the
problem in multiplexing of channels, but still the same reading.

Any ideas?
Sergey

Received on 2007-04-24Z20:58:20