Formats minimally release source files based on former clang-format
This commit is contained in:
387 files changed
+37323
-38074
No files matched your search
@@ -7,8 +7,8 @@
|
||||
namespace LtsSerialPortQuerry
|
||||
{
|
||||
|
||||
LOGGER_T getLogger(const char* name)
|
||||
{
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
static const char ns[] = "SPQ.";
|
||||
std::string loggerName;
|
||||
const size_t len = strlen(name);
|
||||
@@ -18,13 +18,13 @@ LOGGER_T getLogger(const char* name)
|
||||
|
||||
try
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(loggerName);
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(loggerName);
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LtsSerialPortQuerry
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
namespace LtsSerialPortQuerry
|
||||
{
|
||||
typedef NGL::INGLLogger& LOGGER_T;
|
||||
typedef NGL::INGLLogger &LOGGER_T;
|
||||
|
||||
LOGGER_T getLogger(const char* name);
|
||||
LOGGER_T getLogger(const char *name);
|
||||
|
||||
inline LOGGER_T getLogger(const QString& loggerName)
|
||||
{
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
{
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
}
|
||||
}
|
||||
} // namespace LtsSerialPortQuerry
|
||||
+13
-10
@@ -9,24 +9,27 @@
|
||||
|
||||
namespace LtsSerialPortQuerry
|
||||
{
|
||||
class LTSSERIALPORTQUERRY_EXPORT LtsSerialPortQuerry : public QObject
|
||||
{
|
||||
class LTSSERIALPORTQUERRY_EXPORT LtsSerialPortQuerry : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LtsSerialPortQuerry(QObject* parent = nullptr);
|
||||
explicit LtsSerialPortQuerry(QObject *parent = nullptr);
|
||||
|
||||
void setSerialPortSettings(const QSerialPort::BaudRate& baudRate, const QSerialPort::OpenModeFlag& openModeFlag,
|
||||
const QSerialPort::DataBits& dataBits, const QSerialPort::FlowControl& flowControll,
|
||||
const QSerialPort::Parity& parity, const QSerialPort::StopBits& stopBits);
|
||||
void setSerialPortSettings(const QSerialPort::BaudRate &baudRate,
|
||||
const QSerialPort::OpenModeFlag &openModeFlag,
|
||||
const QSerialPort::DataBits &dataBits,
|
||||
const QSerialPort::FlowControl &flowControll,
|
||||
const QSerialPort::Parity &parity,
|
||||
const QSerialPort::StopBits &stopBits);
|
||||
void continueQuerry();
|
||||
void restartQuerry();
|
||||
QSerialPort* currentSerialPort();
|
||||
QSerialPort *currentSerialPort();
|
||||
|
||||
signals:
|
||||
void connectionEstablished();
|
||||
|
||||
private:
|
||||
void querrySerialPort(const QSerialPortInfo& info);
|
||||
void querrySerialPort(const QSerialPortInfo &info);
|
||||
void closeAndDeleteCurrentPort();
|
||||
|
||||
private:
|
||||
@@ -41,7 +44,7 @@ class LTSSERIALPORTQUERRY_EXPORT LtsSerialPortQuerry : public QObject
|
||||
QSerialPort::FlowControl m_flowControll;
|
||||
QSerialPort::Parity m_parity;
|
||||
QSerialPort::StopBits m_stopBits;
|
||||
QSerialPort* m_currentSerialPort;
|
||||
};
|
||||
QSerialPort *m_currentSerialPort;
|
||||
};
|
||||
|
||||
} // namespace LtsSerialPortQuerry
|
||||
+82
-75
@@ -5,59 +5,65 @@
|
||||
namespace LtsSerialPortQuerry
|
||||
{
|
||||
|
||||
LtsSerialPortQuerry::LtsSerialPortQuerry(QObject* parent)
|
||||
: QObject(parent), m_logger(getLogger("LtsSerialPortQuerry")), m_currentQuerry(0),
|
||||
m_baudRate(QSerialPort::Baud115200), m_openModeFlag(QSerialPort::ReadWrite), m_dataBits(QSerialPort::Data8),
|
||||
m_flowControll(QSerialPort::NoFlowControl), m_parity(QSerialPort::NoParity), m_stopBits(QSerialPort::OneStop),
|
||||
m_currentSerialPort(nullptr)
|
||||
{
|
||||
}
|
||||
LtsSerialPortQuerry::LtsSerialPortQuerry(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_logger(getLogger("LtsSerialPortQuerry"))
|
||||
, m_currentQuerry(0)
|
||||
, m_baudRate(QSerialPort::Baud115200)
|
||||
, m_openModeFlag(QSerialPort::ReadWrite)
|
||||
, m_dataBits(QSerialPort::Data8)
|
||||
, m_flowControll(QSerialPort::NoFlowControl)
|
||||
, m_parity(QSerialPort::NoParity)
|
||||
, m_stopBits(QSerialPort::OneStop)
|
||||
, m_currentSerialPort(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void LtsSerialPortQuerry::setSerialPortSettings(const QSerialPort::BaudRate& baudRate,
|
||||
const QIODevice::OpenModeFlag& openModeFlag,
|
||||
const QSerialPort::DataBits& dataBits,
|
||||
const QSerialPort::FlowControl& flowControll,
|
||||
const QSerialPort::Parity& parity,
|
||||
const QSerialPort::StopBits& stopBits)
|
||||
{
|
||||
void LtsSerialPortQuerry::setSerialPortSettings(const QSerialPort::BaudRate &baudRate,
|
||||
const QIODevice::OpenModeFlag &openModeFlag,
|
||||
const QSerialPort::DataBits &dataBits,
|
||||
const QSerialPort::FlowControl &flowControll,
|
||||
const QSerialPort::Parity &parity,
|
||||
const QSerialPort::StopBits &stopBits)
|
||||
{
|
||||
m_baudRate = baudRate;
|
||||
m_openModeFlag = openModeFlag;
|
||||
m_dataBits = dataBits;
|
||||
m_flowControll = flowControll;
|
||||
m_parity = parity;
|
||||
m_stopBits = stopBits;
|
||||
}
|
||||
}
|
||||
|
||||
void LtsSerialPortQuerry::continueQuerry()
|
||||
{
|
||||
void LtsSerialPortQuerry::continueQuerry()
|
||||
{
|
||||
m_currentQuerry++;
|
||||
if (m_currentQuerry >= m_serialPortInfos.size())
|
||||
{
|
||||
|
||||
restartQuerry();
|
||||
return;
|
||||
restartQuerry();
|
||||
return;
|
||||
}
|
||||
querrySerialPort(m_serialPortInfos.at(m_currentQuerry));
|
||||
}
|
||||
}
|
||||
|
||||
void LtsSerialPortQuerry::restartQuerry()
|
||||
{
|
||||
void LtsSerialPortQuerry::restartQuerry()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "restart querry ";
|
||||
m_serialPortInfos = QSerialPortInfo::availablePorts();
|
||||
m_currentQuerry = 0;
|
||||
if (m_serialPortInfos.size())
|
||||
querrySerialPort(m_serialPortInfos.at(m_currentQuerry));
|
||||
querrySerialPort(m_serialPortInfos.at(m_currentQuerry));
|
||||
else
|
||||
QTimer::singleShot(1000, this, &LtsSerialPortQuerry::restartQuerry);
|
||||
}
|
||||
QTimer::singleShot(1000, this, &LtsSerialPortQuerry::restartQuerry);
|
||||
}
|
||||
|
||||
QSerialPort* LtsSerialPortQuerry::currentSerialPort()
|
||||
{
|
||||
QSerialPort *LtsSerialPortQuerry::currentSerialPort()
|
||||
{
|
||||
return m_currentSerialPort;
|
||||
}
|
||||
}
|
||||
|
||||
void LtsSerialPortQuerry::querrySerialPort(const QSerialPortInfo& info)
|
||||
{
|
||||
void LtsSerialPortQuerry::querrySerialPort(const QSerialPortInfo &info)
|
||||
{
|
||||
closeAndDeleteCurrentPort();
|
||||
m_currentSerialPort = new QSerialPort(info, this);
|
||||
m_currentSerialPort->setBaudRate(m_baudRate);
|
||||
@@ -66,75 +72,76 @@ void LtsSerialPortQuerry::querrySerialPort(const QSerialPortInfo& info)
|
||||
m_currentSerialPort->setStopBits(m_stopBits);
|
||||
m_currentSerialPort->setFlowControl(m_flowControll);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Try opening Comport:" << m_currentSerialPort->portName()
|
||||
<< " index is: " << m_currentQuerry;
|
||||
DEBUG_LOG(m_logger) << "Try opening Comport:" << m_currentSerialPort->portName() << " index is: " << m_currentQuerry;
|
||||
|
||||
if (!m_currentSerialPort->open(QSerialPort::ReadWrite))
|
||||
{
|
||||
|
||||
DEBUG_LOG(m_logger) << "Oppening failed query next";
|
||||
DEBUG_LOG(m_logger) << "Oppening failed query next";
|
||||
|
||||
continueQuerry();
|
||||
continueQuerry();
|
||||
}
|
||||
else
|
||||
{
|
||||
connect(m_currentSerialPort, &QSerialPort::errorOccurred, this, &LtsSerialPortQuerry::onSerialPortError,
|
||||
Qt::UniqueConnection);
|
||||
DEBUG_LOG(m_logger) << "Oppened comport" << m_currentSerialPort->portName();
|
||||
emit connectionEstablished();
|
||||
connect(m_currentSerialPort, &QSerialPort::errorOccurred, this, &LtsSerialPortQuerry::onSerialPortError, Qt::UniqueConnection);
|
||||
DEBUG_LOG(m_logger) << "Oppened comport" << m_currentSerialPort->portName();
|
||||
emit connectionEstablished();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LtsSerialPortQuerry::closeAndDeleteCurrentPort()
|
||||
{
|
||||
void LtsSerialPortQuerry::closeAndDeleteCurrentPort()
|
||||
{
|
||||
if (m_currentSerialPort)
|
||||
{
|
||||
m_currentSerialPort->disconnect();
|
||||
if (m_currentSerialPort->isOpen())
|
||||
m_currentSerialPort->close();
|
||||
m_currentSerialPort->deleteLater();
|
||||
m_currentSerialPort->disconnect();
|
||||
if (m_currentSerialPort->isOpen())
|
||||
m_currentSerialPort->close();
|
||||
m_currentSerialPort->deleteLater();
|
||||
|
||||
m_currentSerialPort = nullptr;
|
||||
m_currentSerialPort = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LtsSerialPortQuerry::onSerialPortError(QSerialPort::SerialPortError serialPortError)
|
||||
{
|
||||
void LtsSerialPortQuerry::onSerialPortError(QSerialPort::SerialPortError serialPortError)
|
||||
{
|
||||
|
||||
if (!m_currentSerialPort)
|
||||
return;
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "Spontaneous error " << serialPortError << " doesn't have to be an error ...";
|
||||
|
||||
const QString errStr(QStringLiteral("QSerialPort::SerialPortError ") + QString::number(serialPortError) +
|
||||
QStringLiteral(" from serial port ") + m_currentSerialPort->portName() +
|
||||
QStringLiteral(" error: ") + m_currentSerialPort->errorString());
|
||||
const QString errStr(QStringLiteral("QSerialPort::SerialPortError ") + QString::number(serialPortError) + QStringLiteral(" from serial port ") +
|
||||
m_currentSerialPort->portName() + QStringLiteral(" error: ") + m_currentSerialPort->errorString());
|
||||
|
||||
switch (serialPortError)
|
||||
{
|
||||
case QSerialPort::SerialPortError::NoError: {
|
||||
case QSerialPort::SerialPortError::NoError:
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
case QSerialPort::SerialPortError::DeviceNotFoundError:
|
||||
case QSerialPort::SerialPortError::PermissionError:
|
||||
case QSerialPort::SerialPortError::OpenError:
|
||||
case QSerialPort::SerialPortError::NotOpenError:
|
||||
case QSerialPort::SerialPortError::UnknownError: {
|
||||
ERROR_LOG(m_logger) << "Closing port and try to reopen it. " << m_currentSerialPort->portName();
|
||||
continueQuerry();
|
||||
break;
|
||||
}
|
||||
case QSerialPort::SerialPortError::DeviceNotFoundError:
|
||||
case QSerialPort::SerialPortError::PermissionError:
|
||||
case QSerialPort::SerialPortError::OpenError:
|
||||
case QSerialPort::SerialPortError::NotOpenError:
|
||||
case QSerialPort::SerialPortError::UnknownError:
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Closing port and try to reopen it. " << m_currentSerialPort->portName();
|
||||
continueQuerry();
|
||||
|
||||
Q_FALLTHROUGH();
|
||||
}
|
||||
case QSerialPort::SerialPortError::UnsupportedOperationError: {
|
||||
ERROR_LOG(m_logger) << errStr;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ERROR_LOG(m_logger) << "Got an Error> " << errStr << "restarting";
|
||||
continueQuerry();
|
||||
Q_FALLTHROUGH();
|
||||
}
|
||||
case QSerialPort::SerialPortError::UnsupportedOperationError:
|
||||
{
|
||||
ERROR_LOG(m_logger) << errStr;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got an Error> " << errStr << "restarting";
|
||||
continueQuerry();
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace LtsSerialPortQuerry
|
||||
+14
-11
@@ -9,18 +9,21 @@
|
||||
|
||||
namespace LtsSerialPortQuerry
|
||||
{
|
||||
class LTSSERIALPORTQUERRY_EXPORT LtsSerialPortQuerry : public QObject
|
||||
{
|
||||
class LTSSERIALPORTQUERRY_EXPORT LtsSerialPortQuerry : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LtsSerialPortQuerry(QObject* parent = nullptr);
|
||||
explicit LtsSerialPortQuerry(QObject *parent = nullptr);
|
||||
|
||||
void setSerialPortSettings(const QSerialPort::BaudRate& baudRate, const QSerialPort::OpenModeFlag& openModeFlag,
|
||||
const QSerialPort::DataBits& dataBits, const QSerialPort::FlowControl& flowControll,
|
||||
const QSerialPort::Parity& parity, const QSerialPort::StopBits& stopBits);
|
||||
void setSerialPortSettings(const QSerialPort::BaudRate &baudRate,
|
||||
const QSerialPort::OpenModeFlag &openModeFlag,
|
||||
const QSerialPort::DataBits &dataBits,
|
||||
const QSerialPort::FlowControl &flowControll,
|
||||
const QSerialPort::Parity &parity,
|
||||
const QSerialPort::StopBits &stopBits);
|
||||
|
||||
void restartQuerry();
|
||||
QSerialPort* currentSerialPort();
|
||||
QSerialPort *currentSerialPort();
|
||||
|
||||
public slots:
|
||||
void continueQuerry();
|
||||
@@ -29,8 +32,8 @@ class LTSSERIALPORTQUERRY_EXPORT LtsSerialPortQuerry : public QObject
|
||||
void connectionEstablished();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void querrySerialPort(const QSerialPortInfo& info);
|
||||
NGL::INGLLogger &m_logger;
|
||||
void querrySerialPort(const QSerialPortInfo &info);
|
||||
void closeAndDeleteCurrentPort();
|
||||
void onSerialPortError(QSerialPort::SerialPortError serialPortError);
|
||||
QList<QSerialPortInfo> m_serialPortInfos;
|
||||
@@ -41,7 +44,7 @@ class LTSSERIALPORTQUERRY_EXPORT LtsSerialPortQuerry : public QObject
|
||||
QSerialPort::FlowControl m_flowControll;
|
||||
QSerialPort::Parity m_parity;
|
||||
QSerialPort::StopBits m_stopBits;
|
||||
QSerialPort* m_currentSerialPort;
|
||||
};
|
||||
QSerialPort *m_currentSerialPort;
|
||||
};
|
||||
|
||||
} // namespace LtsSerialPortQuerry
|
||||
Reference in new issue
Block a user