14 #include "comedi_test.h"
16 static int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd);
18 #define N_SAMPLES 10000
20 #define BUFSZ N_SAMPLES*sizeof(sampl_t)
28 unsigned int chanlist[1];
35 if(comedi_get_cmd_fast_1chan(device,subdevice,&cmd)<0){
36 printf(" not supported\n");
40 map=mmap(NULL,MAPLEN,PROT_READ,MAP_SHARED,comedi_fileno(device),0);
42 printf("E: mmap() failed\n");
46 cmd.chanlist = chanlist;
48 cmd.stop_arg = N_SAMPLES;
50 chanlist[0] = CR_PACK(0,0,0);
52 comedi_command(device,&cmd);
57 ret = read(comedi_fileno(device),b,BUFSZ);
70 printf("read %d %d\n",ret,total);
73 if(memcmp(buf,map,total)){
74 printf("E: mmap compare failed\n");
76 printf("compare ok\n");
83 static int comedi_get_cmd_src_mask(comedi_t *it,unsigned int s,comedi_cmd *cmd)
85 memset(cmd,0,sizeof(*cmd));
91 cmd->start_src = TRIG_ANY;
92 cmd->scan_begin_src = TRIG_ANY;
93 cmd->convert_src = TRIG_ANY;
94 cmd->scan_end_src = TRIG_ANY;
95 cmd->stop_src = TRIG_ANY;
97 return comedi_command_test(it,cmd);
101 static int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd)
105 ret = comedi_get_cmd_src_mask(it,s,cmd);
108 cmd->chanlist_len = 1;
110 cmd->scan_end_src = TRIG_COUNT;
111 cmd->scan_end_arg = 1;
113 if(cmd->convert_src&TRIG_TIMER){
114 if(cmd->scan_begin_src&TRIG_FOLLOW){
115 cmd->convert_src = TRIG_TIMER;
116 cmd->scan_begin_src = TRIG_FOLLOW;
118 cmd->convert_src = TRIG_TIMER;
119 cmd->scan_begin_src = TRIG_TIMER;
122 printf("can't do timed?!?\n");
125 if(cmd->stop_src&TRIG_COUNT){
126 cmd->stop_src=TRIG_COUNT;
128 }else if(cmd->stop_src&TRIG_NONE){
129 cmd->stop_src=TRIG_NONE;
132 printf("can't find a good stop_src\n");
136 ret=comedi_command_test(it,cmd);
139 ret=comedi_command_test(it,cmd);
141 if(ret==4 || ret==0){