From 2a720182e41ed6b2d7dac4f984e55e844c4e6d15 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Sun, 6 Mar 2005 17:42:56 +0000 Subject: [PATCH] added comedi_dio_get_config() --- doc/funcref | 16 ++++++++++++++++ include/comedilib.h | 2 ++ lib/dio.c | 32 ++++++++++++++++++++++++++++++++ lib/version_script | 1 + 4 files changed, 51 insertions(+) diff --git a/doc/funcref b/doc/funcref index 04e25e1..fb68ca0 100644 --- a/doc/funcref +++ b/doc/funcref @@ -576,6 +576,22 @@ Description: If sucessful, 1 is returned, otherwise -1. +Function: comedi_dio_get_config -- query input/output properties of channel +Retval: int +Param: comedi_t * device +Param: unsigned int subdevice +Param: unsigned int channel +Param: unsigned int * direction +Description: + The function comedi_dio_get_config() querys the configuration of + an individual channel + in a digital I/O subdevice (see comedi_dio_config()). + On success, the variable specified by the "direction" pointer will + be set to either COMEDI_INPUT or COMEDI_OUTPUT. + + If sucessful, 0 is returned, otherwise -1. + + Function: comedi_dio_read -- read single bit from digital channel Retval: int Param: comedi_t * device diff --git a/include/comedilib.h b/include/comedilib.h index f5ab0ae..b4905b5 100644 --- a/include/comedilib.h +++ b/include/comedilib.h @@ -141,6 +141,8 @@ int comedi_data_write(comedi_t *it,unsigned int subd,unsigned int chan, unsigned int range,unsigned int aref,lsampl_t data); int comedi_dio_config(comedi_t *it,unsigned int subd,unsigned int chan, unsigned int dir); +int comedi_dio_get_config(comedi_t *it,unsigned int subd,unsigned int chan, + unsigned int *dir); int comedi_dio_read(comedi_t *it,unsigned int subd,unsigned int chan, unsigned int *bit); int comedi_dio_write(comedi_t *it,unsigned int subd,unsigned int chan, diff --git a/lib/dio.c b/lib/dio.c index 3aabb10..def2aba 100644 --- a/lib/dio.c +++ b/lib/dio.c @@ -79,6 +79,38 @@ int _comedi_dio_config(comedi_t *it,unsigned int subdev,unsigned int chan,unsign } } +EXPORT_ALIAS_DEFAULT(_comedi_dio_get_config, comedi_dio_get_config, 0.7.23); +int _comedi_dio_get_config(comedi_t *it,unsigned int subdev, unsigned int chan, unsigned int *io) +{ + subdevice *s; + comedi_insn insn; + lsampl_t data[2]; + int retval; + + if(!valid_chan(it,subdev,chan)) + return -1; + + s=it->subdevices+subdev; + if(s->type!=COMEDI_SUBD_DIO) + return -1; + + if(it->has_insnlist_ioctl == 0) + return -1; + + memset(&insn,0,sizeof(insn)); + insn.insn = INSN_CONFIG; + insn.n = sizeof(data) / sizeof(data[0]); + insn.data = data; + insn.subdev = subdev; + insn.chanspec = CR_PACK(chan,0,0); + data[0] = INSN_CONFIG_DIO_QUERY; + + retval = comedi_do_insn(it,&insn); + if(retval < 0) return retval; + *io = data[1]; + return 0; +} + EXPORT_ALIAS_DEFAULT(_comedi_dio_read,comedi_dio_read,0.7.18); int _comedi_dio_read(comedi_t *it,unsigned int subdev,unsigned int chan, unsigned int *val) diff --git a/lib/version_script b/lib/version_script index 0a67f04..52aba8f 100644 --- a/lib/version_script +++ b/lib/version_script @@ -83,5 +83,6 @@ v0.7.20 { v0.7.23 { global: + comedi_dio_get_config; comedi_mark_buffer_written; } v0.7.20; -- 2.26.2