Пример #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)
Пример #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)
Пример #3
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()
Пример #4
0
 def enable_fb_toggled(self, widget):
     enable_fb_check = self.builder.get_object("enable_fb_check")
     self.fb_enabled = enable_fb_check.get_active()
     openmv.enable_fb(self.fb_enabled)
Пример #5
0
        sys.stdout.write("OPENMV: ERROR: Could not connect to Blender, exiting now\n")
        sys.exit(0)

    # init openmv
    if 'darwin' in sys.platform:
        portnames = glob.glob("/dev/cu.usbmodem*")
        if len(portnames):
            portname = portnames[0]
        else:
            portname = None
    else:
        portname = "/dev/openmvcam"

    openmv.init(portname)
    openmv.stop_script()
    openmv.enable_fb(True)
    openmv.exec_script(script)

    # init OpenCV window
    win = cv2.namedWindow('OpenMV')
    cv2.moveWindow("OpenMV", 1280, 0)

    fb = None

        
    writer = None
    f_timestamps = None
    nframes = 0
    while True:
        datadec = ""
        try:
Пример #6
0
        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()

    if fb == None:
        continue
Пример #7
0
 def enable_fb_toggled(self, widget):
     enable_fb_check = self.builder.get_object("enable_fb_check")
     self.fb_enabled = enable_fb_check.get_active()
     openmv.enable_fb(self.fb_enabled)