Я пытаюсь создать пакет (поле адаптации)
Я пытаюсь создать пакет PCR, но янемного запутан в битовых операторах Python ....
adapt_header_3 = (0x1f45db5e4df << (9 + 6)) # adapt_header_3 = 2149055849695
# d5 7d 51 05 7f 27 - This is what the correct result should look like
print(hex(adapt_header_3)) ## << but im getting this for adapt_header_3 0xfa2edaf26f8000
Так что я ожидаю:
d5 7d 51 05 7f 27 (6 байт)
Но я получаю:
fa 2e da f2 6f 80 00 00 (8 байт)
ОБНОВЛЕНИЕ: немного больше теста, использующего это:
adapt_header_1 = 0x7
adapt_header_2 = 0x10
adapt_header_3 = 0x1f45db5e4df
adapt_header = 0x0
adapt_header = adapt_header | (adapt_header_1 << (48 + 8))
adapt_header = adapt_header | (adapt_header_2 << (48))
adapt_header = adapt_header | (adapt_header_3 << (9 + 6))
print(hex(adapt_header))
Чтобы построить это: