From dc928f77922c9a7fefafc670d99c91cba196b1f9 Mon Sep 17 00:00:00 2001 From: James Bithell Date: Sat, 24 Mar 2018 20:07:32 +0000 Subject: [PATCH] Try and correct this error 24.03.18 19:47:25 (+0000) main Traceback (most recent call last): 24.03.18 19:47:25 (+0000) main File "/usr/src/app/main.py", line 127, in 24.03.18 19:47:25 (+0000) main data = looprequest() 24.03.18 19:47:25 (+0000) main File "/usr/src/app/main.py", line 80, in looprequest 24.03.18 19:47:25 (+0000) main if int(response[0]) != 6: 24.03.18 19:47:25 (+0000) main IndexError: index out of range --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 2eff0b1..f8a1468 100644 --- a/main.py +++ b/main.py @@ -77,7 +77,7 @@ def looprequest(): # log("[ERROR] Data too short") # errorcount = errorcount + 1 # return False - if int(response[0]) != 6: + if (len(response) < 1) or (int(response[0]) != 6): log("[ERROR] Device failed to respond with ASCII ACK") errorcount = errorcount + 1 # Didn't respond with an Ascii acknowlegement