13 #include "comedi_test.h"
18 int test_read_select(void)
22 unsigned int chanlist[1];
29 struct timeval timeout;
32 flags = comedi_get_subdevice_flags(device,subdevice);
33 if(!(flags&SDF_CMD) || (comedi_get_read_subdevice(device)!=subdevice)){
34 printf("not applicable\n");
38 if(comedi_get_cmd_generic_timed(device, subdevice, &cmd, 1, 1)<0){
39 printf("E: comedi_get_cmd_generic_timed failed\n");
43 if(realtime)cmd.flags |= TRIG_RT;
45 cmd.chanlist = chanlist;
47 cmd.stop_arg = length;
49 chanlist[0] = CR_PACK(0,0,0);
51 //fcntl(comedi_fileno(device),F_SETFL,O_NONBLOCK);
53 comedi_command(device,&cmd);
58 FD_SET(comedi_fileno(device),&rdset);
60 timeout.tv_usec = 10000;
61 ret = select(comedi_fileno(device)+1,&rdset,NULL,NULL,&timeout);
65 if(verbose)printf("timeout\n");
67 ret = read(comedi_fileno(device),buf,BUFSZ);
68 if(verbose)printf("read==%d\n",ret);
71 printf("E: got EAGAIN!\n");