Added automatic IC-7300 serial port search

merge-requests/1/merge
Elliott Liggett 2018-11-29 13:41:42 -08:00
rodzic 5f35610207
commit 0cee949dcf
5 zmienionych plików z 37 dodań i 9 usunięć

Wyświetl plik

@ -46,7 +46,7 @@ commHandler::commHandler(QString portName)
setupComm(); // basic parameters
openPort();
qDebug() << "Serial buffer size: " << port->readBufferSize();
// qDebug() << "Serial buffer size: " << port->readBufferSize();
//port->setReadBufferSize(1024); // manually. 256 never saw any return from the radio. why...
//qDebug() << "Serial buffer size: " << port->readBufferSize();

Wyświetl plik

@ -27,13 +27,14 @@
// Note: When sending \x00, must use QByteArray.setRawData()
rigCommander::rigCommander()
rigCommander::rigCommander(unsigned char rigCivAddr, QString rigSerialPort)
{
// construct
// TODO: Bring this parameter and the comm port from the UI.
// Keep in hex in the UI as is done with other CIV apps.
civAddr = 0x94; // address of the radio. Decimal is 148.
// civAddr = 0x94; // address of the radio. Decimal is 148.
civAddr = rigCivAddr; // address of the radio. Decimal is 148.
setCIVAddr(civAddr);
//compCivAddr = 0xE1;
@ -50,7 +51,8 @@ rigCommander::rigCommander()
// total 0
// lrwxrwxrwx 1 root root 13 Nov 24 21:43 pci-0000:00:12.0-usb-0:2.1:1.0-port0 -> ../../ttyUSB0
comm = new commHandler("/dev/ttyUSB0");
// comm = new commHandler("/dev/ttyUSB0");
comm = new commHandler(rigSerialPort);
// data from the comm port to the program:
connect(comm, SIGNAL(haveDataFromPort(QByteArray)), this, SLOT(handleNewData(QByteArray)));

Wyświetl plik

@ -19,7 +19,7 @@ class rigCommander : public QObject
Q_OBJECT
public:
rigCommander();
rigCommander(unsigned char rigCivAddr, QString rigSerialPort);
~rigCommander();
public slots:

Wyświetl plik

@ -36,9 +36,34 @@ wfmain::wfmain(QWidget *parent) :
connect(keyStar, SIGNAL(activated()), this, SLOT(shortcutStar()));
setDefaultColors(); // set of UI colors with defaults populated
loadSettings(); // Look for default settings
setDefaultColors(); // other default options
loadSettings(); // Look for saved preferences
prefs.serialPortRadio = QString("auto");
// if setting for serial port is "auto" then...
if(prefs.serialPortRadio == QString("auto"))
{
// Find the ICOM IC-7300.
qDebug() << "Searching for serial port...";
QDirIterator it("/dev/serial", QStringList() << "*IC-7300*", QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext())
qDebug() << it.next();
// if (it.isEmpty()) // fail or default to ttyUSB0 if present
// iterator might not make sense
serialPortRig = it.filePath(); // first? last?
if(serialPortRig.isEmpty())
{
qDebug() << "Cannot find valid serial port. Trying /dev/ttyUSB0";
serialPortRig = QString("/dev/ttyUSB0");
}
// end finding the 7300 code
} else {
serialPortRig = prefs.serialPortRadio;
}
plot = ui->plot; // rename it waterfall.
wf = ui->waterfall;
tracer = new QCPItemTracer(plot);
@ -80,7 +105,7 @@ wfmain::wfmain(QWidget *parent) :
ui->statusBar->showMessage("Ready", 2000);
// comm = new commHandler();
rig = new rigCommander();
rig = new rigCommander(prefs.radioCIVAddr, serialPortRig );
rigThread = new QThread(this);
rig->moveToThread(rigThread);
@ -201,7 +226,7 @@ void wfmain::setDefPrefs()
defPrefs.useDarkMode = true;
defPrefs.drawPeaks = true;
defPrefs.radioCIVAddr = 0x94;
defPrefs.serialPortRadio = QString("/dev/ttyUSB0");
defPrefs.serialPortRadio = QString("auto");
defPrefs.enablePTT = false;
defPrefs.niceTS = true;

Wyświetl plik

@ -201,6 +201,7 @@ private:
void getInitialRigState();
QWidget * theParent;
QStringList portList;
QString serialPortRig;
QShortcut *keyF11;
QShortcut *keyF1;