def connect(self): connected = False openmv.disconnect() for i in range(10): try: # opens CDC port. # Set small timeout when connecting openmv.init(self.config.get("main", "serial_port"), baudrate=self.baudrate, timeout=0.050) connected = True break except Exception as e: connected = False sleep(0.100) if not connected: if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH): error_msg = ( "Failed to open serial port.\n" "Please install OpenMV's udev rules first:\n\n" "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n" "sudo udevadm control --reload-rules\n\n") else: error_msg = ("Failed to open serial port.\n" "Please check the preferences Dialog.\n") self.show_message_dialog(gtk.MESSAGE_ERROR, "%s%s" % (error_msg, e)) return # Set higher timeout after connecting for lengthy transfers. openmv.set_timeout(1 * 2) # SD Cards can cause big hicups. # check firmware version fw_ver = openmv.fw_version() self.fw_version = fw_ver ide_ver = (FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCH) if (fw_ver[0] != FIRMWARE_VERSION_MAJOR or fw_ver[1] != FIRMWARE_VERSION_MINOR): self.connected = False self.show_message_dialog( gtk.MESSAGE_ERROR, "Firmware version mismatch!\n" "Please update the firmware image and/or the IDE!") else: self.connected = True self._update_title() map(lambda x: x.set_sensitive(True), self.controls) # Interrupt running code openmv.stop_script() # Enable Framebuffer openmv.enable_fb(True) # Disable connect button self.connect_button.set_sensitive(False)
def connect(self): try: # opens CDC port. openmv.init(self.config.get("main", "serial_port"), baudrate=self.baudrate, timeout=0.3) except Exception as e: # create fresh config if needed if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH): error_msg = ("Failed to open serial port.\n" "Please install OpenMV's udev rules first:\n\n" "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n" "sudo udevadm control --reload-rules\n\n") else: error_msg = ("Failed to open serial port.\n" "Please check the preferences Dialog.\n") self.show_message_dialog(gtk.MESSAGE_ERROR,"%s%s"%(error_msg, e)) return # add terminal update callback gobject.gobject.timeout_add(10, omvgtk.update_terminal) # check firmware version self.fw_mismatch = False fw_ver = openmv.fw_version() ide_ver = (FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCH) print("fw_version:" + str(fw_ver)) print("ide_version:" + str(ide_ver)) if (fw_ver[0] != FIRMWARE_VERSION_MAJOR): # If ABI versions don't match, nothing todo here... self.show_message_dialog(gtk.MESSAGE_ERROR, "Firmware ABI version mismatch!\n" "Please update the IDE and/or FW manually\n") return elif (FIRMWARE_VERSION_MINOR > fw_ver[1] or FIRMWARE_VERSION_PATCH > fw_ver[2]): self.fw_mismatch = True self.show_message_dialog(gtk.MESSAGE_ERROR, "Firmware version mismatch!\n" "An older firmware version has been detected.\n" "Please update the firmware!") if (self.fw_mismatch): self.connected = True self.connect_button.set_sensitive(False) self.fwupdate_button.set_sensitive(True) return # interrupt any running code openmv.stop_script() self.connected = True self._update_title() self.connect_button.set_sensitive(False) map(lambda x:x.set_sensitive(True), self.controls)
def connect(self): connected = False openmv.disconnect() for i in range(10): try: # opens CDC port. # Set small timeout when connecting openmv.init(self.config.get("main", "serial_port"), baudrate=self.baudrate, timeout=0.050) connected = True break except Exception as e: connected = False sleep(0.100) if not connected: if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH): error_msg = ("Failed to open serial port.\n" "Please install OpenMV's udev rules first:\n\n" "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n" "sudo udevadm control --reload-rules\n\n") else: error_msg = ("Failed to open serial port.\n" "Please check the preferences Dialog.\n") self.show_message_dialog(gtk.MESSAGE_ERROR,"%s%s"%(error_msg, e)) return # Set higher timeout after connecting for lengthy transfers. openmv.set_timeout(1*2) # SD Cards can cause big hicups. # check firmware version fw_ver = openmv.fw_version() self.fw_version = fw_ver ide_ver = (FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCH) if (fw_ver[0] != FIRMWARE_VERSION_MAJOR or fw_ver[1] != FIRMWARE_VERSION_MINOR): self.connected = False self.show_message_dialog(gtk.MESSAGE_ERROR, "Firmware version mismatch!\n" "Please update the firmware image and/or the IDE!") else: self.connected = True self._update_title() map(lambda x:x.set_sensitive(True), self.controls) # Interrupt running code openmv.stop_script() # Enable Framebuffer enable_fb_check = self.builder.get_object("enable_fb_check") self.fb_enabled = enable_fb_check.get_active() openmv.enable_fb(self.fb_enabled) # Disable connect button self.connect_button.set_sensitive(False)
def connect(self): try: # open VCP and configure the terminal self.serial = serial.Serial(self.config.get("main", "serial_port"), self.baudrate, timeout=0.3) gobject.gobject.timeout_add(10, omvgtk.update_terminal) except Exception as e: # create fresh config if needed if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH): error_msg = ( "Failed to open serial port.\n" "Please install OpenMV's udev rules first:\n\n" "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n" "sudo udevadm control --reload-rules\n\n") else: error_msg = ("Failed to open serial port.\n" "Please check the preferences Dialog.\n") self.show_message_dialog(gtk.MESSAGE_ERROR, "%s%s" % (error_msg, e)) return openmv.init(self.serial) # check firmware version fw_ver = openmv.fw_version() print("fw_version:" + str(fw_ver)) if (fw_ver[0] != FIRMWARE_VERSION_MAJOR): self.show_message_dialog( gtk.MESSAGE_ERROR, "Firmware version mismatch! Please upgrade the firmware") return # interrupt any running code openmv.stop_script() self.connected = True self._update_title() self.connect_button.set_sensitive(False) map(lambda x: x.set_sensitive(True), self.controls)
def connect(self): try: # open VCP and configure the terminal self.serial = serial.Serial(self.config.get("main", "serial_port"), self.baudrate, timeout=0.3) gobject.gobject.timeout_add(10, omvgtk.update_terminal) except Exception as e: # create fresh config if needed if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH): error_msg = ("Failed to open serial port.\n" "Please install OpenMV's udev rules first:\n\n" "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n" "sudo udevadm control --reload-rules\n\n") else: error_msg = ("Failed to open serial port.\n" "Please check the preferences Dialog.\n") self.show_message_dialog(gtk.MESSAGE_ERROR,"%s%s"%(error_msg, e)) return openmv.init(self.serial) # check firmware version fw_ver = openmv.fw_version() print("fw_version:" + str(fw_ver)) if (fw_ver[0] != FIRMWARE_VERSION_MAJOR): self.show_message_dialog(gtk.MESSAGE_ERROR, "Firmware version mismatch! Please upgrade the firmware") return # interrupt any running code openmv.stop_script() self.connected = True self._update_title() self.connect_button.set_sensitive(False) map(lambda x:x.set_sensitive(True), self.controls)
def connect(self): try: # opens CDC port. openmv.init(self.config.get("main", "serial_port"), baudrate=self.baudrate, timeout=0.3) except Exception as e: # create fresh config if needed if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH): error_msg = ( "Failed to open serial port.\n" "Please install OpenMV's udev rules first:\n\n" "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n" "sudo udevadm control --reload-rules\n\n") else: error_msg = ("Failed to open serial port.\n" "Please check the preferences Dialog.\n") self.show_message_dialog(gtk.MESSAGE_ERROR, "%s%s" % (error_msg, e)) return # add terminal update callback gobject.gobject.timeout_add(10, omvgtk.update_terminal) # check firmware version self.fw_mismatch = False fw_ver = openmv.fw_version() ide_ver = (FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCH) print("fw_version:" + str(fw_ver)) print("ide_version:" + str(ide_ver)) if (fw_ver[0] != FIRMWARE_VERSION_MAJOR): # If ABI versions don't match, nothing todo here... self.show_message_dialog( gtk.MESSAGE_ERROR, "Firmware ABI version mismatch!\n" "Please update the IDE and/or FW manually\n") return elif (FIRMWARE_VERSION_MINOR > fw_ver[1] or FIRMWARE_VERSION_PATCH > fw_ver[2]): self.fw_mismatch = True self.show_message_dialog( gtk.MESSAGE_ERROR, "Firmware version mismatch!\n" "An older firmware version has been detected.\n" "Please update the firmware!") if (self.fw_mismatch): self.connected = True self.connect_button.set_sensitive(False) self.fwupdate_button.set_sensitive(True) return # interrupt any running code openmv.stop_script() self.connected = True self._update_title() self.connect_button.set_sensitive(False) map(lambda x: x.set_sensitive(True), self.controls)