def main(): createDB() try: manager = Manager() except RuntimeError as e: print("RuntimeException: %s" % e.details) print("Exiting...") exit(1) try: manager.setOnAttachHandler(managerDeviceAttached) manager.setOnDetachHandler(managerDeviceDetached) manager.setOnErrorHandler(managerErrorHandler) manager.setOnServerConnectHandler(managerServerConnect) manager.setOnServerDisconnectHandler(managerServerDisconnect) manager.openManager() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting...") exit(1) try: manager.openManager() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting...") exit(1) print("Press Enter to quit...") chr = sys.stdin.read(1) print("Closing...") try: manager.closeManager() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting...") exit(1) print("Done.") exit(0)
global interC interC.closePhidget() def ConnectHandler(e): print('[C+] Connected to Server!') def DisconnectHandler(e): print('[C-] Disconnected from Server') manager = Manager() manager.setOnAttachHandler(AttachHandler) manager.setOnDetachHandler(DetachHandler) manager.setOnServerConnectHandler(ConnectHandler) manager.setOnServerDisconnectHandler(DisconnectHandler) manager.openRemoteIP(config.SBCIP, 5001) print("phidAPI @ :"+str(config.myPort)) try: s = zerorpc.Server(rpc()) s.bind("tcp://" + str(config.myIP) + ":" + str(config.myPort)) s.run() except KeyboardInterrupt: print(" KeyboardInterrupt") print("Shutting down...") manager.closeManager() exit(0)
) print( "|- Attached -|- Type -|- Serial No. -|- Version -|" ) print( "|------------|----------------------------------|--------------|------------|" ) for attachedDevice in attachedDevices: print("|- %8s -|- %30s -|- %10d -|- %8d -|" % (attachedDevice.isAttached(), attachedDevice.getDeviceName(), attachedDevice.getSerialNum(), attachedDevice.getDeviceVersion())) print( "|------------|----------------------------------|--------------|------------|" ) print("Press Enter to quit....") chr = sys.stdin.read(1) print("Closing...") try: mngr.closeManager() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) print("Done.") exit(0)
mngr.openManager() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) attachedDevices = mngr.getAttachedDevices() print("|------------|----------------------------------|--------------|------------|") print("|- Attached -|- Type -|- Serial No. -|- Version -|") print("|------------|----------------------------------|--------------|------------|") for attachedDevice in attachedDevices: print("|- %8s -|- %30s -|- %10d -|- %8d -|" % (attachedDevice.isAttached(), attachedDevice.getDeviceName(), attachedDevice.getSerialNum(), attachedDevice.getDeviceVersion())) print("|------------|----------------------------------|--------------|------------|") print("Press Enter to quit....") chr = sys.stdin.read(1) print("Closing...") try: mngr.closeManager() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) print("Done.") exit(0)
exit(1) try: #logging example, uncomment to generate a log file #manager.enableLogging(PhidgetLogLevel.PHIDGET_LOG_VERBOSE, "phidgetlog.log") manager.setOnAttachHandler(AttachHandler) manager.setOnDetachHandler(DetachHandler) manager.setOnErrorHandler(LibraryErrorHandler) except PhidgetException as e: LocalErrorCatcher(e) print("Opening....") try: # This would be openPhidget for a specific device object manager.openManager() except PhidgetException as e: LocalErrorCatcher(e) print("Phidget Simple Playground (plug and unplug devices)") print("Press Enter to end anytime...") character = str(raw_input()) print("Closing...") try: # This would be closePhidget() for a specific device object manager.closeManager() except PhidgetException as e: LocalErrorCatcher(e) exit(0)