Add sensor driver structure

This commit is contained in:
BlackMark 2020-07-04 16:40:06 +02:00
parent 17192e104d
commit c9917a055c
3 changed files with 50 additions and 0 deletions

View File

@ -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();

View File

@ -0,0 +1,38 @@
#include "sensor_driver.hpp"
#include <QSerialPortInfo>
#include <QtDebug>
#include <QtGlobal>
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");
}

View File

@ -0,0 +1,9 @@
#pragma once
class SensorDriver {
public:
SensorDriver();
~SensorDriver();
private:
};