doing a retry for the preload write is useless, since the command
authorFrank Mori Hess <fmhess@speakeasy.net>
Fri, 2 Jan 2004 01:16:00 +0000 (01:16 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Fri, 2 Jan 2004 01:16:00 +0000 (01:16 +0000)
hasn't started yet.  Print a useful error message and exit instead.

demo/ao_waveform.c

index a37eaa9ad8d3a73f6ed9b0f1f5c7f9058e5e55d7..0e9f6bcc725a03cbd74925d668c42b4e8be33a6a 100644 (file)
@@ -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){