From 4d7d67982653fe913a677db29576f95527fa344c Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Wed, 16 Mar 2005 19:04:59 +0000 Subject: [PATCH] updated version of comedi_get_subdevice_flags() which is capable of returning dynamic flags like SDF_RUNNING or SDF_BUSY --- lib/get.c | 30 +++++++++++++++++++++++++++--- lib/version_script | 1 + 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/get.c b/lib/get.c index 34108a2..88ccd03 100644 --- a/lib/get.c +++ b/lib/get.c @@ -71,15 +71,39 @@ char* _comedi_get_board_name(comedi_t *it) return it->devinfo.board_name; } -EXPORT_ALIAS_DEFAULT(_comedi_get_subdevice_flags,comedi_get_subdevice_flags,0.7.18); -int _comedi_get_subdevice_flags(comedi_t *it,unsigned int subd) +EXPORT_ALIAS_VER(_comedi_get_subdevice_flags_old, comedi_get_subdevice_flags,0.7.18); +int _comedi_get_subdevice_flags_old(comedi_t *it,unsigned int subd) { if(!valid_dev(it)) return 0; - return it->subdevices[subd].subd_flags; } +EXPORT_ALIAS_DEFAULT(_comedi_get_subdevice_flags,comedi_get_subdevice_flags,0.7.23); +int _comedi_get_subdevice_flags(comedi_t *it,unsigned int subd) +{ + comedi_subdinfo *s; + int flags; + int ret; + if(!valid_dev(it)) + return -1; + s = malloc(sizeof(comedi_subdinfo) * it->n_subdevices); + if(s == NULL) + { + __comedi_errno = errno; + return -1; + } + ret = comedi_ioctl(it->fd, COMEDI_SUBDINFO, (unsigned long)s); + if(ret < 0) + { + free(s); + return -1; + } + flags = s[subd].subd_flags; + free(s); + return flags; +} + EXPORT_ALIAS_DEFAULT(_comedi_get_subdevice_type,comedi_get_subdevice_type,0.7.18); int _comedi_get_subdevice_type(comedi_t *it,unsigned int subd) { diff --git a/lib/version_script b/lib/version_script index 52aba8f..c00eec1 100644 --- a/lib/version_script +++ b/lib/version_script @@ -84,5 +84,6 @@ v0.7.20 { v0.7.23 { global: comedi_dio_get_config; + comedi_get_subdevice_flags; comedi_mark_buffer_written; } v0.7.20; -- 2.26.2