Commit 7350cf532af95c29ec06212503a5f4345c5a166e

Authored by Olli-Pekka Kahilakoski
1 parent 9823122a
Exists in master

FIX: Selecting COM port in UI

Previously, SetCOMPort.GetValue returned a pair (com_port, baud_rate),
which needed to be unpacked into two variables, but the unpacking was
not done.

Change the API so that the dialog object has separate functions GetCOMPort
and GetBaudRate, thus removing the need to unpack the return value.
invesalius/data/trackers.py
@@ -268,9 +268,11 @@ def PlhSerialConnection(tracker_id): @@ -268,9 +268,11 @@ def PlhSerialConnection(tracker_id):
268 trck_init = None 268 trck_init = None
269 dlg_port = dlg.SetCOMPort(select_baud_rate=False) 269 dlg_port = dlg.SetCOMPort(select_baud_rate=False)
270 if dlg_port.ShowModal() == ID_OK: 270 if dlg_port.ShowModal() == ID_OK:
271 - com_port = dlg_port.GetValue() 271 + com_port = dlg_port.GetCOMPort()
  272 + baud_rate = 115200
  273 +
272 try: 274 try:
273 - trck_init = serial.Serial(com_port, baudrate=115200, timeout=0.03) 275 + trck_init = serial.Serial(com_port, baudrate=baud_rate, timeout=0.03)
274 276
275 if tracker_id == 2: 277 if tracker_id == 2:
276 # Polhemus FASTRAK needs configurations first 278 # Polhemus FASTRAK needs configurations first
invesalius/gui/dialogs.py
@@ -4487,15 +4487,16 @@ class SetCOMPort(wx.Dialog): @@ -4487,15 +4487,16 @@ class SetCOMPort(wx.Dialog):
4487 4487
4488 self.CenterOnParent() 4488 self.CenterOnParent()
4489 4489
4490 - def GetValue(self): 4490 + def GetCOMPort(self):
4491 com_port = self.com_port_dropdown.GetString(self.com_port_dropdown.GetSelection()) 4491 com_port = self.com_port_dropdown.GetString(self.com_port_dropdown.GetSelection())
  4492 + return com_port
4492 4493
4493 - if self.select_baud_rate:  
4494 - baud_rate = self.baud_rate_dropdown.GetString(self.baud_rate_dropdown.GetSelection())  
4495 - else:  
4496 - baud_rate = None 4494 + def GetBaudRate(self):
  4495 + if not self.select_baud_rate:
  4496 + return None
4497 4497
4498 - return com_port, baud_rate 4498 + baud_rate = self.baud_rate_dropdown.GetString(self.baud_rate_dropdown.GetSelection())
  4499 + return baud_rate
4499 4500
4500 4501
4501 class ManualWWWLDialog(wx.Dialog): 4502 class ManualWWWLDialog(wx.Dialog):
invesalius/gui/task_navigator.py
@@ -293,7 +293,7 @@ class InnerFoldPanel(wx.Panel): @@ -293,7 +293,7 @@ class InnerFoldPanel(wx.Panel):
293 ctrl.SetValue(False) 293 ctrl.SetValue(False)
294 return 294 return
295 295
296 - com_port = dlg_port.GetValue() 296 + com_port = dlg_port.GetCOMPort()
297 baud_rate = 115200 297 baud_rate = 115200
298 298
299 Publisher.sendMessage('Update serial port', serial_port_in_use=True, com_port=com_port, baud_rate=baud_rate) 299 Publisher.sendMessage('Update serial port', serial_port_in_use=True, com_port=com_port, baud_rate=baud_rate)