Set buffer sizes only on windows

On Linux, this method doesn't appear to be available.
This commit is contained in:
Rames The Generic committed 2025-01-29 18:13:46 -05:00
1 parent 296bc078eb
commit 6a8bfdccd0
2 files changed
+5 -5

No files matched your search

+5 -3
View File
@@ -10,7 +10,7 @@ from lang_manager import LocaleStringManager as lang
from colorama import Fore
from config import BabbleConfig, BabbleSettingsConfig
from utils.misc_utils import get_camera_index_by_name, list_camera_names
from utils.misc_utils import get_camera_index_by_name, list_camera_names, is_nt
from enum import Enum
import sys
@@ -267,17 +267,19 @@ class Camera:
rate = 115200 if sys.platform == "darwin" else 3000000 # Higher baud rate not working on macOS
conn = serial.Serial(baudrate=rate, port=port, xonxoff=False, dsrdtr=False, rtscts=False)
# Set explicit buffer size for serial.
conn.set_buffer_size(rx_size=BUFFER_SIZE, tx_size=BUFFER_SIZE)
if is_nt:
conn.set_buffer_size(rx_size=BUFFER_SIZE, tx_size=BUFFER_SIZE)
print(
f'{Fore.CYAN}[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.ETVRConnected")} {port}{Fore.RESET}'
)
self.serial_connection = conn
self.camera_status = CameraState.CONNECTED
except Exception:
except Exception as e:
print(
f'{Fore.CYAN}[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.ETVRFailiure")} {port}{Fore.RESET}'
)
print(e)
self.camera_status = CameraState.DISCONNECTED
def clamp_max_res(self, image: MatLike) -> MatLike:
-2
View File
@@ -320,9 +320,7 @@ class CameraWidget:
# self.config.capture_source = value
# if "COM" not in value:
ports = ("COM", "/dev/ttyACM")
print(f"Value: {value}")
if any(x in str(value) for x in ports):
print("SERIAL PORT")
self.config.capture_source = value
else:
cam = get_camera_index_by_name(value) # Set capture_source to the UVC index. Otherwise treat value like an ipcam if we return none