1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 04:34:43 +04:00

Merge remote-tracking branch 'OFW/porta/cli-event-ordering' into dev

This commit is contained in:
MX
2025-04-08 17:50:48 +03:00
7 changed files with 61 additions and 56 deletions

View File

@@ -32,16 +32,27 @@ def main():
bytes_to_send = args.length
block_size = 1024
success = True
while bytes_to_send:
actual_size = min(block_size, bytes_to_send)
# can't use 0x03 because that's ASCII ETX, or Ctrl+C
block = bytes([randint(4, 255) for _ in range(actual_size)])
# block = bytes([randint(4, 255) for _ in range(actual_size)])
block = bytes([4 + (i // 64) for i in range(actual_size)])
port.write(block)
return_block = port.read(actual_size)
if return_block != block:
logger.error("Incorrect block received")
with open("block.bin", "wb") as f:
f.write(block)
with open("return_block.bin", "wb") as f:
f.write(return_block)
logger.error(
"Incorrect block received. Saved to `block.bin' and `return_block.bin'."
)
logger.error(f"{bytes_to_send} bytes left. Aborting.")
success = False
break
bytes_to_send -= actual_size
@@ -49,7 +60,8 @@ def main():
end_time = time()
delta = end_time - start_time
speed = args.length / delta
print(f"Speed: {speed/1024:.2f} KiB/s")
if success:
print(f"Speed: {speed/1024:.2f} KiB/s")
port.write(b"\x03") # Ctrl+C
port.close()