Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close serial port #8

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ovos_i2c_detection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ def is_mark_1():
while True:
is_mk1 = ser.readline().decode().rstrip()
if is_mk1 and "Command" in is_mk1:
ser.close()
# This is a Mark 1
return True
break
Comment on lines +66 to 69
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix unreachable code after return statement.

The break statement after the return True is unreachable. The while loop can be simplified since it only needs to read once.

Apply this diff to fix the logic:

-            while True:
+            # Read single response
+            is_mk1 = ser.readline().decode().rstrip()
+            if is_mk1 and "Command" in is_mk1:
+                ser.close()
+                # This is a Mark 1
+                return True
-                is_mk1 = ser.readline().decode().rstrip()
-                if is_mk1 and "Command" in is_mk1:
-                    ser.close()
-                    # This is a Mark 1
-                    return True
-                break
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ser.close()
# This is a Mark 1
return True
break
# Read single response
is_mk1 = ser.readline().decode().rstrip()
if is_mk1 and "Command" in is_mk1:
ser.close()
# This is a Mark 1
return True

ser.close()
return False
except:
return False
Expand Down
Loading