Skip to content

Commit 7e6eac1

Browse files
committed
fix serial open exception
1 parent d0d789e commit 7e6eac1

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

thonnycontrib/quecpython/view.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,22 @@ def __init__(self, *args, **kwargs):
122122

123123
def open_serial_handler(self):
124124
if self.serial is None:
125-
# TODO: 流控未处理: self.flow_control_combobox
126-
self.serial = Serial(
127-
port=self.port_combobox.get().split('-')[0],
128-
baudrate=int(self.baudrate_combobox.get()),
129-
bytesize=int(self.bytesize_combobox.get()),
130-
parity=self.parity_combobox.get(),
131-
stopbits=int(self.stopbits_combobox.get())
132-
)
125+
try:
126+
# TODO: 流控未处理: self.flow_control_combobox
127+
self.serial = Serial(
128+
port=self.port_combobox.get().split('-')[0],
129+
baudrate=int(self.baudrate_combobox.get()),
130+
bytesize=int(self.bytesize_combobox.get()),
131+
parity=self.parity_combobox.get(),
132+
stopbits=int(self.stopbits_combobox.get())
133+
)
134+
except Exception as e:
135+
messagebox.showerror(
136+
title='Open Port Failed!',
137+
message='port open failed!\ndetails: {}'.format(str(e)),
138+
master=self
139+
)
140+
return
133141
self.open_serial_button['text'] = '关闭串口'
134142
self.set_com_widgets_state(tk.DISABLED)
135143
else:

0 commit comments

Comments
 (0)