Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+17
-19
@@ -1,6 +1,5 @@
|
||||
|
||||
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
@@ -8,25 +7,24 @@
|
||||
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);
|
||||
loggerName.reserve(sizeof(ns) + len);
|
||||
loggerName.append(ns, sizeof(ns) - 1);
|
||||
loggerName.append(name, len);
|
||||
static const char ns[] = "SPQ.";
|
||||
std::string loggerName;
|
||||
const size_t len = strlen(name);
|
||||
loggerName.reserve(sizeof(ns) + len);
|
||||
loggerName.append(ns, sizeof(ns) - 1);
|
||||
loggerName.append(name, len);
|
||||
|
||||
try
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
|
||||
getNGLLogger(loggerName);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
}
|
||||
try
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(loggerName);
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LtsSerialPortQuerry
|
||||
Executable → Regular
+6
-7
@@ -1,18 +1,17 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
namespace LtsSerialPortQuerry
|
||||
{
|
||||
typedef NGL::INGLLogger &LOGGER_T;
|
||||
typedef NGL::INGLLogger& LOGGER_T;
|
||||
|
||||
LOGGER_T getLogger(const char *name);
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
LOGGER_T getLogger(const char* name);
|
||||
|
||||
inline LOGGER_T getLogger(const QString& loggerName)
|
||||
{
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LtsSerialPortQuerry
|
||||
Executable → Regular
+30
-35
@@ -1,52 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include "ltsserialportquerry_export.h"
|
||||
#include "lts_seri"
|
||||
#include "ltsserialportquerry_export.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QtSerialPort/QtSerialPort>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
|
||||
|
||||
|
||||
#include <QtSerialPort/QtSerialPort>
|
||||
|
||||
namespace LtsSerialPortQuerry
|
||||
{
|
||||
class LTSSERIALPORTQUERRY_EXPORT LtsSerialPortQuerry : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LtsSerialPortQuerry(QObject *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
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 continueQuerry();
|
||||
void restartQuerry();
|
||||
QSerialPort *currentSerialPort();
|
||||
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();
|
||||
|
||||
signals:
|
||||
void connectionEstablished();
|
||||
signals:
|
||||
void connectionEstablished();
|
||||
|
||||
private:
|
||||
void querrySerialPort(const QSerialPortInfo &info);
|
||||
void closeAndDeleteCurrentPort();
|
||||
private:
|
||||
void querrySerialPort(const QSerialPortInfo& info);
|
||||
void closeAndDeleteCurrentPort();
|
||||
|
||||
private:
|
||||
void onSerialPortError(QSerialPort::SerialPortError serialPortError);
|
||||
private:
|
||||
void onSerialPortError(QSerialPort::SerialPortError serialPortError);
|
||||
|
||||
private:
|
||||
QList<QSerialPortInfo> m_serialPortInfos;
|
||||
int m_currentQuerry;
|
||||
QSerialPort::BaudRate m_baudRate;
|
||||
QSerialPort::OpenModeFlag m_openModeFlag;
|
||||
QSerialPort::DataBits m_dataBits;
|
||||
QSerialPort::FlowControl m_flowControll;
|
||||
QSerialPort::Parity m_parity;
|
||||
QSerialPort::StopBits m_stopBits;
|
||||
QSerialPort *m_currentSerialPort;
|
||||
private:
|
||||
QList<QSerialPortInfo> m_serialPortInfos;
|
||||
int m_currentQuerry;
|
||||
QSerialPort::BaudRate m_baudRate;
|
||||
QSerialPort::OpenModeFlag m_openModeFlag;
|
||||
QSerialPort::DataBits m_dataBits;
|
||||
QSerialPort::FlowControl m_flowControll;
|
||||
QSerialPort::Parity m_parity;
|
||||
QSerialPort::StopBits m_stopBits;
|
||||
QSerialPort* m_currentSerialPort;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LtsSerialPortQuerry
|
||||
Executable → Regular
+99
-111
@@ -5,148 +5,136 @@
|
||||
namespace LtsSerialPortQuerry
|
||||
{
|
||||
|
||||
LtsSerialPortQuerry::LtsSerialPortQuerry(QObject *parent)
|
||||
: QObject(parent)
|
||||
, 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_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;
|
||||
m_baudRate = baudRate;
|
||||
m_openModeFlag = openModeFlag;
|
||||
m_dataBits = dataBits;
|
||||
m_flowControll = flowControll;
|
||||
m_parity = parity;
|
||||
m_stopBits = stopBits;
|
||||
}
|
||||
|
||||
void LtsSerialPortQuerry::continueQuerry()
|
||||
{
|
||||
m_currentQuerry++;
|
||||
if (m_currentQuerry>= m_serialPortInfos.size())
|
||||
{
|
||||
|
||||
restartQuerry();
|
||||
return;
|
||||
}
|
||||
querrySerialPort(m_serialPortInfos.at(m_currentQuerry));
|
||||
m_currentQuerry++;
|
||||
if (m_currentQuerry >= m_serialPortInfos.size())
|
||||
{
|
||||
|
||||
restartQuerry();
|
||||
return;
|
||||
}
|
||||
querrySerialPort(m_serialPortInfos.at(m_currentQuerry));
|
||||
}
|
||||
|
||||
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));
|
||||
else
|
||||
QTimer::singleShot(1000, this, &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));
|
||||
else
|
||||
QTimer::singleShot(1000, this, &LtsSerialPortQuerry::restartQuerry);
|
||||
}
|
||||
|
||||
QSerialPort *LtsSerialPortQuerry::currentSerialPort()
|
||||
QSerialPort* LtsSerialPortQuerry::currentSerialPort()
|
||||
{
|
||||
return m_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);
|
||||
m_currentSerialPort->setDataBits(m_dataBits);
|
||||
m_currentSerialPort->setParity(m_parity);
|
||||
m_currentSerialPort->setStopBits(m_stopBits);
|
||||
m_currentSerialPort->setFlowControl(m_flowControll);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Try opening Comport:" << m_currentSerialPort->portName() << " index is: " << m_currentQuerry;
|
||||
|
||||
closeAndDeleteCurrentPort();
|
||||
m_currentSerialPort = new QSerialPort(info, this);
|
||||
m_currentSerialPort->setBaudRate(m_baudRate);
|
||||
m_currentSerialPort->setDataBits(m_dataBits);
|
||||
m_currentSerialPort->setParity(m_parity);
|
||||
m_currentSerialPort->setStopBits(m_stopBits);
|
||||
m_currentSerialPort->setFlowControl(m_flowControll);
|
||||
|
||||
if (!m_currentSerialPort->open(QSerialPort::ReadWrite))
|
||||
{
|
||||
|
||||
DEBUG_LOG(m_logger) << "Oppening failed query next";
|
||||
DEBUG_LOG(m_logger) << "Try opening Comport:" << m_currentSerialPort->portName()
|
||||
<< " index is: " << m_currentQuerry;
|
||||
|
||||
continueQuerry();
|
||||
}else
|
||||
{
|
||||
connect(m_currentSerialPort, &QSerialPort::errorOccurred,
|
||||
this, &LtsSerialPortQuerry::onSerialPortError, Qt::UniqueConnection);
|
||||
DEBUG_LOG(m_logger) << "Oppened comport" << m_currentSerialPort->portName();
|
||||
emit connectionEstablished();
|
||||
}
|
||||
if (!m_currentSerialPort->open(QSerialPort::ReadWrite))
|
||||
{
|
||||
|
||||
DEBUG_LOG(m_logger) << "Oppening failed query next";
|
||||
|
||||
continueQuerry();
|
||||
}
|
||||
else
|
||||
{
|
||||
connect(m_currentSerialPort, &QSerialPort::errorOccurred, this, &LtsSerialPortQuerry::onSerialPortError,
|
||||
Qt::UniqueConnection);
|
||||
DEBUG_LOG(m_logger) << "Oppened comport" << m_currentSerialPort->portName();
|
||||
emit connectionEstablished();
|
||||
}
|
||||
}
|
||||
|
||||
void LtsSerialPortQuerry::closeAndDeleteCurrentPort()
|
||||
{
|
||||
if (m_currentSerialPort)
|
||||
{
|
||||
m_currentSerialPort->disconnect();
|
||||
if (m_currentSerialPort->isOpen())
|
||||
m_currentSerialPort->close();
|
||||
m_currentSerialPort->deleteLater();
|
||||
|
||||
m_currentSerialPort = nullptr;
|
||||
}
|
||||
}
|
||||
if (m_currentSerialPort)
|
||||
{
|
||||
m_currentSerialPort->disconnect();
|
||||
if (m_currentSerialPort->isOpen())
|
||||
m_currentSerialPort->close();
|
||||
m_currentSerialPort->deleteLater();
|
||||
|
||||
m_currentSerialPort = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void LtsSerialPortQuerry::onSerialPortError(QSerialPort::SerialPortError serialPortError)
|
||||
{
|
||||
|
||||
if (!m_currentSerialPort)
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "Spontaneous error " << serialPortError << " doesn't have to be an error ...";
|
||||
if (!m_currentSerialPort)
|
||||
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:
|
||||
{
|
||||
|
||||
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();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (serialPortError)
|
||||
{
|
||||
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();
|
||||
|
||||
Q_FALLTHROUGH();
|
||||
}
|
||||
case QSerialPort::SerialPortError::UnsupportedOperationError: {
|
||||
ERROR_LOG(m_logger) << errStr;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ERROR_LOG(m_logger) << "Got an Error> " << errStr << "restarting";
|
||||
continueQuerry();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace LtsSerialPortQuerry
|
||||
Executable → Regular
+34
-38
@@ -1,57 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include "logger.h"
|
||||
#include "ltsserialportquerry_export.h"
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QtSerialPort/QtSerialPort>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
#include <QtSerialPort/QtSerialPort>
|
||||
|
||||
namespace LtsSerialPortQuerry
|
||||
{
|
||||
class LTSSERIALPORTQUERRY_EXPORT LtsSerialPortQuerry : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LtsSerialPortQuerry(QObject *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
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 restartQuerry();
|
||||
QSerialPort *currentSerialPort();
|
||||
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);
|
||||
|
||||
public slots:
|
||||
void continueQuerry();
|
||||
void restartQuerry();
|
||||
QSerialPort* currentSerialPort();
|
||||
|
||||
signals:
|
||||
void connectionEstablished();
|
||||
public slots:
|
||||
void continueQuerry();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void querrySerialPort(const QSerialPortInfo &info);
|
||||
void closeAndDeleteCurrentPort();
|
||||
signals:
|
||||
void connectionEstablished();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onSerialPortError(QSerialPort::SerialPortError serialPortError);
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void querrySerialPort(const QSerialPortInfo& info);
|
||||
void closeAndDeleteCurrentPort();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QList<QSerialPortInfo> m_serialPortInfos;
|
||||
int m_currentQuerry;
|
||||
QSerialPort::BaudRate m_baudRate;
|
||||
QSerialPort::OpenModeFlag m_openModeFlag;
|
||||
QSerialPort::DataBits m_dataBits;
|
||||
QSerialPort::FlowControl m_flowControll;
|
||||
QSerialPort::Parity m_parity;
|
||||
QSerialPort::StopBits m_stopBits;
|
||||
QSerialPort *m_currentSerialPort;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void onSerialPortError(QSerialPort::SerialPortError serialPortError);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
QList<QSerialPortInfo> m_serialPortInfos;
|
||||
int m_currentQuerry;
|
||||
QSerialPort::BaudRate m_baudRate;
|
||||
QSerialPort::OpenModeFlag m_openModeFlag;
|
||||
QSerialPort::DataBits m_dataBits;
|
||||
QSerialPort::FlowControl m_flowControll;
|
||||
QSerialPort::Parity m_parity;
|
||||
QSerialPort::StopBits m_stopBits;
|
||||
QSerialPort* m_currentSerialPort;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LtsSerialPortQuerry
|
||||
Reference in new issue
Block a user