mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
cli_perf: advanced error reporting
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -67,3 +67,7 @@ PVS-Studio.log
|
|||||||
|
|
||||||
# JS packages
|
# JS packages
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
|
# cli_perf script output in case of errors
|
||||||
|
/block.bin
|
||||||
|
/return_block.bin
|
||||||
|
|||||||
@@ -32,16 +32,25 @@ def main():
|
|||||||
|
|
||||||
bytes_to_send = args.length
|
bytes_to_send = args.length
|
||||||
block_size = 1024
|
block_size = 1024
|
||||||
|
success = True
|
||||||
while bytes_to_send:
|
while bytes_to_send:
|
||||||
actual_size = min(block_size, bytes_to_send)
|
actual_size = min(block_size, bytes_to_send)
|
||||||
# can't use 0x03 because that's ASCII ETX, or Ctrl+C
|
# 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)
|
port.write(block)
|
||||||
return_block = port.read(actual_size)
|
return_block = port.read(actual_size)
|
||||||
|
|
||||||
if return_block != block:
|
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
|
break
|
||||||
|
|
||||||
bytes_to_send -= actual_size
|
bytes_to_send -= actual_size
|
||||||
@@ -49,7 +58,8 @@ def main():
|
|||||||
end_time = time()
|
end_time = time()
|
||||||
delta = end_time - start_time
|
delta = end_time - start_time
|
||||||
speed = args.length / delta
|
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.write(b"\x03") # Ctrl+C
|
||||||
port.close()
|
port.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user