File indexing completed on 2024-05-12 05:51:06
0001 /* 0002 SPDX-FileCopyrightText: 2022 Héctor Mesa Jiménez <wmj.py@gmx.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #pragma once 0007 0008 #include <QProcess> 0009 0010 #include "bus.h" 0011 0012 namespace dap 0013 { 0014 class ProcessBus : public Bus 0015 { 0016 Q_OBJECT 0017 public: 0018 explicit ProcessBus(QObject *parent = nullptr); 0019 ~ProcessBus() override; 0020 0021 QByteArray read() override; 0022 quint16 write(const QByteArray &data) override; 0023 0024 QProcess process; 0025 0026 bool start(const settings::BusSettings &configuration) override; 0027 void close() override; 0028 0029 private: 0030 void onStateChanged(QProcess::ProcessState state); 0031 void onError(QProcess::ProcessError processError); 0032 void onFinished(int exitCode, QProcess::ExitStatus exitStatus); 0033 0034 void readError(); 0035 0036 enum { None, Terminate, Kill } m_tryClose = None; 0037 }; 0038 0039 }