- From: Emily Alden <ealden_at_bates.edu>
- Date: Wed, 30 Oct 2002 23:30:55 -0500
We're using a Lab-PC driver and comdedi_command to take analog input data asynchronosly. When we run this piece of code we find 8020 data points in the buffer (ret, see code below). But, we get a "segmentation fault" after 4340 (i, in code below) data points have been read out from the buffer.
Can anyone help us sort out why we can't read all our data points from this buffer?
Thank you.
Emily Alden
Bates College
//Read the comedi data buffer into data_array[], columns 2 on (array position 1
and on)
go = 1;
while (go) {
ret = read (comedi_fileno (devi), buf, BUFSZ);
printf("ret=%d\n",ret);
if (ret < 0) {
if (errno == EAGAIN)
usleep (10000);
else {
go = 0;
perror ("read");
}
}
else if (ret == 0)
go = 0;
else {
//loop through rows and columns, and use index (i) to keep place in the buffer
i=0 ;
n=0;
while (i < ret ) {
for(m = 1; m < n_chan+1; m++){
//read data from the buffer
data_array[m][n] =
comedi_to_phys (((sampl_t *) buf)[i], comedi_get_range (devi, cai.subdev, channel,
range), 4095);
i++;
printf("i=%d\n",i);
}
n++;
}
}
}
Received on 2002-10-31Z04:30:55