Skip to content

Commit 6a8bfdc

Browse files
Set buffer sizes only on windows
On Linux, this method doesn't appear to be available.
1 parent 296bc07 commit 6a8bfdc

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

BabbleApp/camera.py

+5-3
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 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

@@ -267,17 +267,19 @@ def start_serial_connection(self, port):
267267
rate = 115200 if sys.platform == "darwin" else 3000000 # Higher baud rate not working on macOS
268268
conn = serial.Serial(baudrate=rate, port=port, xonxoff=False, dsrdtr=False, rtscts=False)
269269
# Set explicit buffer size for serial.
270-
conn.set_buffer_size(rx_size=BUFFER_SIZE, tx_size=BUFFER_SIZE)
270+
if is_nt:
271+
conn.set_buffer_size(rx_size=BUFFER_SIZE, tx_size=BUFFER_SIZE)
271272

272273
print(
273274
f'{Fore.CYAN}[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.ETVRConnected")} {port}{Fore.RESET}'
274275
)
275276
self.serial_connection = conn
276277
self.camera_status = CameraState.CONNECTED
277-
except Exception:
278+
except Exception as e:
278279
print(
279280
f'{Fore.CYAN}[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.ETVRFailiure")} {port}{Fore.RESET}'
280281
)
282+
print(e)
281283
self.camera_status = CameraState.DISCONNECTED
282284

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

BabbleApp/camera_widget.py

-2
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,7 @@ def render(self, window, event, values):
320320
# self.config.capture_source = value
321321
# if "COM" not in value:
322322
ports = ("COM", "/dev/ttyACM")
323-
print(f"Value: {value}")
324323
if any(x in str(value) for x in ports):
325-
print("SERIAL PORT")
326324
self.config.capture_source = value
327325
else:
328326
cam = get_camera_index_by_name(value) # Set capture_source to the UVC index. Otherwise treat value like an ipcam if we return none

0 commit comments

Comments
 (0)