コード例 #1
0
def hexdigest2bytes(hexdigest):
    """
    >>> hexdigest2bytes("aabbcc")
    b'\\xaa\\xbb\\xcc'
    >>> hexdigest2bytes("ABCDEF")
    b'\\xab\\xcd\\xef'
    >>> hexdigest2bytes("ABCD0F")
    b'\\xab\\xcd\\x0f'
    """
    return bytes(map(hex2byte, split(hexdigest, 2)))
コード例 #2
0
    def convert(self, data):
        type_info = self._type_info[self._dataType]

        values = []
        for chunk in split(data, type_info.data_size):
            (value, ) = struct.unpack(type_info.read_pattern, chunk)

            values.append(self._convert_single(value))

        return values
コード例 #3
0
    def upload_binary(self, checksum, data):
        self.reboot_to_bootloader()

        self._log(f"Image info: size: {len(data)} checksum: {checksum}")

        # init update
        self._log("Initializing update")
        self._bootloader.send_init_update(len(data), checksum)

        # split data into chunks
        chunks = split(data, chunk_size=255)

        # send data
        self._log('Sending data')
        self._stopwatch.reset()
        for chunk in chunks:
            self._bootloader.send_firmware(chunk)
        self._log(f'Data transfer took {round(self._stopwatch.elapsed, 1)} seconds')
コード例 #4
0
 def parse_response(self, payload):
     return list(split(payload, 63))