예제 #1
0
    def on_start(self, event):
        # get the device
        device = self.usb_ctrl.GetValue()
        ##        if (not os.path.exists(device) or not os.access(device, os.R_OK|os.W_OK)):
        ##            self.help_text.SetLabel("ERROR - device %s doesn't exist or isn't readable and writable." % (device))
        ##            return

        # can't start twice so disable this button
        self.start.Disable()
        self.help_text.SetLabel("Starting download of %d bytes." %
                                (self.byte_count, ))
        self.Update()

        result = token_downloader.gui_serial(self.dtype, self.version,
                                             self.download_bytes, device,
                                             self.help_text, self.gauge)

        #print "Result:", result
        if (not result):
            self.start.Enable()
        else:
            self.gauge.SetValue(self.byte_count)
            self.help_text.SetLabel("Downloading was successful!")
            self.start.Enable()

        self.Refresh()
예제 #2
0
    def on_start(self, event):
        # get the device
        device = self.usb_ctrl.GetValue()

        filename = self.file_browse.GetValue()
        if (not os.path.exists(filename)):
            self.help_text.SetLabel("Error - couldn't read file: %s" %
                                    (filename, ))
            return

        file_handle = file(filename, 'rb')
        firmware_string = file_handle.read()
        file_handle.close()

        prefix = token_downloader.SERIAL_WAKEUP_STR + token_downloader.FIRMWARE_STR
        prefix_len = len(prefix)

        while (firmware_string.startswith(token_downloader.PRE_WAKEUP_ONE)):
            firmware_string = firmware_string[len(token_downloader.
                                                  PRE_WAKEUP_ONE):]

        if ((len(firmware_string) < prefix_len)
                or (not firmware_string.startswith(prefix))):
            self.help_text.SetLabel(
                "Error - file doesn't seem to be firmware.")
            return

        version = ((ord(firmware_string[prefix_len]) & 0xf0) >> 4,
                   ord(firmware_string[prefix_len]) & 0x0f)

        firmware_bytes = []
        for i in range(prefix_len + 1, len(firmware_string)):
            firmware_bytes.append(ord(firmware_string[i]))
        self.byte_count = len(firmware_string)
        self.gauge.SetRange(self.byte_count)

        # can't start twice so disable this button
        self.start.Disable()
        self.help_text.SetLabel("Starting download of %d bytes." %
                                (self.byte_count, ))
        self.Update()

        result = token_downloader.gui_serial("firmware", version,
                                             firmware_bytes, device,
                                             self.help_text, self.gauge)

        if (not result):
            self.start.Enable()

        else:
            self.gauge.SetValue(self.byte_count)
            self.gauge.Update()

            self.help_text.SetLabel("Downloading was successful!")
            self.start.Enable()

        self.Refresh()
예제 #3
0
    def on_start(self, event):
        # get the device
        device = self.usb_ctrl.GetValue()

        filename = self.file_browse.GetValue()
        if (not os.path.exists(filename)):
            self.help_text.SetLabel("Error - couldn't read file: %s" % (filename,))
            return

        file_handle = file(filename, 'rb')
        firmware_string = file_handle.read()
        file_handle.close()

        prefix = token_downloader.SERIAL_WAKEUP_STR + token_downloader.FIRMWARE_STR
        prefix_len = len(prefix)

        while (firmware_string.startswith(token_downloader.PRE_WAKEUP_ONE)):
               firmware_string = firmware_string[len(token_downloader.PRE_WAKEUP_ONE):]

        if ((len(firmware_string) < prefix_len) or
            (not firmware_string.startswith(prefix))):
            self.help_text.SetLabel("Error - file doesn't seem to be firmware.")
            return

        version = ((ord(firmware_string[prefix_len])&0xf0)>>4,
                   ord(firmware_string[prefix_len])&0x0f)

        firmware_bytes = []
        for i in range(prefix_len+1, len(firmware_string)):
            firmware_bytes.append(ord(firmware_string[i]))
        self.byte_count = len(firmware_string)
        self.gauge.SetRange(self.byte_count)

        # can't start twice so disable this button
        self.start.Disable()
        self.help_text.SetLabel("Starting download of %d bytes." % (self.byte_count,))
        self.Update()

        result = token_downloader.gui_serial("firmware", version, firmware_bytes,
                                             device, self.help_text, self.gauge)

        if (not result):
            self.start.Enable()

        else:
            self.gauge.SetValue(self.byte_count)
            self.gauge.Update()

            self.help_text.SetLabel("Downloading was successful!")
            self.start.Enable()

        self.Refresh()
