Skip to content
Snippets Groups Projects
Commit 331f2e71 authored by Greg Quinn's avatar Greg Quinn
Browse files

Allow callables in pkted

parent bffa1775
No related branches found
No related tags found
No related merge requests found
......@@ -27,9 +27,14 @@ def edit_packets(file_path, specs):
ini = spec.start_bit
sz = spec.num_bits
fin = ini + sz
new_arr = np.asarray(spec.new_value)
new_arr = new_arr.astype(new_arr.dtype.newbyteorder('>'))
bits[ini:fin] = np.unpackbits(new_arr[None].view(np.uint8))[-sz:]
if callable(spec.new_value):
old_value = bits[ini:fin].copy()
new_value = spec.new_value(old_value)
else:
new_value = np.asarray(spec.new_value)
new_value = new_value.astype(new_value.dtype.newbyteorder('>'))
new_value = np.unpackbits(new_value[None].view(np.uint8))[-sz:]
bits[ini:fin] = new_value
pkt.write(np.packbits(bits).tobytes())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment