DELTA = FREQ_LIMIT  # done so first error doesn't count towards limit

while DELTA >= FREQ_LIMIT:
    try:
        Setup.setup()
        try:
            Setup.serial_setup()
        except SerialException:
            print "serial error"
            time.sleep(2)
            if var.serial_start == 0:
                var.serial_start = 2
            elif var.serial_start ==2:
                var.serial_start = 0
            Setup.closedown()
            Setup.serial_setup()
        SCHED = Scheduler()
        SCHED.new(server(var.port))
        SCHED.mainloop()
        
    except StandardError:
        print "standard error"
	print traceback.format_exc()
	#print var.devices
	#print var.devices[0][2].isOpen()
	#break
        STOP = time.time()
        DELTA = STOP - START
        
        if var.soc: