Add option of popup alert

half-duplex
Phil Taylor 2023-01-05 19:37:53 +00:00
rodzic 373b670482
commit 3e149ee742
14 zmienionych plików z 52 dodań i 29 usunięć

Wyświetl plik

@ -320,7 +320,7 @@ void commHandler::openPort()
qInfo(logSerial()) << "Could not open serial port " << portName << " , please restart."; qInfo(logSerial()) << "Could not open serial port " << portName << " , please restart.";
isConnected = false; isConnected = false;
serialError = true; serialError = true;
emit haveSerialPortError(portName, "Could not open port. Please restart."); emit havePortError(errorType(portName, "Could not open port. Please restart."));
return; return;
} }
} }

Wyświetl plik

@ -9,6 +9,8 @@
#include <QTime> #include <QTime>
#include <QTimer> #include <QTimer>
#include "wfviewtypes.h"
// This class abstracts the comm port in a useful way and connects to // This class abstracts the comm port in a useful way and connects to
// the command creator and command parser. // the command creator and command parser.
@ -39,7 +41,7 @@ signals:
void haveTextMessage(QString message); // status, debug only void haveTextMessage(QString message); // status, debug only
void sendDataOutToPort(const QByteArray &writeData); // not used void sendDataOutToPort(const QByteArray &writeData); // not used
void haveDataFromPort(QByteArray data); // emit this when we have data, connect to rigcommander void haveDataFromPort(QByteArray data); // emit this when we have data, connect to rigcommander
void haveSerialPortError(const QString port, const QString error); void havePortError(errorType err);
void haveStatusUpdate(const QString text); void haveStatusUpdate(const QString text);
private: private:

Wyświetl plik

@ -90,7 +90,7 @@ void pttyHandler::openPort()
qInfo(logSerial()) << "Could not open pseudo terminal port, please restart."; qInfo(logSerial()) << "Could not open pseudo terminal port, please restart.";
isConnected = false; isConnected = false;
serialError = true; serialError = true;
emit haveSerialPortError(portName, "Could not open pseudo terminal port. Please restart."); emit havePortError(errorType(portName, "Could not open pseudo terminal port. Please restart."));
return; return;
} }

Wyświetl plik

@ -10,6 +10,7 @@
#include <QtSerialPort/QSerialPort> #include <QtSerialPort/QSerialPort>
#include "rigidentities.h" #include "rigidentities.h"
#include "wfviewtypes.h"
// This class abstracts the comm port in a useful way and connects to // This class abstracts the comm port in a useful way and connects to
// the command creator and command parser. // the command creator and command parser.
@ -34,7 +35,7 @@ private slots:
signals: signals:
void haveTextMessage(QString message); // status, debug only void haveTextMessage(QString message); // status, debug only
void haveDataFromPort(QByteArray data); // emit this when we have data, connect to rigcommander void haveDataFromPort(QByteArray data); // emit this when we have data, connect to rigcommander
void haveSerialPortError(const QString port, const QString error); void havePortError(errorType err);
void haveStatusUpdate(const QString text); void haveStatusUpdate(const QString text);
private: private:

Wyświetl plik

