From: David Schleef Date: Mon, 18 Mar 2002 21:48:14 +0000 (+0000) Subject: added output command test X-Git-Tag: r0_7_19~77 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b7d115eafaebd378f39a74b6cf203dbf2d239007;p=comedilib.git added output command test --- diff --git a/testing/cmd_1.c b/testing/cmd_1.c index 404905c..de40842 100644 --- a/testing/cmd_1.c +++ b/testing/cmd_1.c @@ -152,6 +152,90 @@ int test_cmd_read_fast_1chan(void) return 0; } +int test_cmd_write_fast_1chan(void) +{ + comedi_cmd cmd; + char buf[BUFSZ]; + unsigned int chanlist[1]; + int go; + int total=0; + int ret; + unsigned int flags = comedi_get_subdevice_flags(device,subdevice); + + if(!(flags&SDF_CMD) || !(flags&SDF_WRITEABLE)){ + printf("not applicable\n"); + return 0; + } + + if(comedi_get_cmd_generic_timed(device,subdevice,&cmd,1)<0){ + printf(" not supported\n"); + return 0; + } + + if(realtime)cmd.flags |= TRIG_RT; + cmd.chanlist = chanlist; + cmd.scan_end_arg = 1; + cmd.stop_arg = 1000000; + cmd.chanlist_len = 1; + chanlist[0] = CR_PACK(0,0,0); + + memset(buf,0,BUFSZ); + + ret = comedi_command(device,&cmd); + if(ret<0){ + perror("comedi_command"); + } + + go = 1; + while(go){ + ret = write(comedi_fileno(device), buf, BUFSZ); + if(ret<0){ + perror("write"); + return 0; + } + if(ret