예제 #4
0
    def on_start(self, event):
        # get the device
        device = self.usb_ctrl.GetValue()

        filename = self.file_browse.GetValue()
        if (not os.path.exists(filename)):
            self.help_text.SetLabel("Error - couldn't read file: %s" %
                                    (filename, ))
            return

        file_handle = file(filename, 'rb')
        read_error, data_bytes = hex_to_bin(file_handle)
        file_handle.close()

        if (read_error):
            self.help_text.SetLabel("Error on reading intel hex file: " +
                                    read_error)
            return

        version = (0, 0)
        download_bytes = [0, 0, 0, 0]
        download_bytes[0], download_bytes[1] = tokens.word_to_bytes(
            len(data_bytes))
        download_bytes[2], download_bytes[3] = tokens.word_to_bytes(
            tokens.calculate_crc(data_bytes))
        download_bytes.extend(data_bytes)

        self.byte_count = len(download_bytes)
        self.gauge.SetRange(self.byte_count)

        # can't start twice so disable this button
        self.start.Disable()
        self.help_text.SetLabel("Starting download of %d bytes." %
                                (self.byte_count, ))
        self.Update()

        result = token_downloader.gui_serial("firmware", version,
                                             download_bytes, device,
                                             self.help_text, self.gauge)

        if (not result):
            self.start.Enable()

        else:
            self.gauge.SetValue(self.byte_count)
            self.gauge.Update()
            self.help_text.SetLabel("Downloading was successful!")
            self.start.Enable()

        self.Refresh()
예제 #5
0
    def on_start(self, event):
        # get the device
        device = self.usb_ctrl.GetValue()

        filename = self.file_browse.GetValue()
        if (not os.path.exists(filename)):
            self.help_text.SetLabel("Error - couldn't read file: %s" % (filename,))
            return

        file_handle = file(filename, 'rb')
        read_error, data_bytes = hex_to_bin(file_handle)
        file_handle.close()

        if (read_error):
            self.help_text.SetLabel("Error on reading intel hex file: " + read_error)
            return

        version = (0, 0)
        download_bytes = [0, 0, 0, 0]
        download_bytes[0], download_bytes[1] = tokens.word_to_bytes(len(data_bytes))
        download_bytes[2], download_bytes[3] = tokens.word_to_bytes(tokens.calculate_crc(data_bytes))
        download_bytes.extend(data_bytes)

        self.byte_count = len(download_bytes)
        self.gauge.SetRange(self.byte_count)

        # can't start twice so disable this button
        self.start.Disable()
        self.help_text.SetLabel("Starting download of %d bytes." % (self.byte_count,))
        self.Update()

        result = token_downloader.gui_serial("firmware", version, download_bytes,
                                             device, self.help_text, self.gauge)

        if (not result):
            self.start.Enable()

        else:
            self.gauge.SetValue(self.byte_count)
            self.gauge.Update()
            self.help_text.SetLabel("Downloading was successful!")
            self.start.Enable()

        self.Refresh()
예제 #6
0
    def on_start(self, event):
        # get the device
        device = self.usb_ctrl.GetValue()
##        if (not os.path.exists(device) or not os.access(device, os.R_OK|os.W_OK)):
##            self.help_text.SetLabel("ERROR - device %s doesn't exist or isn't readable and writable." % (device))
##            return

        # can't start twice so disable this button
        self.start.Disable()
        self.help_text.SetLabel("Starting download of %d bytes." % (self.byte_count,))
        self.Update()

        result = token_downloader.gui_serial(self.dtype, self.version, self.download_bytes,
                                             device, self.help_text, self.gauge)

        #print "Result:", result
        if (not result):
            self.start.Enable()
        else:
            self.gauge.SetValue(self.byte_count)
            self.help_text.SetLabel("Downloading was successful!")
            self.start.Enable()

        self.Refresh()