@ -86,8 +86,8 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, qu
// data from the rig to the ptty: // data from the rig to the ptty:
connect(comm, SIGNAL(haveDataFromPort(QByteArray)), ptty, SLOT(receiveDataFromRigToPtty(QByteArray))); connect(comm, SIGNAL(haveDataFromPort(QByteArray)), ptty, SLOT(receiveDataFromRigToPtty(QByteArray)));
connect(comm, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString))); connect(comm, SIGNAL(havePortError(errorType)), this, SLOT(handlePortError(errorType)));
connect(ptty, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString))); connect(ptty, SIGNAL(havePortError(errotType)), this, SLOT(handlePortError(errorType)));
connect(this, SIGNAL(getMoreDebug()), comm, SLOT(debugThis())); connect(this, SIGNAL(getMoreDebug()), comm, SLOT(debugThis()));
connect(this, SIGNAL(getMoreDebug()), ptty, SLOT(debugThis())); connect(this, SIGNAL(getMoreDebug()), ptty, SLOT(debugThis()));
@ -164,12 +164,12 @@ void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs, aud
connect(udp, SIGNAL(haveBaudRate(quint32)), this, SLOT(receiveBaudRate(quint32))); connect(udp, SIGNAL(haveBaudRate(quint32)), this, SLOT(receiveBaudRate(quint32)));
// Connect for errors/alerts // Connect for errors/alerts
connect(udp, SIGNAL(haveNetworkError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString))); connect(udp, SIGNAL(haveNetworkError(errorType)), this, SLOT(handlePortError(errorType)));
connect(udp, SIGNAL(haveNetworkStatus(networkStatus)), this, SLOT(handleStatusUpdate(networkStatus))); connect(udp, SIGNAL(haveNetworkStatus(networkStatus)), this, SLOT(handleStatusUpdate(networkStatus)));
connect(udp, SIGNAL(haveNetworkAudioLevels(networkAudioLevels)), this, SLOT(handleNetworkAudioLevels(networkAudioLevels))); connect(udp, SIGNAL(haveNetworkAudioLevels(networkAudioLevels)), this, SLOT(handleNetworkAudioLevels(networkAudioLevels)));
connect(ptty, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString))); connect(ptty, SIGNAL(havePortError(errorType)), this, SLOT(handlePortError(errorType)));
connect(this, SIGNAL(getMoreDebug()), ptty, SLOT(debugThis())); connect(this, SIGNAL(getMoreDebug()), ptty, SLOT(debugThis()));
connect(this, SIGNAL(discoveredRigID(rigCapabilities)), ptty, SLOT(receiveFoundRigID(rigCapabilities))); connect(this, SIGNAL(discoveredRigID(rigCapabilities)), ptty, SLOT(receiveFoundRigID(rigCapabilities)));
@ -232,14 +232,14 @@ void rigCommander::process()
// new thread enters here. Do nothing but do check for errors. // new thread enters here. Do nothing but do check for errors.
if(comm!=Q_NULLPTR && comm->serialError) if(comm!=Q_NULLPTR && comm->serialError)
{ {
emit haveSerialPortError(rigSerialPort, QString("Error from commhandler. Check serial port.")); emit havePortError(errorType(rigSerialPort, QString("Error from commhandler. Check serial port.")));
} }
} }
void rigCommander::handleSerialPortError(const QString port, const QString errorText) void rigCommander::handlePortError(errorType err)
{ {
qInfo(logRig()) << "Error using port " << port << " message: " << errorText; qInfo(logRig()) << "Error using port " << err.device << " message: " << err.message;
emit haveSerialPortError(port, errorText); emit havePortError(err);
} }
void rigCommander::handleStatusUpdate(const networkStatus status) void rigCommander::handleStatusUpdate(const networkStatus status)

Wyświetl plik

@ -227,7 +227,7 @@ public slots:
// UDP: // UDP:
void handleNewData(const QByteArray& data); void handleNewData(const QByteArray& data);
void receiveAudioData(const audioPacket& data); void receiveAudioData(const audioPacket& data);
void handleSerialPortError(const QString port, const QString errorText); void handlePortError(errorType err);
void changeLatency(const quint16 value); void changeLatency(const quint16 value);
void dataFromServer(QByteArray data); void dataFromServer(QByteArray data);
void receiveBaudRate(quint32 baudrate); void receiveBaudRate(quint32 baudrate);
@ -249,7 +249,7 @@ public slots:
signals: signals:
// Communication: // Communication:
void commReady(); void commReady();
void haveSerialPortError(const QString port, const QString errorText); void havePortError(errorType err);
void haveStatusUpdate(const networkStatus status); void haveStatusUpdate(const networkStatus status);
void haveNetworkAudioLevels(const networkAudioLevels l); void haveNetworkAudioLevels(const networkAudioLevels l);
void dataForComm(const QByteArray &outData); void dataForComm(const QByteArray &outData);

Wyświetl plik

