Skip to content

Commit

Permalink
log small transfers and exit tx thread on lost connection
Browse files Browse the repository at this point in the history
  • Loading branch information
rpatel3001 committed Feb 28, 2024
1 parent 7ec48f1 commit a3feed0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rootfs/scripts/soapy2tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def rx_thread(sdrcfg, rxStream, rxcfg, tx_init, inbufs, rxq):

status = sdr.readStream(rxStream, [inbufs[bufidx]], rxcfg["mtu"])
print(f"[rx] Actual stream transfer size: {status.ret}/{rxcfg['mtu']}")
realmtu = status.ret

while True:
status = sdr.readStream(rxStream, [inbufs[bufidx]], rxcfg["mtu"])
Expand All @@ -55,10 +56,13 @@ def rx_thread(sdrcfg, rxStream, rxcfg, tx_init, inbufs, rxq):
sdr.deactivateStream(rxStream)
sdr.closeStream(rxStream)
if environ.get("EXIT_ON_ERROR"):
print("Quitting script...")
print("[rx] Quitting script...")
interrupt_main()
else:
print("[rx] Quitting thread...")
return
elif samps < realmtu:
print(f"[rx] Got only {samps} samples, expected {realmtu}")

for i in range(len(rxq)):
try:
Expand Down Expand Up @@ -156,6 +160,7 @@ def tx_thread(rxcfg, chancfg, tx_init, inbufs, rxq):
except BaseException:
print(f"[tx {chancfg['idx']}] Disconnected from {addr}")
tx_init[txcfg['idx']].clear()
return


# wrapper to catch exceptions and restart threads
Expand Down

0 comments on commit a3feed0

Please sign in to comment.