fixed comedi_nanosleep(), which did nothing before
authorFrank Mori Hess <fmhess@speakeasy.net>
Fri, 29 Nov 2002 21:27:40 +0000 (21:27 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Fri, 29 Nov 2002 21:27:40 +0000 (21:27 +0000)
comedi_calibrate/other.c

index b4408e148a9a0eaabc1e3aa6178386e3aa1ebc99..75522330627bd6c4ef7510cb6bb4d4dfb4ba1b30 100644 (file)
@@ -18,19 +18,24 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 
 #include <comedilib.h>
-
-
-/* Note that this silently fails if delay >= 100000 */
+#include <unistd.h>
 
 void comedi_nanodelay(comedi_t *dev, unsigned int delay)
 {
        comedi_insn insn;
+       lsampl_t data = delay;
+       int retval;
 
        memset(&insn, 0, sizeof(insn));
        insn.insn = INSN_WAIT;
        insn.n = 1;
-       insn.data = &delay;
+       insn.data = &data;
+       retval = comedi_do_insn( dev, &insn );
+       // fall back on usleep for long delays
+       if( retval < 0 )
+               usleep( delay / 1000 );
 
+       return;
 }