Skip to content

Commit a68f443

Browse files
authored
Merge pull request Project-Babble#85 from RamesTheGeneric/main
Fix serial connection on Linux
2 parents 494ddbb + 7cbe85f commit a68f443

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

BabbleApp/camera.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from colorama import Fore
1212
from config import BabbleConfig, BabbleSettingsConfig
13-
from utils.misc_utils import is_nt, get_camera_index_by_name, list_camera_names
13+
from utils.misc_utils import get_camera_index_by_name, list_camera_names, is_nt
1414
from enum import Enum
1515
import sys
1616

@@ -86,8 +86,8 @@ def run(self):
8686
self.config.capture_source is not None
8787
and self.config.capture_source != ""
8888
):
89-
capture = str(self.config.capture_source)
90-
if "COM" in capture or "/dev/tty" in capture:
89+
ports = ("COM", "/dev/ttyACM")
90+
if any(x in str(self.config.capture_source) for x in ports):
9191
if (
9292
self.serial_connection is None
9393
or self.camera_status == CameraState.DISCONNECTED
@@ -151,7 +151,7 @@ def run(self):
151151
if should_push and not self.capture_event.wait(timeout=0.02):
152152
continue
153153
if self.config.capture_source is not None:
154-
ports = ("COM", "/dev/tty")
154+
ports = ("COM", "/dev/ttyACM")
155155
if any(x in str(self.config.capture_source) for x in ports):
156156
self.get_serial_camera_picture(should_push)
157157
else:
@@ -275,10 +275,11 @@ def start_serial_connection(self, port):
275275
)
276276
self.serial_connection = conn
277277
self.camera_status = CameraState.CONNECTED
278-
except Exception:
278+
except Exception as e:
279279
print(
280280
f'{Fore.CYAN}[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.ETVRFailiure")} {port}{Fore.RESET}'
281281
)
282+
print(e)
282283
self.camera_status = CameraState.DISCONNECTED
283284

284285
def clamp_max_res(self, image: MatLike) -> MatLike:

BabbleApp/camera_widget.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def render(self, window, event, values):
319319
# if value not in self.camera_list:
320320
# self.config.capture_source = value
321321
# if "COM" not in value:
322-
ports = ("COM", "/dev/tty")
322+
ports = ("COM", "/dev/ttyACM")
323323
if any(x in str(value) for x in ports):
324324
self.config.capture_source = value
325325
else:
@@ -344,7 +344,7 @@ def render(self, window, event, values):
344344
and ".mp4" not in value
345345
and "udp" not in value
346346
and "COM" not in value
347-
and "/dev/tty" not in value
347+
and "/dev/ttyACM" not in value
348348
and value not in self.camera_list
349349
): # If http is not in camera address, add it.
350350
self.config.capture_source = (

0 commit comments

Comments
 (0)