Skip to content

Commit

Permalink
scripts: use python's hex() in ta_bin_to_c.py
Browse files Browse the repository at this point in the history
- Python has a built in function to turn a byte into its respective hex
  value that can be used instead of string formatting the values
  directly.
- Using the built in function instead of the previous string formatting
  method fixed an issue where bytes were failing to be written when
  we used an archaic yocto bsp from broadcom.
- The built in function also has the benefit of being easier to read and
  understand.

Signed-off-by: Dhananjay Phadke <dphadke@linux.microsoft.com>
Signed-off-by: Andrew Mustea <andrew.mustea@microsoft.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
  • Loading branch information
dphadke-msft authored and jforissier committed Jun 14, 2022
1 parent 488c73c commit 3efc099
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/bin_to_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def main():
if args.text and i != size - 1 and bytes[i] == b'\0':
print('Error: null byte encountered in text file')
sys.exit(1)
f.write('0x' + '{:02x}'.format(bytes[i]) + ',')
f.write(hex(bytes[i]) + ',')
i = i + 1
if i % 8 == 0 or i == size:
f.write('\n')
Expand Down

0 comments on commit 3efc099

Please sign in to comment.