Change cmd tester to check for Comedi version, and then use
authorDavid Schleef <ds@schleef.org>
Wed, 15 May 2002 19:53:34 +0000 (19:53 +0000)
committerDavid Schleef <ds@schleef.org>
Wed, 15 May 2002 19:53:34 +0000 (19:53 +0000)
SDF_CMD flag.

lib/filler.c
lib/libinternal.h

index fe6410245c6916350681abe0a51d0a093b32a2bd..37382452e400a5437b34a940313e2f567d80bfc8 100644 (file)
@@ -151,28 +151,35 @@ comedi_range *get_rangeinfo(int fd,unsigned int range_type)
 
 static int do_test_for_cmd(comedi_t *dev,unsigned int subdevice)
 {
-       comedi_cmd it;
-       int ret;
+       /* SDF_CMD was added in 0.7.57 */
+       if(dev->devinfo.version_code >= COMEDI_VERSION_CODE(0,7,57)){
+               if(dev->subdevices[subdevice].subd_flags & SDF_CMD)
+                       return 1;
+               return 0;
+       }else{
+               comedi_cmd it;
+               int ret;
 
-       memset(&it,0,sizeof(it));
+               memset(&it,0,sizeof(it));
 
-       it.subdev = subdevice;
-       it.start_src = TRIG_ANY;
-       it.scan_begin_src = TRIG_ANY;
-       it.convert_src = TRIG_ANY;
-       it.scan_end_src = TRIG_ANY;
-       it.stop_src = TRIG_ANY;
+               it.subdev = subdevice;
+               it.start_src = TRIG_ANY;
+               it.scan_begin_src = TRIG_ANY;
+               it.convert_src = TRIG_ANY;
+               it.scan_end_src = TRIG_ANY;
+               it.stop_src = TRIG_ANY;
 
-       ret = ioctl(dev->fd,COMEDI_CMDTEST,&it);
+               ret = ioctl(dev->fd,COMEDI_CMDTEST,&it);
 
-       if(ret<0 && errno==EIO){
-               return 0;
-       }
-       if(ret<0){
-               fprintf(stderr,"BUG in do_test_for_cmd()\n");
-               return 0;
+               if(ret<0 && errno==EIO){
+                       return 0;
+               }
+               if(ret<0){
+                       fprintf(stderr,"BUG in do_test_for_cmd()\n");
+                       return 0;
+               }
+               return 1;
        }
-       return 1;
 }
 
 static int do_test_for_insnlist(comedi_t *dev)
index 41a310508c0aad37cbbceb497a0580fa2fa5fd3b..6b033cd65177875db453e7f89ea212b1b79c645f 100644 (file)
@@ -55,6 +55,8 @@
 
 #define DEBUG(level,format,args...) do{if(__comedi_loglevel>=(level))fprintf(stderr,__FUNCTION__ ": " format, ## args);}while(0)
 
+#define COMEDI_VERSION_CODE(a,b,c) (((a)<<16) | ((b)<<8) | (c))
+
 #define COMEDILIB_MAGIC 0xc001dafe
 
 extern int __comedi_init;