Ejemplo n.º 1
0
 def prepare_debug_command(self):
     if self._dbg_view:
         value = self._dbg_view.pop_data()
         if value:
             kwargs = {'value': value}
             command = UiMessage(Message.CMD_DEVICE_RAW_DATA, self.id(),
                                 self.next_seq(), **kwargs)
             self.prepare_command(command)
Ejemplo n.º 2
0
    def page_read(self, page_id, discard=False):
        page_mm = self.chip.get_mem_map_tab(page_id)
        if not page_mm:
            return

        if discard or not page_mm.valid():
            kwargs = {'page_id': page_id, 'discard': True}
            command = UiMessage(Message.CMD_DEVICE_PAGE_READ, self.id(),
                                self.next_seq(), **kwargs)
            self.prepare_command(command)
Ejemplo n.º 3
0
    def page_write(self, page_id):
        page_mm = self.chip.get_mem_map_tab(page_id)
        if not page_mm:
            return

        value = page_mm.raw_values()
        kwargs = {'page_id': page_id, 'value': value}
        command = UiMessage(Message.CMD_DEVICE_PAGE_WRITE, self.id(),
                            self.next_seq(), **kwargs)
        self.prepare_command(command)
Ejemplo n.º 4
0
    def handle_connected_msg(self, attached):
        print("{} connect {}".format(self.__class__.__name__, attached))

        if attached:
            if not self.chip:
                kwargs = {'page_id': Page.ID_INFORMATION, 'discard': False}
                command = UiMessage(Message.CMD_DEVICE_PAGE_READ, self.id(),
                                    self.next_seq(), **kwargs)
                self.prepare_command(command)
            elif not self.chip.inited():
                ChipMemoryMap.delete(self.chip.id())
                self.chip = None
            else:
                self.set_message_output()
        else:
            self.chip = None
Ejemplo n.º 5
0
    def set_message_output(self, enable=True):
        assert enable

        # page_id = (5, 0)
        # page_mm = self.chip.get_mem_map_tab(page_id)
        # if not page_mm:
        #     return

        # len = page_mm.get_value_size() -1
        # addr = page_mm.address()
        # value = [0x88, 0x57, 0x2, page_mm.get_value_size() -1, addr & 0xff, addr >>8]
        # self.raw_write(value)

        command = UiMessage(Message.CMD_DEVICE_MSG_OUTPUT, self.id(),
                            self.next_seq())
        self.prepare_command(command)
Ejemplo n.º 6
0
    def handle_page_read_msg(self, page_cache):
        assert page_cache

        if not page_cache.buffer_data_valid():
            return

        self.update_page_element(page_cache)

        page_id = page_cache.id()
        if page_id == Page.ID_INFORMATION:
            if not self.chip:
                self.create_chip(page_cache)
                kwargs = {'page_id': Page.OBJECT_TABLE, 'discard': False}
                command = UiMessage(Message.CMD_DEVICE_PAGE_READ, self.id(),
                                    self.next_seq(), **kwargs)
                self.prepare_command(command)
        elif page_id == Page.OBJECT_TABLE:
            if not self.chip.inited():
                self.create_chip_pages_element()
                self.create_msg_view_element()
                self.create_paint_view_element()
                self.set_message_output()

        self.set_message_output()
Ejemplo n.º 7
0
 def poll_device(self):
     command = UiMessage(Message.CMD_POLL_DEVICE, self.id(),
                         self.next_seq())
     self.prepare_command(command)
Ejemplo n.º 8
0
 def raw_write(self, value):
     kwargs = {'value': value}
     command = UiMessage(Message.CMD_DEVICE_RAW_DATA, self.id(),
                         self.next_seq(), **kwargs)
     self.prepare_command(command)