1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

AMBR feature: fixed TTY devices search to limit it to TTYUSB device to avoid conflict with PlutoSDR for example

This commit is contained in:
f4exb 2022-05-31 02:11:28 +02:00
parent 1552b70681
commit 9835604f30

View File

@ -31,6 +31,7 @@
#include <termios.h> #include <termios.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <linux/serial.h> #include <linux/serial.h>
#include "util/serialutil.h"
#endif #endif
#include <chrono> #include <chrono>
@ -95,35 +96,20 @@ void AMBEEngine::scan(QList<QString>& ambeDevices)
void AMBEEngine::getComList() void AMBEEngine::getComList()
{ {
qDebug("AMBEEngine::getComList: Linux"); qDebug("AMBEEngine::getComList: Linux");
int n;
struct dirent **namelist;
m_comList.clear(); m_comList.clear();
m_comList8250.clear(); m_comList8250.clear();
const char* sysdir = "/sys/class/tty/"; const char* sysdir = "/sys/class/tty/";
// Scan through /sys/class/tty - it contains all tty-devices in the system std::vector<std::string> comPorts;
n = scandir(sysdir, &namelist, NULL, alphasort); SerialUtil::getComPorts(comPorts, "ttyUSB[0-9]+"); // in Linux the AMBE devices will be listed as ttyUSBx
if (n < 0) for (std::vector<std::string>::iterator it = comPorts.begin(); it != comPorts.end(); ++it)
{ {
perror("scandir"); // Construct full absolute file path
} std::string devicedir = sysdir;
else it->erase(0,5); // remove /dev/
{ devicedir += *it;
while (n--) // Register the device
{ register_comport(m_comList, m_comList8250, devicedir);
if (strcmp(namelist[n]->d_name, "..") && strcmp(namelist[n]->d_name, "."))
{
// Construct full absolute file path
std::string devicedir = sysdir;
devicedir += namelist[n]->d_name;
// Register the device
register_comport(m_comList, m_comList8250, devicedir);
}
free(namelist[n]);
}
free(namelist);
} }
// Only non-serial8250 has been added to comList without any further testing // Only non-serial8250 has been added to comList without any further testing