Compare commits

..

10 Commits

Author SHA1 Message Date
1897e8237a Add watcher for switching on/off modem 2024-11-13 15:02:14 +01:00
d5693cb2b1 Merge branch 'master' into palanga-switch-terminal-on-off 2024-11-13 14:18:45 +01:00
d3b1046a9f onCCWakeGpioChanged():
Use commands credit_switchWake/switchPower to reboot cc-terminal.
2024-11-13 13:28:04 +01:00
a98ddbdb85 Changed file name to check for cc-terminal rebbot to /run/powerctrl_cc. 2024-11-13 13:27:13 +01:00
91a0f88cd9 hwapi::onCCWakeGpioChanged():
when switching cc-terminal off, send 0 to watch-file (watched by a
	filesystem watcher).
	when switching cc-terminal on, send 1 to watch-file (watched by a
	filesystem watcher).
2024-11-11 16:20:15 +01:00
c31b38917a Use QSettings to get watch.txt file path.
onCCWakeGpioChanged():

	remove obsolete code.
2024-11-08 12:06:19 +01:00
fe1351fcca switching on/off modem seems to be enough 2024-11-07 16:09:20 +01:00
dd29fb0762 datif: command 112: accecpt 40ct coin value ("Stadtmünze" Kirchdorf) 2024-11-06 10:09:12 +01:00
c9e5834e29 Merge branch 'proposal_detect_obsolete_data' 2024-10-22 12:26:40 +02:00
8fa6d40a0c Merge branch 'proposal_detect_obsolete_data' of git.mimbach49.de:GerhardHoffmann/DCLibraries into proposal_detect_obsolete_data 2024-10-22 12:25:24 +02:00
3 changed files with 60 additions and 64 deletions

View File

@@ -117,7 +117,9 @@ private:
ReportingThread *m_reportingThread; ReportingThread *m_reportingThread;
DownloadThread *m_downloadThread; DownloadThread *m_downloadThread;
QScopedPointer<QFileSystemWatcher> m_fileSystemWatcher; QScopedPointer<QFileSystemWatcher> m_fileSystemWatcher;
QString m_watchedFile;
QString m_powerctrl_cc;
QString m_powerctrl_modem;
private slots: private slots:
void onCCWakeGpioChanged(QString const &file); void onCCWakeGpioChanged(QString const &file);

View File

