mirror of
https://github.com/qca/qca-swiss-army-knife.git
synced 2026-01-27 17:07:18 +01:00
Update ath10k-bdencoder to run properly with Python 3
Explicit string encoding and decoding of UTF-8 strings was added in order to make the script work with python 3. Signed-off-by: Erik Stromdahl <erik.stromdahl@gmail.com>
This commit is contained in:
parent
60bec5a5b9
commit
c2bd6f580d
1 changed files with 7 additions and 6 deletions
|
|
@ -105,7 +105,8 @@ class BoardName():
|
|||
def parse_ie(buf, offset, length):
|
||||
self = BoardName()
|
||||
fmt = '<%ds' % length
|
||||
(self.name, ) = struct.unpack_from(fmt, buf, offset)
|
||||
(name, ) = struct.unpack_from(fmt, buf, offset)
|
||||
self.name = name.decode('utf-8')
|
||||
|
||||
logging.debug('BoardName.parse_ie(): offset %d length %d self %s' %
|
||||
(offset, length, self))
|
||||
|
|
@ -117,7 +118,7 @@ class BoardName():
|
|||
if ebdf:
|
||||
ie_id = ATH10K_BD_IE_BOARD_EXT_NAME
|
||||
|
||||
return add_ie(buf, offset, ie_id, str(self.name))
|
||||
return add_ie(buf, offset, ie_id, self.name.encode('utf-8'))
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.name == other.name
|
||||
|
|
@ -310,7 +311,7 @@ class BoardContainer:
|
|||
allnames.append(name)
|
||||
|
||||
def _add_signature(self, buf, offset):
|
||||
signature = ATH10K_BOARD_SIGNATURE + '\0'
|
||||
signature = (ATH10K_BOARD_SIGNATURE + '\0').encode('utf-8')
|
||||
length = len(signature)
|
||||
pad_len = padding_needed(length)
|
||||
length = length + pad_len
|
||||
|
|
@ -321,7 +322,7 @@ class BoardContainer:
|
|||
struct.pack_into('<B', padding, i, PADDING_MAGIC)
|
||||
|
||||
fmt = '<%ds%ds' % (len(signature), pad_len)
|
||||
struct.pack_into(fmt, buf, offset, signature.encode(), padding.raw)
|
||||
struct.pack_into(fmt, buf, offset, signature, padding.raw)
|
||||
offset += length
|
||||
|
||||
# make sure ATH10K_BOARD_SIGNATURE_LEN is correct
|
||||
|
|
@ -345,7 +346,7 @@ class BoardContainer:
|
|||
fmt = '<%dsb' % (len(ATH10K_BOARD_SIGNATURE))
|
||||
(signature, null) = struct.unpack_from(fmt, buf, offset)
|
||||
|
||||
if signature != ATH10K_BOARD_SIGNATURE or null != 0:
|
||||
if signature.decode('utf-8') != ATH10K_BOARD_SIGNATURE or null != 0:
|
||||
print("invalid signature found in %s" % name)
|
||||
return 1
|
||||
|
||||
|
|
@ -445,7 +446,7 @@ def cmd_extract(args):
|
|||
b['data'] = filename
|
||||
mapping.append(b)
|
||||
|
||||
f = open(filename, 'w')
|
||||
f = open(filename, 'wb')
|
||||
f.write(board.data.data)
|
||||
f.close()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue