Yet another bug?
After running nice for 13:05:54 hours I got this:
Mar 11 06:54:18 raspberrypi bash[476]: 2020/03/11 04:54:37 [CC—] 42069232 B 6999 bps (1) localhost/STALL
Mar 11 06:54:23 raspberrypi bash[476]: 2020/03/11 04:54:42 [CC—] 42073673 B 7206 bps (1) localhost/STALL
Mar 11 06:54:27 raspberrypi bash[476]: Traceback (most recent call last):
Mar 11 06:54:27 raspberrypi bash[476]: File “/usr/local/bin/rtcmadd1008.py”, line 15, in
Mar 11 06:54:27 raspberrypi bash[476]: message_number = (packet_data[0] << 8) + packet_data[1]
Mar 11 06:54:27 raspberrypi bash[476]: IndexError: index out of range
Mar 11 06:54:27 raspberrypi bash[476]: 2020/03/11 06:54:27 socat[478] E write(1, 0xde2e68, 25): Broken pipe
Mar 11 06:54:28 raspberrypi bash[476]: 2020/03/11 04:54:47 [CC—] 42076984 B 6999 bps (1) localhost/STALL
Mar 11 06:54:33 raspberrypi bash[476]: 2020/03/11 04:54:52 [CC—] 42076984 B 0 bps (1) localhost/STALL
Mar 11 06:54:38 raspberrypi bash[476]: 2020/03/11 04:54:57 [CW—] 42076984 B 0 bps (1) timeout
And did not start working anymore.
(The previous bug caused a timeout which did recover after some time…)
Seems like packet_data has been guite short for some reason or another???
How an earth did we get this far this time anyways:
Has the sys.stdin.buffer been empty and
sys.stdin.buffer.read(length)
sys.stdin.buffer.read(3)
have returned empty??
Or maybe the length was 0… I sure don’t know.
But as this thing should keep running 24/7 with high reliably something has to be done?
So maybe just simply:
# Just to make sure that there really is enough data in the packet_data
if len(packet_data) > 2:
message_number = (packet_data[0] << 8) + packet_data[1]
message_number >>= 4