blob: b0501e5a39879b8ec2d082a53547fdf507c3a973 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import struct
def barray_to_s16(barray):
integers = struct.unpack('h', barray)
return integers[0]
def u16_to_hex(value):
return '0x' + (struct.pack('>H', value).hex())
def barray_to_u16_hex(barray):
count = len(barray)//2
integers = struct.unpack('H'*count, barray)
return [u16_to_hex(x) for x in integers]
def u32_to_hex(value):
return '0x' + (struct.pack('>I', value).hex())
def barray_to_u32_hex(barray):
count = len(barray)//4
integers = struct.unpack('I'*count, barray)
return [u32_to_hex(x) for x in integers]
|