Skip to content

Instantly share code, notes, and snippets.

@Doaxan
Last active August 29, 2025 10:55
Show Gist options
  • Select an option

  • Save Doaxan/504d19d03199103fa5c82672cb7ee86d to your computer and use it in GitHub Desktop.

Select an option

Save Doaxan/504d19d03199103fa5c82672cb7ee86d to your computer and use it in GitHub Desktop.
Convert Bands to Hex [QXDM, diagcmd]
# 7 -> 0000001 -> reverse -> 1000000 -> to dec -> 64 -> to hex -> 40 -> 0x000040
# 3 -> 001 -> reverse -> 100 -> to dec -> 4 -> to hex -> 4 -> 0x000004
import sys
bands = list(map(int, input("Enter bands numbers: ").replace(',', ' ').split()))
bits = [0] * 64
for band in bands:
bits[band - 1] = 1
bits.reverse()
int_bands = int("".join(map(str, bits)), 2)
hex_bands = int_bands.to_bytes(3, byteorder=sys.byteorder).hex(' ')
print("diagcmd 27 ac 1a {}".format(hex_bands))
print("diagcmd 27 ad 1a {}".format(hex_bands))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment