def fetch_ports(): coms = fetch_coms() pots = {} for c in coms: p = Potentiostat('/dev/{}'.format(c)) if p not in pots: pots['pot{}'.format(p.get_device_id())] = p for k, p in pots.items(): _pot_radio = ttk.Radiobutton(parent, text=p) _pot_radio.grid(row=0, column=1)
def read_pots(): devlist = os.listdir('/dev') coms = [c for c in devlist if c.startswith('ttyACM')] pots = {} for c in coms: p = Potentiostat('/dev/{}'.format(c)) _id = p.get_device_id() if p not in pots: pots['pot{}'.format(_id)] = p return pots
def read_pots(): """ searches the operating system for connected serial ports """ devlist = os.listdir('/dev') coms = [c for c in devlist if c.startswith('ttyACM')] pots = {} for c in coms: p = Potentiostat('/dev/{}'.format(c)) _id = p.get_device_id() if p not in pots: pots['pot{}'.format(_id)] = p return pots
def find_arduino_serial_ports(num_RAAs): _Ard_Address = [[] for x in range(num_RAAs)] ports = list(serial.tools.list_ports.comports()) for p in ports: try: dev = Potentiostat(p[0]) cT = dev.get_device_id() print cT if float(cT) == 1: print 'Connecting RAA 1 to Arduino via port %s.'%(p[0]) _Ard_Address[0] = dev if float(cT) == 2: print 'Connecting RAA 2 to Arduino via port %s.'%(p[0]) _Ard_Address[1] = dev except: print 'Could not connect to arduino' return _Ard_Address
def find_arduino_serial_ports(num_RAAs): _Ard_Address = [[] for x in range(num_RAAs)] ports = list(serial.tools.list_ports.comports()) print 'Looking for ARD port...' for p in ports: try: ## print p dev = Potentiostat(p[0]) cT = dev.get_device_id() if float(cT) == 1: print 'Connecting RAA 1 to Arduino (ID: %s) via port %s.'%(str(cT), p[0]) _Ard_Address[0] = dev if float(cT) == 2: print 'Connecting RAA 2 to Arduino (ID: %s) via port %s.'%(str(cT), p[0]) _Ard_Address[1] = dev except: pass ## print 'Could not connect to arduino (Ln: 140)' if not _Ard_Address[0]: print 'Could not connect RAA 1 to potentiostat' if not _Ard_Address[1]: print 'Could not connect RAA 2 to potentiostat' return _Ard_Address
potentiostat_ID = 2 curr_range = '10uA' # Name of current range for test [-10uA, +10uA] volt_range = '1V' low_voltage = -0.3 low_time = .5 high_voltage = 0.7 high_time = 2 sample_period = .1 try: dev = [] ports = list(serial.tools.list_ports.comports()) for p in ports: try: dev_temp = Potentiostat(p[0]) cT = dev_temp.get_device_id() if cT == potentiostat_ID: dev = dev_temp except: pass if not dev == []: print 'Running chronoamperometry on potentiostat with device ID: %s'%(str(dev.get_device_id())) dev.set_volt_range(volt_range) dev.set_curr_range(curr_range) ##dev.stop_test() list_length = 1 curr_list = [] while True: stTime = time.time()
from __future__ import print_function from potentiostat import Potentiostat import sys if len(sys.argv) > 1: port = sys.argv[1] else: port = '/dev/ttyACM0' dev = Potentiostat(port) rsp = dev.get_device_id() print('device id: {0}'.format(rsp))
dev = 1 devices_found = 0 ports = list(serial.tools.list_ports.comports()) for p in ports: if not (devices_found > 0): try: dev = Potentiostat(p[0]) serial_port = p[0] devices_found += 1 except: pass if not dev == []: dev.set_device_id(potentiostat_ID) print 'Setting potentiostat on port %s with ID: %s' % ( str(serial_port), str(dev.get_device_id())) if devices_found > 1: print '***********\n**Warning**\n***********' print 'Multiple potentiostats detected' else: print 'Could not connect potentiostat with device ID: %s' % ( str(potentiostat_ID)) except: traceback.print_exc() pass finally: ports = list(serial.tools.list_ports.comports()) for p in ports: try: dev = Potentiostat(p[0])