Use serial port location on Linux instead of port name

This commit is contained in:
Dan Paulat 2024-11-24 09:01:57 -06:00
parent 2029806a5f
commit 0683cd2326

View file

@ -168,7 +168,17 @@ SerialPortDialog::~SerialPortDialog()
std::string SerialPortDialog::serial_port() 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() int SerialPortDialog::baud_rate()
@ -225,7 +235,8 @@ void SerialPortDialog::Impl::UpdateModel()
static const QStringList headerLabels { static const QStringList headerLabels {
tr("Port"), tr("Description"), tr("Device")}; tr("Port"), tr("Description"), tr("Device")};
#else #else
static const QStringList headerLabels {tr("Port"), tr("Description")}; static const QStringList headerLabels {
tr("Port"), tr("Location"), tr("Description")};
#endif #endif
// Clear existing serial ports // Clear existing serial ports
@ -260,8 +271,11 @@ void SerialPortDialog::Impl::UpdateModel()
new QStandardItem(description), new QStandardItem(description),
new QStandardItem(device)}); new QStandardItem(device)});
#else #else
root->appendRow( const QString systemLocation = port.second.systemLocation();
{new QStandardItem(portName), new QStandardItem(description)});
root->appendRow({new QStandardItem(portName),
new QStandardItem(systemLocation),
new QStandardItem(description)});
#endif #endif
} }