Skip to content

Commit

Permalink
mavproxy_link.py: add bytes-available-to-read counter in link stats o…
Browse files Browse the repository at this point in the history
…utput
  • Loading branch information
peterbarker committed Sep 9, 2024
1 parent 8c15c9d commit 97bcd3c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion MAVProxy/modules/mavproxy_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,18 @@ def show_link(self):
except AttributeError:
# some mav objects may not have a "signing" attribute
pass
print("link %s %s (%u packets, %u bytes, %.2fs delay, %u lost, %.1f%% loss, rate:%uB/s%s)" % (

# add an entry for bytes-available-to-read:
bytes_available = ""
try:
import fcntl
sock = master.port
bytes_available = struct.unpack('I', fcntl.ioctl(sock, 0x541B, struct.pack('I', 0)))[0]
bytes_available = f" avail={bytes_available}"
except AttributeError as e:
pass

print("link %s %s (%u packets, %u bytes, %.2fs delay, %u lost, %.1f%% loss, rate:%uB/s%s%s)" % (
self.link_label(master),
status,
self.status.counters['MasterIn'][master.linknum],
Expand All @@ -316,6 +327,7 @@ def show_link(self):
master.packet_loss(),
self.status.bytecounters['MasterIn'][master.linknum].rate(),
sign_string,
bytes_available
))

def reset_link_stats(self):
Expand Down

0 comments on commit 97bcd3c

Please sign in to comment.