kopia lustrzana https://gitlab.com/eliggett/wfview
Added automatic IC-7300 serial port search
rodzic
5f35610207
commit
0cee949dcf
|
@ -46,7 +46,7 @@ commHandler::commHandler(QString portName)
|
||||||
|
|
||||||
setupComm(); // basic parameters
|
setupComm(); // basic parameters
|
||||||
openPort();
|
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...
|
//port->setReadBufferSize(1024); // manually. 256 never saw any return from the radio. why...
|
||||||
//qDebug() << "Serial buffer size: " << port->readBufferSize();
|
//qDebug() << "Serial buffer size: " << port->readBufferSize();
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,14 @@
|
||||||
// Note: When sending \x00, must use QByteArray.setRawData()
|
// Note: When sending \x00, must use QByteArray.setRawData()
|
||||||
|
|
||||||
|
|
||||||
rigCommander::rigCommander()
|
rigCommander::rigCommander(unsigned char rigCivAddr, QString rigSerialPort)
|
||||||
{
|
{
|
||||||
// construct
|
// construct
|
||||||
// TODO: Bring this parameter and the comm port from the UI.
|
// TODO: Bring this parameter and the comm port from the UI.
|
||||||
// Keep in hex in the UI as is done with other CIV apps.
|
// 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);
|
setCIVAddr(civAddr);
|
||||||
//compCivAddr = 0xE1;
|
//compCivAddr = 0xE1;
|
||||||
|
@ -50,7 +51,8 @@ rigCommander::rigCommander()
|
||||||
// total 0
|
// total 0
|
||||||
// lrwxrwxrwx 1 root root 13 Nov 24 21:43 pci-0000:00:12.0-usb-0:2.1:1.0-port0 -> ../../ttyUSB0
|
// 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:
|
// data from the comm port to the program:
|
||||||
connect(comm, SIGNAL(haveDataFromPort(QByteArray)), this, SLOT(handleNewData(QByteArray)));
|
connect(comm, SIGNAL(haveDataFromPort(QByteArray)), this, SLOT(handleNewData(QByteArray)));
|
||||||
|
|
|
@ -19,7 +19,7 @@ class rigCommander : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
rigCommander();
|
rigCommander(unsigned char rigCivAddr, QString rigSerialPort);
|
||||||
~rigCommander();
|
~rigCommander();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
33
wfmain.cpp
33
wfmain.cpp
|
@ -36,9 +36,34 @@ wfmain::wfmain(QWidget *parent) :
|
||||||
connect(keyStar, SIGNAL(activated()), this, SLOT(shortcutStar()));
|
connect(keyStar, SIGNAL(activated()), this, SLOT(shortcutStar()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setDefaultColors(); // set of UI colors with defaults populated
|
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.
|
plot = ui->plot; // rename it waterfall.
|
||||||
wf = ui->waterfall;
|
wf = ui->waterfall;
|
||||||
tracer = new QCPItemTracer(plot);
|
tracer = new QCPItemTracer(plot);
|
||||||
|
@ -80,7 +105,7 @@ wfmain::wfmain(QWidget *parent) :
|
||||||
ui->statusBar->showMessage("Ready", 2000);
|
ui->statusBar->showMessage("Ready", 2000);
|
||||||
|
|
||||||
// comm = new commHandler();
|
// comm = new commHandler();
|
||||||
rig = new rigCommander();
|
rig = new rigCommander(prefs.radioCIVAddr, serialPortRig );
|
||||||
rigThread = new QThread(this);
|
rigThread = new QThread(this);
|
||||||
|
|
||||||
rig->moveToThread(rigThread);
|
rig->moveToThread(rigThread);
|
||||||
|
@ -201,7 +226,7 @@ void wfmain::setDefPrefs()
|
||||||
defPrefs.useDarkMode = true;
|
defPrefs.useDarkMode = true;
|
||||||
defPrefs.drawPeaks = true;
|
defPrefs.drawPeaks = true;
|
||||||
defPrefs.radioCIVAddr = 0x94;
|
defPrefs.radioCIVAddr = 0x94;
|
||||||
defPrefs.serialPortRadio = QString("/dev/ttyUSB0");
|
defPrefs.serialPortRadio = QString("auto");
|
||||||
defPrefs.enablePTT = false;
|
defPrefs.enablePTT = false;
|
||||||
defPrefs.niceTS = true;
|
defPrefs.niceTS = true;
|
||||||
|
|
||||||
|
|
1
wfmain.h
1
wfmain.h
|
@ -201,6 +201,7 @@ private:
|
||||||
void getInitialRigState();
|
void getInitialRigState();
|
||||||
QWidget * theParent;
|
QWidget * theParent;
|
||||||
QStringList portList;
|
QStringList portList;
|
||||||
|
QString serialPortRig;
|
||||||
|
|
||||||
QShortcut *keyF11;
|
QShortcut *keyF11;
|
||||||
QShortcut *keyF1;
|
QShortcut *keyF1;
|
||||||
|
|
Ładowanie…
Reference in New Issue