From 8fdb92784a7a430cadd0fe67363e451f6214ee61 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Sun, 27 Feb 2005 22:45:14 +0000 Subject: [PATCH] patch from Ian Abbott : 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. --- testing/cmd_1.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/testing/cmd_1.c b/testing/cmd_1.c index b2b7d2d..e9d337a 100644 --- a/testing/cmd_1.c +++ b/testing/cmd_1.c @@ -163,6 +163,7 @@ int test_cmd_write_fast_1chan(void) unsigned int flags = comedi_get_subdevice_flags(device,subdevice); static const int num_samples = 100000; int num_bytes; + int wc; if((flags & SDF_LSAMPL)) { @@ -197,14 +198,17 @@ int test_cmd_write_fast_1chan(void) 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(retBUFSZ){ + wc = BUFSZ; + } + ret = write(comedi_fileno(device),buf,wc); if(ret<0){ if(errno==EAGAIN){ usleep(10000); -- 2.26.2