From: Frank Mori Hess Date: Fri, 2 Jan 2004 01:16:00 +0000 (+0000) Subject: doing a retry for the preload write is useless, since the command X-Git-Tag: r0_7_22~103 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=998c091e1e3376da29e46c1efd141c11224b3024;p=comedilib.git doing a retry for the preload write is useless, since the command hasn't started yet. Print a useful error message and exit instead. --- 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){