@@ -1205,7 +1205,7 @@ char T_datif::loadRecDataFromFrame()
uit2=0; uit2=0;
} }
if (uit2==3 || uit2==5 || uit2==10 || uit2==20 || uit2==50 || uit2==100 || uit2==200 || uit2==500) if (uit2==3 || uit2==5 || uit2==10 || uit2==20 || uit2==40 || uit2==50 || uit2==100 || uit2==200 || uit2==500)
{ {
// valid coin // valid coin
if ((newInsertedAmount != lastInsertedAmount) || uit2>0 ) if ((newInsertedAmount != lastInsertedAmount) || uit2>0 )

View File

@@ -16,6 +16,7 @@
#include <QThread> #include <QThread>
#include <QDebug> #include <QDebug>
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
#include <QSettings>
static uint32_t hwapi_lastStartAmount; static uint32_t hwapi_lastStartAmount;
@@ -58,16 +59,22 @@ hwapi::hwapi(QObject *parent) : QObject(parent)
#error "SLAVE LIB COMPILED INTO MASTER" #error "SLAVE LIB COMPILED INTO MASTER"
#endif #endif
QSettings settings("/opt/app/ATBAPP/ATBQT.ini", QSettings::IniFormat);
m_powerctrl_cc = settings.value("AsyncPOS_CCPlugin/terminal_watch_file",
"/run/powerctrl_cc").toString();
// m_sysfs_remout_out = "/sys/class/leds/wakeupctrl_cc/brightness";
m_watchedFile = "/tmp/watch.txt";
m_fileSystemWatcher.reset(new QFileSystemWatcher()); m_fileSystemWatcher.reset(new QFileSystemWatcher());
if (!m_fileSystemWatcher->addPath(m_watchedFile)) {
qCritical() << "cannot add path for" << m_watchedFile; m_powerctrl_modem = "/run/powerctrl_modem";
m_fileSystemWatcher->addPath(m_powerctrl_modem);
if (!m_fileSystemWatcher->addPath(m_powerctrl_cc)) {
qCritical() << "cannot add path for" << m_powerctrl_cc;
} else { } else {
if (connect(m_fileSystemWatcher.get(), SIGNAL(fileChanged(QString const&)), if (connect(m_fileSystemWatcher.get(), SIGNAL(fileChanged(QString const&)),
this, SLOT(onCCWakeGpioChanged(QString const&)))) { this, SLOT(onCCWakeGpioChanged(QString const&)))) {
qCritical() << "connected file watcher with" << m_watchedFile; qCritical() << "connected file watcher with" << m_powerctrl_cc;
} }
} }
@@ -135,71 +142,58 @@ hwapi::hwapi(QObject *parent) : QObject(parent)
} }
void hwapi::onCCWakeGpioChanged(QString const &fileName) { void hwapi::onCCWakeGpioChanged(QString const &fileName) {
if (fileName == m_watchedFile) {
QFile f(m_watchedFile); qCritical() << __func__ << ":" << __LINE__ << fileName;
if (f.open(QFile::ReadWrite | QFile::Text)) {
if (fileName == m_powerctrl_cc) {
QFile f(m_powerctrl_cc);
if (f.exists() && f.open(QFile::ReadOnly | QFile::Text)) {
QTextStream stream(&f); QTextStream stream(&f);
int sleepTime = 5000;
QString const &content = stream.readAll(); QString const &content = stream.readAll();
if (content.startsWith("0")) { if (content.startsWith("0")) {
if (mod_isGsmPowerOn()) { qCritical() << __func__ << ":" << __LINE__ << "switching cc-terminal off...";
qCritical() << __func__ << ":" << __LINE__; credit_switchWake(false);
mod_switchWake(false); credit_switchPower(false);
mod_switchPower(false);
//if (mod_isGsmPowerOn()) { // try again
// qCritical() << __func__ << ":" << __LINE__;
// stream << "0";
// QThread::msleep(sleepTime);
//}
}
if (cred_isCreditPowerOn()) { // try again
//qCritical() << __func__ << ":" << __LINE__;
//credit_switchWake(false);
//credit_switchPower(false);
//if (cred_isCreditPowerOn()) { // try again
// qCritical() << __func__ << ":" << __LINE__;
// stream << "0";
// QThread::msleep(sleepTime);
//}
}
} else } else
if (content.startsWith("1")) { if (content.startsWith("1")) {
if (mod_isGsmPowerOn() == false) { qCritical() << __func__ << ":" << __LINE__ << "switching cc-terminal on...";
static bool mod_powerOnCalled = false; credit_switchPower(true);
if (mod_powerOnCalled == false) { credit_switchWake(true);
mod_switchPower(true); } else
mod_switchWake(true); if (content.startsWith("2")) {
mod_powerOnCalled = true; qCritical() << __func__ << ":" << __LINE__ << "switching cc-terminal off and on...";
credit_switchWake(false);
credit_switchPower(false);
QThread::sleep(1);
credit_switchPower(true);
credit_switchWake(true);
} else {
qCritical() << "switching cc-terminal watched file contained" << content;
QFile::resize(m_powerctrl_cc, 0); // empty file
} }
//if (mod_isGsmPowerOn() == false) { // try again
// mod_switchWake(true);
// qCritical() << __func__ << ":" << __LINE__;
// stream << "1";
// QThread::msleep(sleepTime);
//}
} }
}
else if (fileName == m_powerctrl_modem) {
if (cred_isCreditPowerOn() == false) { QFile f(m_powerctrl_modem);
static bool cred_powerOnCalled = false; if (f.exists() && f.open(QFile::ReadOnly | QFile::Text)) {
//if (cred_powerOnCalled == false) { QTextStream stream(&f);
// credit_switchPower(true); QString const &content = stream.readAll();
// credit_switchWake(true); if (content.startsWith("0")) {
// cred_powerOnCalled = true; qCritical() << __func__ << ":" << __LINE__ << "switching modem off...";
//} mod_switchWake(false);
//if (cred_isCreditPowerOn() == false) { // try again mod_switchPower(false);
// credit_switchWake(true); } else
// qCritical() << __func__ << ":" << __LINE__; if (content.startsWith("1")) {
// stream << "1"; qCritical() << __func__ << ":" << __LINE__ << "switching modem on...";
// QThread::msleep(sleepTime); mod_switchWake(true);
//} mod_switchPower(true);
}
} else {
qCritical() << "watched file contained" << content;
} }
} }
} else { }
qCritical() << "ERROR watching the wrong file" << fileName; else {
qCritical() << "ERROR watching the wrong file" << fileName << m_powerctrl_cc;
} }
} }