This commit is contained in:
Raoul Snyman 2014-03-20 17:43:51 +02:00
commit 104f418ffd

View File

@ -238,9 +238,17 @@ class MainWindow(QtGui.QMainWindow, UiMainWindow):
self.device_closed = True
self.device.close()
try:
settings.setValue(u'previous-port', self.connect_dialog.get_port())
port = self.connect_dialog.get_port()
settings.setValue(u'previous-port', port)
if isinstance(port, basestring) and port.startswith('COM'):
try:
# On Windows ports are 0-based, so strip the COM and subtract 1 from the port number
port = int(port[3:]) - 1
except (TypeError, ValueError):
QtGui.QMessageBox.critical(self, 'Error opening port', 'Error: Port is not valid')
return
self.device = Serial(
port=self.connect_dialog.get_port(),
port=port,
baudrate=self.connect_dialog.get_baud(),
bytesize=self.connect_dialog.get_data_bits(),
parity=self.connect_dialog.get_parity(),