commit 67d9474a8e8befb50244f7be0ee9a53b045739b3
parent b93061917d29f842c78607ceaed7e838e11647bc
Author: Daniel Barlow <dan@telent.net>
Date: Sun, 11 Jan 2026 15:34:18 +0000
display count of bytes received
Diffstat:
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/shore.py b/shore.py
@@ -9,6 +9,7 @@ import select
peer_hostname = None
peer_thread = None
+bytes_recorded = 0
started = False
@@ -23,6 +24,8 @@ def recording_thread_main():
sock.connect((peer_hostname, 5000))
sock.setblocking(0)
interval = 500
+ global bytes_recorded
+ bytes_recorded = 0
while started:
print("sending subscribe")
b = bytes([interval >> 8, interval & 0xff, 0x54, 0x11, 0, 25] )
@@ -32,6 +35,7 @@ def recording_thread_main():
ready = select.select([sock], [], [], timeout - time.time())
if ready[0]:
data = sock.recv(4000)
+ bytes_recorded = bytes_recorded + len(data)
print(f"got data {len(data)}" )
sock.close()
print("recording thread terminated")
@@ -96,6 +100,11 @@ with tg.Connection() as c:
add_host(a, "eculogical.local", instances)
add_host(a, "eculogical2.local", instances)
add_host(a, "eculogical3.local", instances)
+
+ tg.Space(a, instances)
+
+ status = tg.TextView(a, "initializing", instances)
+
tg.Space(a, instances)
buttons = tg.LinearLayout(a, instances, False)
@@ -106,6 +115,15 @@ with tg.Connection() as c:
# start_button.setwidth(tg.View.WRAP_CONTENT)
start_button.setgravity(1, 1)
+ def update_byte_counter():
+ global started
+ while True:
+ label = f"recorded {bytes_recorded} bytes" if started else "not recording"
+ status.settext(label)
+ time.sleep(1)
+
+ threading.Thread(target = update_byte_counter, daemon = True).start()
+
for ev in c.events(): # waits for events from the gui
if ev.type == tg.Event.destroy:
sys.exit()