I was running "comedi_test -v" on my new analog output driver and
noticed that it was getting stuck in a loop during the
"cmd_write_fast_1_chan" test.
It turned out that the test had written more data to the buffer than was
required to complete the acquisition (it was using cmd->stop_src =
TRIG_COUNT) and then got stuck in a loop waiting for the buffer to empty.
The attached patch stops the test_cmd_write_fast_1chan function writing
more data than is required to complete the acquisition.
unsigned int flags = comedi_get_subdevice_flags(device,subdevice);
static const int num_samples = 100000;
int num_bytes;
+ int wc;
if((flags & SDF_LSAMPL))
{
go = 1;
while(go){
- ret = write(comedi_fileno(device), buf, BUFSZ);
+ wc = num_bytes-total;
+ if(wc>BUFSZ){
+ wc = BUFSZ;
+ }
+ ret = write(comedi_fileno(device), buf, wc);
if(ret<0){
perror("write");
return 0;
}
- if(ret<BUFSZ){
+ if(ret<wc){
go = 0;
- break;
}
total += ret;
}
if(verbose)printf("inttrig\n");
- go=1;
+ go=(total<num_bytes);
while(go){
- ret = write(comedi_fileno(device),buf,BUFSZ);
+ wc = num_bytes-total;
+ if(wc>BUFSZ){
+ wc = BUFSZ;
+ }
+ ret = write(comedi_fileno(device),buf,wc);
if(ret<0){
if(errno==EAGAIN){
usleep(10000);