Changeset View
Changeset View
Standalone View
Standalone View
testclient/mainwindow.cpp
Show First 20 Lines • Show All 270 Lines • ▼ Show 20 Line(s) | |||||
271 | * of serial ports | 271 | * of serial ports | ||
272 | */ | 272 | */ | ||
273 | void MainWindow::locateSerialPort() | 273 | void MainWindow::locateSerialPort() | ||
274 | { | 274 | { | ||
275 | QStringList ports; | 275 | QStringList ports; | ||
276 | QList<QSerialPortInfo> serialPortInfoList = QSerialPortInfo::availablePorts(); | 276 | QList<QSerialPortInfo> serialPortInfoList = QSerialPortInfo::availablePorts(); | ||
277 | if (!serialPortInfoList.isEmpty()) { | 277 | if (!serialPortInfoList.isEmpty()) { | ||
278 | foreach (const QSerialPortInfo &serialPortInfo, serialPortInfoList) { | 278 | foreach (const QSerialPortInfo &serialPortInfo, serialPortInfoList) { | ||
279 | #ifdef Q_OS_MAC | ||||
280 | //Mac os has callout serial ports starting with cu. they can only recv data. filter them out | ||||
281 | if (!serialPortInfo.portName().startsWith(QStringLiteral("cu."), Qt::CaseInsensitive)) { | ||||
patrickelectric: why Insensitive ? | |||||
because this will cover any all the cu devices (Cu. CU. cU. cu.) iirc on mac os they are Cu in the list and /dev/cu by device. rizzitello: because this will cover any all the cu devices (Cu. CU. cU. cu.) iirc on mac os they are Cu in… | |||||
279 | ports.append(serialPortInfo.portName()); | 282 | ports.append(serialPortInfo.portName()); | ||
280 | } | 283 | } | ||
284 | #else | ||||
285 | ports.append(serialPortInfo.portName()); | ||||
286 | #endif | ||||
287 | } | ||||
281 | if (ports == serialPortList) { | 288 | if (ports == serialPortList) { | ||
282 | return; | 289 | return; | ||
283 | } else { | 290 | } else { | ||
284 | serialPortList.clear(); | 291 | serialPortList.clear(); | ||
285 | serialPortList = ports; | 292 | serialPortList = ports; | ||
286 | ui->serialPortCB->clear(); | 293 | ui->serialPortCB->clear(); | ||
287 | ui->serialPortCB->addItems(serialPortList); | 294 | ui->serialPortCB->addItems(serialPortList); | ||
288 | addLog(tr("Found %1 Ports").arg(QString::number(serialPortList.count()))); | 295 | addLog(tr("Found %1 Ports").arg(QString::number(serialPortList.count()))); | ||
▲ Show 20 Lines • Show All 289 Lines • Show Last 20 Lines |
why Insensitive ?