def generateDevices(self): for i in xrange(self.instrument['main']['devices']): devconf = { 'board': None, 'analog':{ 'in' : None, 'out':None}, 'digital':{ 'in': None, 'out': None, 'io': None}, 'counter': None} device = Device(self.parser.get('Device'+str(i),'path')) device.open() devconf['board'] = device try: devconf['analog']['in'] = device.find_subdevice_by_type( CONSTANTS.SUBDEVICE_TYPE.ai) except PyComediError: pass try: devconf['analog']['out'] = device.find_subdevice_by_type( CONSTANTS.SUBDEVICE_TYPE.ao, factory = StreamingSubdevice) except PyComediError: pass try: devconf['digital']['in'] = device.find_subdevice_by_type( CONSTANTS.SUBDEVICE_TYPE.di) except PyComediError: pass try: devconf['digital']['out'] = device.find_subdevice_by_type( CONSTANTS.SUBDEVICE_TYPE.do) except PyComediError: pass try: devconf['digital']['io'] = device.find_subdevice_by_type( CONSTANTS.SUBDEVICE_TYPE.dio) except PyComediError: pass try: devconf['counter'] = device.find_subdevice_by_type( CONSTANTS.SUBDEVICE_TYPE.counter) except PyComediError: pass self.instrument['devices'][i] = devconf
def __init__(self): dev = rospy.get_param('~comedi_dev', '/dev/comedi0') chan_out = rospy.get_param('~comedi_out_chan', 0) chan_in = rospy.get_param('~comedi_in_chan', 0) self.device = Device(dev) self.device.open() subdev_out = self.device.find_subdevice_by_type(SUBDEVICE_TYPE.ao) subdev_in = self.device.find_subdevice_by_type(SUBDEVICE_TYPE.ai) self.channel_out = subdev_out.channel(chan_out, factory=AnalogChannel, aref=AREF.ground) self.channel_in = subdev_in.channel(chan_in, factory=AnalogChannel, aref=AREF.ground) self.channel_out.range = self.channel_out.find_range(unit=UNIT.volt, min=0, max=10) self.channel_in.range = self.channel_in.find_range(unit=UNIT.volt, min=1, max=5) self.max = self.channel_in.get_maxdata() self.conv_out = self.channel_out.get_converter() self.conv_in = self.channel_in.get_converter()
def __init__(self): self.device = Device('/dev/comedi0') self.device.open()