Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    def task_init(self, state):
        openmv.disconnect()
        try:
            # Attempt to connect to bootloader
            openmv.init(self.port, baudrate=self.baud, timeout=0.050)
            if openmv.bootloader_start():
                openmv.set_timeout(1)
                state["next"] = self.task_erase
                state["bar"].set_text("Erasing...")
                self.cancel_button.set_sensitive(False)
        except Exception as e:
            openmv.disconnect()
            if self.flash_msg:
                state["bar"].set_text("Connecting to bootloader...\
                                       \n                              ")
            else:
                state["bar"].set_text("Connecting to bootloader...\
                                       \nDisconnect and re-connect cam!")
            self.flash_msg = self.flash_msg ^ 1
            sleep(0.100)

        return True
Ejemplo n.º 4
0
    def task_init(self, state):
        openmv.disconnect()
        try:
            # Attempt to connect to bootloader
            openmv.init(self.port, baudrate=self.baud, timeout=0.050)
            if openmv.bootloader_start():
                openmv.set_timeout(1)
                state["next"] = self.task_erase
                state["bar"].set_text("Erasing...")
                self.cancel_button.set_sensitive(False)
        except Exception as e:
            openmv.disconnect()
            if self.flash_msg:
                state["bar"].set_text("Connecting to bootloader...\
                                       \n                              ")
            else:
                state["bar"].set_text("Connecting to bootloader...\
                                       \nDisconnect and re-connect cam!")
            self.flash_msg = self.flash_msg ^ 1
            sleep(0.100)

        return True
Ejemplo n.º 5
0
def main():
    # CMD args parser
    parser = argparse.ArgumentParser(description='openmv stress test')
    parser.add_argument("-j",
                        "--disable_fb",
                        action="store_true",
                        help="Disable FB JPEG compression")
    parser.add_argument("-p",
                        "--port",
                        action="store",
                        help="OpenMV serial port")
    parser.add_argument("-t",
                        "--time",
                        action="store",
                        default=100,
                        help="Max time before stopping the script")
    parser.add_argument("-s",
                        "--script",
                        action="store",
                        default="examples/01-Basics/helloworld.py",
                        help="OpenMV script file")

    # Parse CMD args
    args = parser.parse_args()

    # init openmv
    if (args.port):
        portname = args.port
    elif 'darwin' in sys.platform:
        portname = "/dev/cu.usbmodem14221"
    else:
        portname = "/dev/openmvcam"

    print("\n>>>Reading script: %s\n" % (args.script))
    with open(args.script, "r") as f:
        script = f.read()
    print("%s\n" % (script))

    connected = False
    for i in range(10):
        try:
            # Open serial port.
            # Set small timeout when connecting
            openmv.init(portname, baudrate=921600, timeout=0.050)
            connected = True
            break
        except Exception as e:
            connected = False
            sleep(0.100)

    if not connected:
        print("Failed to connect to OpenMV's serial port.\n"
              "Please install OpenMV's udev rules first:\n"
              "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
              "sudo udevadm control --reload-rules\n\n")
        sys.exit(1)

    # Set higher timeout after connecting.
    openmv.set_timeout(0.500)

    # Enable/Disable framebuffer compression.
    print(">>>Enable FB JPEG compression %s" % (str(not args.disable_fb)))
    openmv.enable_fb(not args.disable_fb)

    # Interrupt running script.
    openmv.stop_script()
    max_timeout = int(args.time)
    for i in xrange(1000):
        openmv.exec_script(script)
        sleep(randint(0, max_timeout) / 1000)
        openmv.stop_script()
Ejemplo n.º 6
0
    def connect(self):
        connected = False
        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
            except Exception as e:
                connected = False
                sleep(0.100)

        if not connected:
            # 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

        # Set higher timeout after connecting for lengthy transfers.
        openmv.set_timeout(0.3)

        # add terminal update callback
        gobject.gobject.timeout_add(30, 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()

        # set enable JPEG
        openmv.enable_jpeg(self.enable_jpeg)

        self.connected = True
        self._update_title()
        self.connect_button.set_sensitive(False)
        map(lambda x:x.set_sensitive(True), self.controls)
Ejemplo n.º 7
0
        openmv.init(portname, baudrate=921600, timeout=0.050)
        connected = True
        break
    except Exception as e:
        connected = False
        sleep(0.100)

if not connected:
    print ( "Failed to connect to OpenMV's serial port.\n"
            "Please install OpenMV's udev rules first:\n"
            "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
            "sudo udevadm control --reload-rules\n\n")
    sys.exit(1)

# Set higher timeout after connecting for lengthy transfers.
openmv.set_timeout(1*2) # SD Cards can cause big hicups.
openmv.stop_script()
openmv.enable_fb(True)
openmv.exec_script(script)

# init screen
running = True
Clock = pygame.time.Clock()
font = pygame.font.SysFont("monospace", 15)

while running:
    Clock.tick(100)

    # read framebuffer
    fb = openmv.fb_dump()
Ejemplo n.º 8
0
        openmv.init(portname, baudrate=921600, timeout=0.050)
        connected = True
        break
    except Exception as e:
        connected = False
        sleep(0.100)

if not connected:
    print("Failed to connect to OpenMV's serial port.\n"
          "Please install OpenMV's udev rules first:\n"
          "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
          "sudo udevadm control --reload-rules\n\n")
    sys.exit(1)

# Set higher timeout after connecting for lengthy transfers.
openmv.set_timeout(1 * 2)  # SD Cards can cause big hicups.
openmv.stop_script()
openmv.enable_fb(True)
openmv.exec_script(script)

# init screen
running = True
Clock = pygame.time.Clock()
font = pygame.font.SysFont("monospace", 15)

while running:
    Clock.tick(100)

    # read framebuffer
    fb = openmv.fb_dump()
Ejemplo n.º 9
0
    def connect(self):
        connected = False
        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:
            # 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

        # Set higher timeout after connecting for lengthy transfers.
        openmv.set_timeout(1 * 2)  # SD Cards can cause big hicups.

        # add terminal update callback
        gobject.gobject.timeout_add(30, 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()

        # set enable JPEG
        openmv.enable_jpeg(self.enable_jpeg)

        self.connected = True
        self._update_title()
        self.connect_button.set_sensitive(False)
        map(lambda x: x.set_sensitive(True), self.controls)