From 998c091e1e3376da29e46c1efd141c11224b3024 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Fri, 2 Jan 2004 01:16:00 +0000 Subject: [PATCH] doing a retry for the preload write is useless, since the command hasn't started yet. Print a useful error message and exit instead. --- demo/ao_waveform.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/demo/ao_waveform.c b/demo/ao_waveform.c index a37eaa9..0e9f6bc 100644 --- a/demo/ao_waveform.c +++ b/demo/ao_waveform.c @@ -178,16 +178,18 @@ int main(int argc, char *argv[]) } dds_output(data,BUF_LEN); - n=BUF_LEN*sizeof(sampl_t); - while(n>0){ - m=write(comedi_fileno(dev),(void *)data+(BUF_LEN*sizeof(sampl_t)-n),n); - if(m<0){ - perror("write"); - exit(0); - } - printf("m=%d\n",m); - n-=m; + n = BUF_LEN * sizeof(sampl_t); + m = write(comedi_fileno(dev), (void *)data, n); + if(m < 0){ + perror("write"); + exit(1); + }else if(m < n) + { + fprintf(stderr, "failed to preload output buffer with %i bytes, is it too small?\n" + "See the --write-buffer option of comedi_config\n", n); + exit(1); } + printf("m=%d\n",m); ret = comedi_internal_trigger(dev, subdevice, 0); if(ret<0){ -- 2.26.2