13 #include "comedi_test.h"
15 static int comedi_get_cmd_src_mask(comedi_t *it,unsigned int s,comedi_cmd *cmd);
16 static int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd);
17 static int do_continuous(int multiplier);
21 int test_cmd_continuous(void)
25 /* as if doing _one_ infinite loop wasn't slow enough,
26 * we loop through with higher and higher multipliers,
27 * in case the test fails because of latency problems */
29 for(mult=1;mult<1024;mult*=2){
36 static int do_continuous(int multiplier)
40 unsigned int chanlist[1];
45 unsigned long total_secs = 0;
46 struct timeval tv,start_tv;
48 if(comedi_get_cmd_fast_1chan(device,subdevice,&cmd)<0){
49 printf(" not supported\n");
53 cmd.chanlist = chanlist;
55 cmd.stop_src = TRIG_NONE;
58 chanlist[0] = CR_PACK(0,0,0);
61 cmd.scan_begin_arg *= multiplier;
62 printf("multiplier=%d, scan_begin_arg=%d\n",
66 ret=comedi_command(device,&cmd);
68 perror("comedi_command");
70 printf("ret==%d\n",ret);
73 gettimeofday(&start_tv,NULL);
77 ret = read(comedi_fileno(device),buf,BUFSZ);
91 gettimeofday(&tv,NULL);
92 tv.tv_sec-=start_tv.tv_sec;
93 tv.tv_usec-=start_tv.tv_usec;
98 if(tv.tv_sec>total_secs){
101 t=tv.tv_sec+1e-6*tv.tv_usec;
102 printf("%0.3f %d (%g) %d (%g)\n",
114 static int comedi_get_cmd_src_mask(comedi_t *it,unsigned int s,comedi_cmd *cmd)
116 memset(cmd,0,sizeof(*cmd));
122 cmd->start_src = TRIG_ANY;
123 cmd->scan_begin_src = TRIG_ANY;
124 cmd->convert_src = TRIG_ANY;
125 cmd->scan_end_src = TRIG_ANY;
126 cmd->stop_src = TRIG_ANY;
128 return comedi_command_test(it,cmd);
132 static int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd)
136 ret = comedi_get_cmd_src_mask(it,s,cmd);
139 cmd->chanlist_len = 1;
141 cmd->scan_end_src = TRIG_COUNT;
142 cmd->scan_end_arg = 1;
144 if(cmd->convert_src&TRIG_TIMER){
145 if(cmd->scan_begin_src&TRIG_FOLLOW){
146 cmd->convert_src = TRIG_TIMER;
147 cmd->scan_begin_src = TRIG_FOLLOW;
149 cmd->convert_src = TRIG_TIMER;
150 cmd->scan_begin_src = TRIG_TIMER;
153 printf("can't do timed?!?\n");
156 if(cmd->stop_src&TRIG_COUNT){
157 cmd->stop_src=TRIG_COUNT;
159 }else if(cmd->stop_src&TRIG_NONE){
160 cmd->stop_src=TRIG_NONE;
163 printf("can't find a good stop_src\n");
167 ret=comedi_command_test(it,cmd);
170 ret=comedi_command_test(it,cmd);
172 if(ret==4 || ret==0){