コード例 #1
0
ファイル: gui.py プロジェクト: joernalraun/ubittool
    def read_full_flash_intel(self):
        """Read the full contents of flash.

        Displays it as Intel Hex in the read-only text viewer.
        """
        self.set_next_cmd(self.CMD_READ_FLASH_HEX)
        hex_str = read_flash_hex(decode_hex=False)
        self.text_viewer.replace(hex_str)
コード例 #2
0
ファイル: gui.py プロジェクト: joernalraun/ubittool
    def read_full_flash_pretty(self):
        """Read the full contents of flash.

        Displays it as a pretty hex and ASCII string in the read-only text
        viewer.
        """
        self.set_next_cmd(self.CMD_READ_FLASH_PRETTY)
        hex_str = read_flash_hex(decode_hex=True)
        self.text_viewer.replace(hex_str)
コード例 #3
0
ファイル: test_cmds.py プロジェクト: carlosperate/ubittool
def test_read_flash_hex_decoded(mock_read_flash):
    """Test read_flash_hex() with decoding hex."""
    data_bytes = bytes([x for x in range(1, 17)])
    expected = ("0000  01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10  "
                "|................|\n")
    mock_read_flash.return_value = (0, data_bytes)

    result = cmds.read_flash_hex(decode_hex=True)

    assert result == expected
コード例 #4
0
ファイル: test_cmds.py プロジェクト: carlosperate/ubittool
def test_read_flash_hex(mock_read_flash):
    """Test read_flash_hex() with default arguments."""
    data_bytes = bytes([x for x in range(256)] * 4)
    intel_hex = IntelHex()
    intel_hex.frombytes(data_bytes)
    ihex_str = ihex_to_str(intel_hex)
    mock_read_flash.return_value = (0, data_bytes)

    result = cmds.read_flash_hex()

    assert result == ihex_str
コード例 #5
0
ファイル: test_cmds.py プロジェクト: carlosperate/ubittool
def test_read_flash_hex_non_zero_address(mock_read_flash):
    """Test read_flash_hex() with given address and count."""
    data_bytes = bytes([x for x in range(128)])
    data_dict = {x + 1024: x for x in range(256)}
    intel_hex = IntelHex()
    intel_hex.fromdict(data_dict)
    ihex_str = ihex_to_str(intel_hex)
    # Remove the last 128 bytes, 8 lines, 9 with EoF
    ihex_str = "\n".join(ihex_str.split()[:-9] + [INTEL_HEX_EOF])
    mock_read_flash.return_value = (1024, data_bytes)

    result = cmds.read_flash_hex(address=1024, count=128)

    assert result == ihex_str