Skip to content

Commit

Permalink
Merge pull request #299 from dpaulat/hotfix/linux-serial-port-location
Browse files Browse the repository at this point in the history
Use serial port location on Linux instead of port name
  • Loading branch information
dpaulat authored Nov 24, 2024
2 parents 2029806 + 0683cd2 commit b5ac254
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions scwx-qt/source/scwx/qt/ui/serial_port_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,17 @@ SerialPortDialog::~SerialPortDialog()

std::string SerialPortDialog::serial_port()
{
return p->selectedSerialPort_;
std::string serialPort = p->selectedSerialPort_;

#if !defined(_WIN32)
auto it = p->portInfoMap_.find(p->selectedSerialPort_);
if (it != p->portInfoMap_.cend())
{
serialPort = it->second.systemLocation().toStdString();
}
#endif

return serialPort;
}

int SerialPortDialog::baud_rate()
Expand Down Expand Up @@ -225,7 +235,8 @@ void SerialPortDialog::Impl::UpdateModel()
static const QStringList headerLabels {
tr("Port"), tr("Description"), tr("Device")};
#else
static const QStringList headerLabels {tr("Port"), tr("Description")};
static const QStringList headerLabels {
tr("Port"), tr("Location"), tr("Description")};
#endif

// Clear existing serial ports
Expand Down Expand Up @@ -260,8 +271,11 @@ void SerialPortDialog::Impl::UpdateModel()
new QStandardItem(description),
new QStandardItem(device)});
#else
root->appendRow(
{new QStandardItem(portName), new QStandardItem(description)});
const QString systemLocation = port.second.systemLocation();

root->appendRow({new QStandardItem(portName),
new QStandardItem(systemLocation),
new QStandardItem(description)});
#endif
}

Expand Down

0 comments on commit b5ac254

Please sign in to comment.