diff --git a/c++/include/comedilib.hpp b/c++/include/comedilib.hpp index 4bce827..0df1f95 100644 --- a/c++/include/comedilib.hpp +++ b/c++/include/comedilib.hpp @@ -167,6 +167,8 @@ namespace comedi class subdevice { public: + subdevice(): _index(-1) + {} subdevice(const device &dev, unsigned subdevice_index): _device(dev), _index(subdevice_index) { @@ -191,6 +193,18 @@ namespace comedi } return retval; } + void cancel() + { + int retval = comedi_cancel(comedi_handle(), index()); + if(retval < 0) + { + std::ostringstream message; + message << __PRETTY_FUNCTION__ << ": comedi_cancel() failed, return value=" << retval << " ."; + std::cerr << message.str() << std::endl; + comedi_perror("comedi_cancel"); + throw std::runtime_error(message.str()); + } + } lsampl_t data_read(unsigned channel, unsigned range, unsigned aref) const { lsampl_t value;