Changeset 164 for trunk/synapse
- Timestamp:
- 08/19/10 13:36:21 (12 years ago)
- Location:
- trunk/synapse
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/synapse/Puzzlebox/Synapse/Client.py
r163 r164 84 84 self.socket.name = 'ThinkGear Client' 85 85 86 if ((self.server_host == '') or \ 87 (self.server_host == '*')): 88 self.server_host=QtNetwork.QHostAddress.Any 86 if self.server_host == '*': 87 self.server_host = '127.0.0.1' 88 89 self.server_host=QtNetwork.QHostAddress(self.server_host) 89 90 90 91 self.socket.readyRead.connect(self.printReply) -
trunk/synapse/Puzzlebox/Synapse/Interface.py
r163 r164 237 237 # and re-connects to a MindSet Emulator, 238 238 # we need to reset the max power values 239 self.progressBarEEGDelta.setMaximum( THINKGEAR_EMULATION_MAX_EEG_POWER_VALUE)240 self.progressBarEEGTheta.setMaximum( THINKGEAR_EMULATION_MAX_EEG_POWER_VALUE)241 self.progressBarEEGLowAlpha.setMaximum( THINKGEAR_EMULATION_MAX_EEG_POWER_VALUE)242 self.progressBarEEGHighAlpha.setMaximum( THINKGEAR_EMULATION_MAX_EEG_POWER_VALUE)243 self.progressBarEEGLowBeta.setMaximum( THINKGEAR_EMULATION_MAX_EEG_POWER_VALUE)244 self.progressBarEEGHighBeta.setMaximum( THINKGEAR_EMULATION_MAX_EEG_POWER_VALUE)245 self.progressBarEEGLowGamma.setMaximum( THINKGEAR_EMULATION_MAX_EEG_POWER_VALUE)246 self.progressBarEEGMidGamma.setMaximum( THINKGEAR_EMULATION_MAX_EEG_POWER_VALUE)239 self.progressBarEEGDelta.setMaximum(self.maxEEGPower) 240 self.progressBarEEGTheta.setMaximum(self.maxEEGPower) 241 self.progressBarEEGLowAlpha.setMaximum(self.maxEEGPower) 242 self.progressBarEEGHighAlpha.setMaximum(self.maxEEGPower) 243 self.progressBarEEGLowBeta.setMaximum(self.maxEEGPower) 244 self.progressBarEEGHighBeta.setMaximum(self.maxEEGPower) 245 self.progressBarEEGLowGamma.setMaximum(self.maxEEGPower) 246 self.progressBarEEGMidGamma.setMaximum(self.maxEEGPower) 247 247 248 248 … … 376 376 if ('eegPower' in packet.keys()): 377 377 378 # If we are not emulating packets we'll set the maximum EEG Power value 379 # threshold to the default (or maximum value found within this packet) 380 if not self.thinkGearConnectServer.emulate_headset_data: 381 self.maxEEGPower = THINKGEAR_EMULATION_MAX_EEG_POWER_VALUE 378 382 379 383 for value in packet['eegPower'].keys(): … … 433 437 ################################################################## 434 438 439 def enumerateSerialPorts(self): 440 441 """ Uses the Win32 registry to return an 442 iterator of serial (COM) ports 443 existing on this computer. 444 445 from http://eli.thegreenplace.net/2009/07/31/listing-all-serial-ports-on-windows-with-python/ 446 """ 447 448 path = 'HARDWARE\\DEVICEMAP\\SERIALCOMM' 449 try: 450 key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path) 451 except WindowsError: 452 raise IterationError 453 454 for i in itertools.count(): 455 try: 456 val = winreg.EnumValue(key, i) 457 yield str(val[1]) 458 except EnvironmentError: 459 break 460 461 462 ################################################################## 463 464 def fullPortName(self, portname): 465 466 """ Given a port-name (of the form COM7, 467 COM12, CNCA0, etc.) returns a full 468 name suitable for opening with the 469 Serial class. 470 """ 471 472 m = re.match('^COM(\d+)$', portname) 473 if m and int(m.group(1)) < 10: 474 return portname 475 476 return '\\\\.\\' + portname 477 478 479 ################################################################## 480 435 481 def searchForThinkGearDevices(self): 436 482 437 483 #self.pushButtonBluetoothSearch.setText('Searching') 438 484 439 if (sys.platform != 'win32'): 485 mindset_devices = [] 486 487 if (sys.platform == 'win32'): 488 489 for portname in self.enumerateSerialPorts(): 490 491 #portname = self.fullPortName(portname) 492 mindset_devices.append(portname) 493 494 495 else: 440 496 441 497 # Bluetooth module doesn't compile properly under Windows … … 447 503 #flush_cache=True, \ 448 504 #lookup_names=True) 449 450 addresses = []451 505 452 506 command = '%s con' % PATH_TO_HCITOOL … … 460 514 pass 461 515 else: 462 addresses.append(address)463 464 for address in addresses:516 bluetooth_devices.append(address) 517 518 for address in bluetooth_devices: 465 519 device_name = bluetooth.lookup_name(address) 466 520 if device_name == 'MindSet': 467 bluetooth_devices.append(address)521 mindset_devices.append(address) 468 522 469 523 470 524 if self.DEBUG: 471 print "Bluetooth devices found:",472 print bluetooth_devices525 print "Bluetooth MindSet devices found:", 526 print mindset_devices 473 527 474 528 … … 476 530 477 531 self.comboBoxDeviceSelect.addItem('MindSet Emulator') 478 479 480 for mindset_device in bluetooth_devices:481 532 533 534 for mindset_device in mindset_devices: 535 self.comboBoxDeviceSelect.addItem(mindset_device) 482 536 483 537 -
trunk/synapse/Puzzlebox/Synapse/Protocol.py
r163 r164 90 90 91 91 THINKGEAR_DEVICE_SERIAL_PORT = configuration.THINKGEAR_DEVICE_SERIAL_PORT 92 THINKGEAR_DEVICE_BLUETOOTH_ADDRESS = \93 configuration.THINKGEAR_DEVICE_BLUETOOTH_ADDRESS92 #THINKGEAR_DEVICE_BLUETOOTH_ADDRESS = \ 93 #configuration.THINKGEAR_DEVICE_BLUETOOTH_ADDRESS 94 94 95 95 DEFAULT_SERIAL_BAUDRATE = 57600 … … 828 828 829 829 try: 830 device = serial.Serial(port = self.device_address, \ 830 ## device = serial.Serial(port = self.device_address, \ 831 ## baudrate = baudrate, \ 832 ## bytesize = init_byte_size, \ 833 ## parity = init_parity, \ 834 ## stopbits = init_stopbits, \ 835 ## xonxoff = init_software_flow_control, \ 836 ## rtscts = init_rts_cts_flow_control, \ 837 ## timeout = timeout) 838 839 device = serialWrapper(port = self.device_address, \ 831 840 baudrate = baudrate, \ 832 841 bytesize = init_byte_size, \ … … 840 849 if self.DEBUG: 841 850 print "ERROR:", 842 print e 851 print e, 852 print self.device_address 843 853 sys.exit() 844 854 -
trunk/synapse/puzzlebox_synapse_configuration.ini
r163 r164 12 12 13 13 # Use Bluetooth MAC address for Linux 14 THINKGEAR_DEVICE_BLUETOOTH_ADDRESS = ' 00:13:EF:00:56:70'14 THINKGEAR_DEVICE_BLUETOOTH_ADDRESS = '' 15 15 # THINKGEAR_DEVICE_BLUETOOTH_ADDRESS = '00:13:EF:xx:xx:xx' # Linux example 16 16 -
trunk/synapse/synapse-protocol.py
r163 r164 25 25 DEBUG = 2 26 26 27 if tgConf.THINKGEAR_DEVICE_BLUETOOTH_ADDRESS == '': 28 device_address = tgConf.THINKGEAR_DEVICE_SERIAL_PORT 29 else: 30 device_address = tgConf.THINKGEAR_DEVICE_BLUETOOTH_ADDRESS 27 device_address = None 31 28 32 29 for each in sys.argv: 33 30 if each.startswith("--device="): 34 31 device_address = each[ len("--device="): ] 32 33 if device_address == None: 34 if tgConf.THINKGEAR_DEVICE_BLUETOOTH_ADDRESS == '': 35 device_address = tgConf.THINKGEAR_DEVICE_SERIAL_PORT 36 else: 37 device_address = tgConf.THINKGEAR_DEVICE_BLUETOOTH_ADDRESS 35 38 36 37 38 39 40 39 app = QtCore.QCoreApplication(sys.argv) 40 serial_device = tgProtocol.SerialDevice(log, device_address, DEBUG=DEBUG) 41 protocol = tgProtocol.ProtocolHandler(log, serial_device, DEBUG=DEBUG) 42 protocol.start() 43 serial_device.run()
Note: See TracChangeset
for help on using the changeset viewer.