Example #1
0
    def _open_port(self, addr):
        """
        Attempt to open a connection to the SHAKE with the given address.

        :param addr: the port identifier (COM port number, char device filename)
        :returns: SHAKE_SUCCESS or SHAKE_ERROR (TODO getlasterror type func?)
        """
        try:
            self.port = pyshake_serial.serial_port(addr)
            baud = 230400
            if self.device_type == SHAKE_SK7:
                baud = 460800

            if not self.port.open(baud):
                debug("port creation failed")
                self.thread_done = True
                return SHAKE_ERROR

            self.write_to_port = self.port.write
        except:
            debug('error; port creation failed')
            self.thread_done = True
            return SHAKE_ERROR

        return SHAKE_SUCCESS
Example #2
0
	def port_setup(self):
		# create the port (this is done inside the thread started by connect())
		try:	
			self.port = pyshake_serial.serial_port(self.device_address)
			baud = 230400
			if self.device_type == SHAKE_SK7:
				baud = 460800
			
			if not self.port.open(baud):
				debug("port creation failed")
				self.thread_done = True
				return SHAKE_ERROR

			# 	ao_callgate sets up an Active Object that is used to trigger calls
			# 	to self.port.write from the thread the object was created in. 
			if platform == "S60":
				self.write_to_port = ao_callgate(self.port.write)
			else:
				self.write_to_port = self.port.write
		except pyshake_serial.pyshake_serial_error:
			debug('error; port creation failed')
			self.thread_done = True
			return SHAKE_ERROR