From c9917a055cd9612f878e208325cdd97f9c77c8e0 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sat, 4 Jul 2020 16:40:06 +0200 Subject: [PATCH] Add sensor driver structure --- AdaptiveBrightness/main.cpp | 3 +++ AdaptiveBrightness/sensor_driver.cpp | 38 ++++++++++++++++++++++++++++ AdaptiveBrightness/sensor_driver.hpp | 9 +++++++ 3 files changed, 50 insertions(+) create mode 100644 AdaptiveBrightness/sensor_driver.cpp create mode 100644 AdaptiveBrightness/sensor_driver.hpp diff --git a/AdaptiveBrightness/main.cpp b/AdaptiveBrightness/main.cpp index 82e4a87..d45c009 100644 --- a/AdaptiveBrightness/main.cpp +++ b/AdaptiveBrightness/main.cpp @@ -5,6 +5,7 @@ #include "AdaptiveBrightness.hpp" #include "log_to_file.hpp" +#include "sensor_driver.hpp" int main(int argc, char* argv[]) { @@ -12,6 +13,8 @@ int main(int argc, char* argv[]) qDebug("Starting application"); + SensorDriver sensorDriver; + QApplication application(argc, argv); AdaptiveBrightness mainWindow; mainWindow.show(); diff --git a/AdaptiveBrightness/sensor_driver.cpp b/AdaptiveBrightness/sensor_driver.cpp new file mode 100644 index 0000000..a2f23ed --- /dev/null +++ b/AdaptiveBrightness/sensor_driver.cpp @@ -0,0 +1,38 @@ +#include "sensor_driver.hpp" + +#include +#include +#include + +SensorDriver::SensorDriver() +{ + qDebug("Initializing sensor driver"); + + const auto serialPortInfos = QSerialPortInfo::availablePorts(); + + qDebug() << "Total number of ports available: " << serialPortInfos.count(); + + const QString blankString = "N/A"; + QString description; + QString manufacturer; + QString serialNumber; + + for(const QSerialPortInfo& serialPortInfo: serialPortInfos) { + description = serialPortInfo.description(); + manufacturer = serialPortInfo.manufacturer(); + serialNumber = serialPortInfo.serialNumber(); + qInfo() << "Port: " << serialPortInfo.portName(); + qInfo() << "Location: " << serialPortInfo.systemLocation(); + qInfo() << "Description: " << (!description.isEmpty() ? description : blankString); + qInfo() << "Manufacturer: " << (!manufacturer.isEmpty() ? manufacturer : blankString); + qInfo() << "Serial number: " << (!serialNumber.isEmpty() ? serialNumber : blankString); + qInfo() << "Vendor Identifier: " << (serialPortInfo.hasVendorIdentifier() ? QByteArray::number(serialPortInfo.vendorIdentifier(), 16) : blankString); + qInfo() << "Product Identifier: "; + qInfo() << (serialPortInfo.hasProductIdentifier() ? QByteArray::number(serialPortInfo.productIdentifier(), 16) : blankString); + } +} + +SensorDriver::~SensorDriver() +{ + qDebug("Destroying sensor driver"); +} diff --git a/AdaptiveBrightness/sensor_driver.hpp b/AdaptiveBrightness/sensor_driver.hpp new file mode 100644 index 0000000..a62fa21 --- /dev/null +++ b/AdaptiveBrightness/sensor_driver.hpp @@ -0,0 +1,9 @@ +#pragma once + +class SensorDriver { + public: + SensorDriver(); + ~SensorDriver(); + + private: +};