port configuration corected

main
Kynsight 1 month ago
parent c0a66cbff8
commit a520d8f17f

@ -116,6 +116,9 @@ class UARTConfig:
device: Serial device path (e.g., "/dev/ttyUSB0")
baudrate: Baud rate (e.g., 115200)
data_bits: Data bits (7 or 8)
stop_bits: Stop bits (1 or 2)
parity: Parity ('N', 'E', 'O', 'M', 'S')
buffer_size: RX circular buffer capacity in bytes
read_chunk_size: Max bytes to read per loop iteration
@ -130,6 +133,9 @@ class UARTConfig:
"""
device: str
baudrate: int
data_bits: int = 8
stop_bits: int = 1
parity: str = 'N'
buffer_size: int = 496
read_chunk_size: int = 512
@ -301,12 +307,27 @@ def uart_open(port: UARTPort) -> Status:
return Status.ALREADY_OPEN
try:
# Open serial port
# Map parity
parity_map = {
'N': serial.PARITY_NONE,
'E': serial.PARITY_EVEN,
'O': serial.PARITY_ODD,
'M': serial.PARITY_MARK,
'S': serial.PARITY_SPACE
}
# Open serial port with FULL configuration
port._serial_port = serial.Serial(
port=port.config.device,
baudrate=port.config.baudrate,
bytesize=port.config.data_bits,
parity=parity_map.get(port.config.parity, serial.PARITY_NONE),
stopbits=port.config.stop_bits,
timeout=0.01, # Non-blocking with small timeout
write_timeout=0.5
write_timeout=0.5,
xonxoff=False, # Disable software flow control
rtscts=False, # Disable hardware (RTS/CTS) flow control
dsrdtr=False # Disable hardware (DSR/DTR) flow control
)
# Create RX buffer

@ -469,6 +469,9 @@ class UARTWidget(QWidget):
config = UARTConfig(
device=device,
baudrate=baudrate,
data_bits=int(self.combo_databits.currentText()),
stop_bits=int(self.combo_stopbits.currentText()),
parity='N' if self.combo_parity.currentText() == 'None' else self.combo_parity.currentText()[0],
buffer_size=4096,
stop_mode=stop_mode,
stop_timeout_ms=self.spin_timeout.value(),

Loading…
Cancel
Save