import u3
import time

def captura(NMAX):
	"""
	Devuelve NMAX valores de voltaje en una lista
	"""
	try:
		d=None
		d=u3.U3()
		d.configIO(FIOAnalog = 0x0f)
		d.streamConfig(NumChannels = ??, PChannels = ??, NChannels = ??, ScanFrequency=??)
		print 'Configurado'
		if(d.streamStarted): d.streamStop() # ??
		else: d.streamStart() # ??
		print 'Iniciado'
		n=0
		valores=[]
		time.sleep(0.1)
		for dic in d.streamData():
			print n
			if(not(dic is None) and dic.has_key('AIN0')):
				valores.extend(??)
				n += len(dic['AIN0'])
				if(n>NMAX): break
		d.streamStop()
		d.close()
		print 'Final'
		return valores[0:NMAX]
	except:
		print 'exception'
	finally:
		if(d is not None):
			if(d.streamStarted): d.streamStop()
			d.close()
  

