From 6af34bd5314e5141a64415203a99fc0e28738453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Wed, 4 Sep 2019 13:59:24 +0200 Subject: [PATCH] Add tool basic structure and rename to nymea-gpio --- debian/changelog | 2 +- debian/control | 13 ++++++++++-- debian/copyright | 12 +++++++++-- debian/nymea-gpio.tool.install.in | 1 + gpio.cpp => libnymea-gpio/gpio.cpp | 0 gpio.h => libnymea-gpio/gpio.h | 0 .../gpiomonitor.cpp | 13 ++++++++++-- gpiomonitor.h => libnymea-gpio/gpiomonitor.h | 0 .../libnymea-gpio.pro | 11 ++-------- nymea-gpio-tool/main.cpp | 21 +++++++++++++++++++ nymea-gpio-tool/nymea-gpio-tool.pro | 15 +++++++++++++ nymea-gpio.pri | 10 +++++++++ nymea-gpio.pro | 4 ++++ 13 files changed, 86 insertions(+), 16 deletions(-) create mode 100644 debian/nymea-gpio.tool.install.in rename gpio.cpp => libnymea-gpio/gpio.cpp (100%) rename gpio.h => libnymea-gpio/gpio.h (100%) rename gpiomonitor.cpp => libnymea-gpio/gpiomonitor.cpp (91%) rename gpiomonitor.h => libnymea-gpio/gpiomonitor.h (100%) rename libnymea-gpio.pro => libnymea-gpio/libnymea-gpio.pro (82%) create mode 100644 nymea-gpio-tool/main.cpp create mode 100644 nymea-gpio-tool/nymea-gpio-tool.pro create mode 100644 nymea-gpio.pri create mode 100644 nymea-gpio.pro diff --git a/debian/changelog b/debian/changelog index a74681c..99fdfbb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -libnymea-gpio (0.1.0) bionic; urgency=medium +nymea-gpio (1.0.0) bionic; urgency=medium * Initial release. diff --git a/debian/control b/debian/control index 892c31a..06579e7 100644 --- a/debian/control +++ b/debian/control @@ -1,4 +1,4 @@ -Source: libnymea-gpio +Source: nymea-gpio Section: utils Priority: optional Maintainer: Simon Stürz @@ -18,13 +18,22 @@ Depends: ${shlibs:Depends}, Description: Qt 5 based library for GPIO interaction. Qt 5 based library for GPIO interaction. +Package: nymea-gpio-tool +Section: tools +Architecture: any +Depends: ${shlibs:Depends}, + ${misc:Depends}, + libnymea-gpio (= ${binary:Version}) +Description: Qt 5 based tool for GPIO interaction. + Qt 5 based tool for GPIO interaction. + Package: libnymea-gpio-dev Section: libdevel Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, pkg-config, - libnymea-gpio (= ${binary:Version}), + libnymea-gpio (= ${binary:Version}) Description: Qt 5 based library for GPIO interaction - development files Development files for Qt 5 based GPIO library. diff --git a/debian/copyright b/debian/copyright index a5e8d5e..6eb66da 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,11 +1,19 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Author: Simon Stürz -Download: https://github.com/guh/libnymea-gpio +Download: https://github.com/guh/nymea-gpio License: LGPL-3 On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/LGPL-3'. -Files: * +License: GPL-3+ + On Debian systems, the complete text of the GNU General + Public License can be found in `/usr/share/common-licenses/GPL-3'. + +Files: libnymea-gpio/* Copyright: (C) 2019 Simon Stürz License: LGPL-3 + +Files: nymea-gpio-tool/* +Copyright: (C) 2019 Simon Stürz +License: GPL-3+ diff --git a/debian/nymea-gpio.tool.install.in b/debian/nymea-gpio.tool.install.in new file mode 100644 index 0000000..0e8e70b --- /dev/null +++ b/debian/nymea-gpio.tool.install.in @@ -0,0 +1 @@ +nymea-gpio-tool usr/bin diff --git a/gpio.cpp b/libnymea-gpio/gpio.cpp similarity index 100% rename from gpio.cpp rename to libnymea-gpio/gpio.cpp diff --git a/gpio.h b/libnymea-gpio/gpio.h similarity index 100% rename from gpio.h rename to libnymea-gpio/gpio.h diff --git a/gpiomonitor.cpp b/libnymea-gpio/gpiomonitor.cpp similarity index 91% rename from gpiomonitor.cpp rename to libnymea-gpio/gpiomonitor.cpp index 48f69c6..7e66708 100644 --- a/gpiomonitor.cpp +++ b/libnymea-gpio/gpiomonitor.cpp @@ -48,6 +48,9 @@ void GpioMonitor::setEnabled(bool enabled) void GpioMonitor::run() { + // Initialize the current value + setValue(m_gpio->value()); + // Poll the GPIO value until the stop is true while (true) { @@ -78,8 +81,11 @@ bool GpioMonitor::enable() return true; } - QMutexLocker locker(&m_stopMutex); - m_stop = false; + // Init the GPIO + if (!m_gpio->isAvailable()) { + qCWarning(dcGpio()) << "Could not enable GPIO monitor."; + return false; + } if (!m_gpio->exportGpio()) { qCWarning(dcGpio()) << "Could not enable GPIO monitor."; @@ -96,6 +102,9 @@ bool GpioMonitor::enable() return false; } + QMutexLocker locker(&m_stopMutex); + m_stop = false; + // Everything went fine, lets start the poll thread and inform about the result start(); return true; diff --git a/gpiomonitor.h b/libnymea-gpio/gpiomonitor.h similarity index 100% rename from gpiomonitor.h rename to libnymea-gpio/gpiomonitor.h diff --git a/libnymea-gpio.pro b/libnymea-gpio/libnymea-gpio.pro similarity index 82% rename from libnymea-gpio.pro rename to libnymea-gpio/libnymea-gpio.pro index 4d36cfc..bd37280 100644 --- a/libnymea-gpio.pro +++ b/libnymea-gpio/libnymea-gpio.pro @@ -1,15 +1,8 @@ +include(../nymea-gpio.pri) + TARGET = nymea-gpio TEMPLATE = lib -QT -= gui - -QMAKE_CXXFLAGS *= -Werror -std=c++11 -g -QMAKE_LFLAGS *= -std=c++11 - -VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"') - -DEFINES += LIBNYMEAGPIO_LIBRARY - SOURCES += \ gpio.cpp \ gpiomonitor.cpp diff --git a/nymea-gpio-tool/main.cpp b/nymea-gpio-tool/main.cpp new file mode 100644 index 0000000..99aff39 --- /dev/null +++ b/nymea-gpio-tool/main.cpp @@ -0,0 +1,21 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication application(argc, argv); + application.setOrganizationName("guh"); + application.setApplicationName("nymea-gpio-tool"); + application.setApplicationVersion(VERSION_STRING); + + QCommandLineParser parser; + parser.addHelpOption(); + QString applicationDescription = QString("\nnymea-gpio-tool is a command line tool which allowes to interact with GPIOs.\n" + "Version: %1\n" + "Copyright %2 2019 Simon Stürz \n" + "Released under the GNU GENERAL PUBLIC LICENSE Version 3.").arg(application.applicationVersion()).arg(QChar(0xA9)); + parser.setApplicationDescription(applicationDescription); + parser.process(application); + + return application.exec(); +} diff --git a/nymea-gpio-tool/nymea-gpio-tool.pro b/nymea-gpio-tool/nymea-gpio-tool.pro new file mode 100644 index 0000000..302ae7f --- /dev/null +++ b/nymea-gpio-tool/nymea-gpio-tool.pro @@ -0,0 +1,15 @@ +include(../nymea-gpio.pri) + +TARGET = nymea-gpio-tool + +CONFIG += console +CONFIG -= app_bundle +TEMPLATE = app + +INCLUDEPATH += $$top_srcdir/libnymea-gpio/ +LIBS += -L$$top_builddir/libnymea-gpio/ -lnymea-gpio + +SOURCES += main.cpp \ + +target.path = /usr/bin +INSTALLS += target diff --git a/nymea-gpio.pri b/nymea-gpio.pri new file mode 100644 index 0000000..9fb5920 --- /dev/null +++ b/nymea-gpio.pri @@ -0,0 +1,10 @@ +QT -= gui + +QMAKE_CXXFLAGS *= -Werror -std=c++11 -g +QMAKE_LFLAGS *= -std=c++11 + +top_srcdir=$$PWD +top_builddir=$$shadowed($$PWD) + +VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"') +DEFINES += VERSION_STRING=\\\"$${VERSION_STRING}\\\" diff --git a/nymea-gpio.pro b/nymea-gpio.pro new file mode 100644 index 0000000..57b0086 --- /dev/null +++ b/nymea-gpio.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS = libnymea-gpio nymea-gpio-tool +nymea-gpio-tool.depends = libnymea-gpio +