@ -29,6 +29,7 @@ servermain::servermain(const QString settingsFile)
qRegisterMetaType<QList<radio_cap_packet>>(); qRegisterMetaType<QList<radio_cap_packet>>();
qRegisterMetaType<networkStatus>(); qRegisterMetaType<networkStatus>();
qRegisterMetaType<codecType>(); qRegisterMetaType<codecType>();
qRegisterMetaType<errorType>();
setDefPrefs(); setDefPrefs();
@ -119,7 +120,7 @@ void servermain::makeRig()
connect(radio->rigThread, SIGNAL(finished()), radio->rig, SLOT(deleteLater())); connect(radio->rigThread, SIGNAL(finished()), radio->rig, SLOT(deleteLater()));
radio->rigThread->start(); radio->rigThread->start();
// Rig status and Errors: // Rig status and Errors:
connect(radio->rig, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(receiveSerialPortError(QString, QString))); connect(radio->rig, SIGNAL(havePortError(errorType)), this, SLOT(receivePortError(errorType)));
connect(radio->rig, SIGNAL(haveStatusUpdate(networkStatus)), this, SLOT(receiveStatusUpdate(networkStatus))); connect(radio->rig, SIGNAL(haveStatusUpdate(networkStatus)), this, SLOT(receiveStatusUpdate(networkStatus)));
// Rig comm setup: // Rig comm setup:
@ -328,7 +329,7 @@ void servermain::receiveFoundRigID(rigCapabilities rigCaps)
return; return;
} }
void servermain::receiveSerialPortError(QString port, QString errorText) void servermain::receivePortError(errorType err)
{ {
qInfo(logSystem()) << "servermain: received serial port error for port: " << port << " with message: " << errorText; qInfo(logSystem()) << "servermain: received serial port error for port: " << port << " with message: " << errorText;

Wyświetl plik

@ -175,7 +175,7 @@ private slots:
void receivePTTstatus(bool pttOn); void receivePTTstatus(bool pttOn);
void receiveFoundRigID(rigCapabilities rigCaps); void receiveFoundRigID(rigCapabilities rigCaps);
void receiveSerialPortError(QString port, QString errorText); void receivePortError(errorType err);
void receiveBaudRate(quint32 baudrate); void receiveBaudRate(quint32 baudrate);
void handlePttLimit(); void handlePttLimit();
@ -305,6 +305,7 @@ Q_DECLARE_METATYPE(enum meterKind)
Q_DECLARE_METATYPE(enum spectrumMode) Q_DECLARE_METATYPE(enum spectrumMode)
Q_DECLARE_METATYPE(rigstate*) Q_DECLARE_METATYPE(rigstate*)
Q_DECLARE_METATYPE(codecType) Q_DECLARE_METATYPE(codecType)
Q_DECLARE_METATYPE(errorType)
#endif // WFMAIN_H #endif // WFMAIN_H

Wyświetl plik

@ -325,12 +325,12 @@ void udpHandler::dataReceived()
if (in->type != 0x01) { if (in->type != 0x01) {
if (in->error == 0xffffffff && !streamOpened) if (in->error == 0xffffffff && !streamOpened)
{ {
emit haveNetworkError(radioIP.toString(), "Connection failed, wait a few minutes or reboot the radio."); emit haveNetworkError(errorType(true, radioIP.toString(), "Connection failed\ntry rebooting the radio."));
qInfo(logUdp()) << this->metaObject()->className() << ": Connection failed, wait a few minutes or reboot the radio."; qInfo(logUdp()) << this->metaObject()->className() << ": Connection failed, wait a few minutes or reboot the radio.";
} }
else if (in->error == 0x00000000 && in->disc == 0x01) else if (in->error == 0x00000000 && in->disc == 0x01)
{ {
emit haveNetworkError(radioIP.toString(), "Got radio disconnected."); emit haveNetworkError(errorType(radioIP.toString(), "Got radio disconnected."));
qInfo(logUdp()) << this->metaObject()->className() << ": Got radio disconnected."; qInfo(logUdp()) << this->metaObject()->className() << ": Got radio disconnected.";
if (streamOpened) { if (streamOpened) {
// Close stream connections but keep connection open to the radio. // Close stream connections but keep connection open to the radio.
@ -395,7 +395,7 @@ void udpHandler::dataReceived()
{ {
if (rxSetup.codec >= 0x40 || txSetup.codec >= 0x40) if (rxSetup.codec >= 0x40 || txSetup.codec >= 0x40)
{ {
emit haveNetworkError(QString("UDP"), QString("Opus codec not supported, forcing LPCM16")); emit haveNetworkError(errorType(QString("UDP"), QString("Opus codec not supported, forcing LPCM16")));
if (rxSetup.codec >= 0x40) if (rxSetup.codec >= 0x40)
rxSetup.codec = 0x04; rxSetup.codec = 0x04;
if (txSetup.codec >= 0x40) if (txSetup.codec >= 0x40)
@ -406,7 +406,7 @@ void udpHandler::dataReceived()
if (in->error == 0xfeffffff) if (in->error == 0xfeffffff)
{ {
status.message = "Invalid Username/Password"; emit haveNetworkError(errorType(true, radioIP.toString(), "Invalid Username/Password"));
qInfo(logUdp()) << this->metaObject()->className() << ": Invalid Username/Password"; qInfo(logUdp()) << this->metaObject()->className() << ": Invalid Username/Password";
} }
else if (!isAuthenticated) else if (!isAuthenticated)

Wyświetl plik

@ -62,7 +62,7 @@ public slots:
signals: signals:
void haveDataFromPort(QByteArray data); // emit this when we have data, connect to rigcommander void haveDataFromPort(QByteArray data); // emit this when we have data, connect to rigcommander
void haveAudioData(audioPacket data); // emit this when we have data, connect to rigcommander void haveAudioData(audioPacket data); // emit this when we have data, connect to rigcommander
void haveNetworkError(QString, QString); void haveNetworkError(errorType);
void haveChangeLatency(quint16 value); void haveChangeLatency(quint16 value);
void haveSetVolume(unsigned char value); void haveSetVolume(unsigned char value);
void haveNetworkStatus(networkStatus); void haveNetworkStatus(networkStatus);

Wyświetl plik

@ -74,6 +74,7 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode
qRegisterMetaType<networkStatus>(); qRegisterMetaType<networkStatus>();
qRegisterMetaType<networkAudioLevels>(); qRegisterMetaType<networkAudioLevels>();
qRegisterMetaType<codecType>(); qRegisterMetaType<codecType>();
qRegisterMetaType<errorType>();
haveRigCaps = false; haveRigCaps = false;
@ -493,7 +494,7 @@ void wfmain::makeRig()
rigThread->start(); rigThread->start();
// Rig status and Errors: // Rig status and Errors:
connect(rig, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(receiveSerialPortError(QString, QString))); connect(rig, SIGNAL(havePortError(errorType)), this, SLOT(receivePortError(errorType)));
connect(rig, SIGNAL(haveStatusUpdate(networkStatus)), this, SLOT(receiveStatusUpdate(networkStatus))); connect(rig, SIGNAL(haveStatusUpdate(networkStatus)), this, SLOT(receiveStatusUpdate(networkStatus)));
connect(rig, SIGNAL(haveNetworkAudioLevels(networkAudioLevels)), this, SLOT(receiveNetworkAudioLevels(networkAudioLevels))); connect(rig, SIGNAL(haveNetworkAudioLevels(networkAudioLevels)), this, SLOT(receiveNetworkAudioLevels(networkAudioLevels)));
connect(rig, SIGNAL(requestRadioSelection(QList<radio_cap_packet>)), this, SLOT(radioSelection(QList<radio_cap_packet>))); connect(rig, SIGNAL(requestRadioSelection(QList<radio_cap_packet>)), this, SLOT(radioSelection(QList<radio_cap_packet>)));
@ -673,11 +674,16 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps)
return; return;
} }
void wfmain::receiveSerialPortError(QString port, QString errorText) void wfmain::receivePortError(errorType err)
{ {
qInfo(logSystem()) << "wfmain: received serial port error for port: " << port << " with message: " << errorText; if (err.alert) {
ui->statusBar->showMessage(QString("ERROR: using port ").append(port).append(": ").append(errorText), 10000); QMessageBox::critical(this, err.device, err.message, QMessageBox::Ok);
}
else
{
qInfo(logSystem()) << "wfmain: received error for device: " << err.device << " with message: " << err.message;
ui->statusBar->showMessage(QString("ERROR: using device ").append(err.device).append(": ").append(err.message), 10000);
}
// TODO: Dialog box, exit, etc // TODO: Dialog box, exit, etc
} }

Wyświetl plik

@ -296,7 +296,7 @@ private slots:
void receiveAntennaSel(unsigned char ant, bool rx); void receiveAntennaSel(unsigned char ant, bool rx);
void receiveRigID(rigCapabilities rigCaps); void receiveRigID(rigCapabilities rigCaps);
void receiveFoundRigID(rigCapabilities rigCaps); void receiveFoundRigID(rigCapabilities rigCaps);
void receiveSerialPortError(QString port, QString errorText); void receivePortError(errorType err);
void receiveStatusUpdate(networkStatus status); void receiveStatusUpdate(networkStatus status);
void receiveNetworkAudioLevels(networkAudioLevels l); void receiveNetworkAudioLevels(networkAudioLevels l);
void handlePlotClick(QMouseEvent *); void handlePlotClick(QMouseEvent *);
@ -1076,6 +1076,7 @@ Q_DECLARE_METATYPE(QList<radio_cap_packet>)
Q_DECLARE_METATYPE(QList<spotData>) Q_DECLARE_METATYPE(QList<spotData>)
Q_DECLARE_METATYPE(rigstate*) Q_DECLARE_METATYPE(rigstate*)
Q_DECLARE_METATYPE(codecType) Q_DECLARE_METATYPE(codecType)
Q_DECLARE_METATYPE(errorType)
//void (*wfmain::logthistext)(QString text) = NULL; //void (*wfmain::logthistext)(QString text) = NULL;

Wyświetl plik

@ -20,13 +20,13 @@ Global
{326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Debug|x64.Build.0 = Debug|x64 {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Debug|x64.Build.0 = Debug|x64
{326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|Win32.ActiveCfg = Release|Win32 {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|Win32.ActiveCfg = Release|Win32
{326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|x64.ActiveCfg = Release|x64 {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|x64.ActiveCfg = Release|x64
{326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|x64.Build.0 = Release|x64
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Debug|Win32.ActiveCfg = Debug|Win32 {00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Debug|Win32.ActiveCfg = Debug|Win32
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Debug|Win32.Build.0 = Debug|Win32 {00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Debug|Win32.Build.0 = Debug|Win32
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Debug|x64.ActiveCfg = Debug|x64 {00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Debug|x64.ActiveCfg = Debug|x64
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Release|Win32.ActiveCfg = Release|Win32 {00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Release|Win32.ActiveCfg = Release|Win32
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Release|Win32.Build.0 = Release|Win32 {00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Release|Win32.Build.0 = Release|Win32
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Release|x64.ActiveCfg = Release|x64 {00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Release|x64.ActiveCfg = Release|x64
{00E054F8-A1D4-3ECA-A8D6-DFC8A68AFD56}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

Wyświetl plik

@ -45,6 +45,17 @@ struct timekind {
bool isMinus; bool isMinus;
}; };
struct errorType {
errorType(bool alert, QString message) : alert(alert), message(message) {};
errorType(bool alert, QString device, QString message) : alert(alert), device(device), message(message) {};
errorType(QString device, QString message) : alert(false), device(device), message(message) {};
errorType(QString message) : alert(false), message(message) {};
bool alert;
QString device;
QString message;
};
enum audioType {qtAudio,portAudio,rtAudio}; enum audioType {qtAudio,portAudio,rtAudio};
enum codecType { LPCM, PCMU, OPUS }; enum codecType { LPCM, PCMU, OPUS };