wfview/pttyhandler.h

79 wiersze
1.9 KiB
C
Czysty Zwykły widok Historia

2021-03-04 20:19:05 +00:00
#ifndef PTTYHANDLER_H
#define PTTYHANDLER_H
#include <QObject>
#include <QMutex>
#include <QDataStream>
2021-05-11 08:38:05 +00:00
#include <QIODevice>
#include <QSocketNotifier>
2021-03-04 20:19:05 +00:00
#include <QtSerialPort/QSerialPort>
#include "rigidentities.h"
2021-03-04 20:19:05 +00:00
// This class abstracts the comm port in a useful way and connects to
// the command creator and command parser.
class pttyHandler : public QObject
{
Q_OBJECT
public:
2021-05-05 13:11:00 +00:00
pttyHandler(QString portName);
2021-03-04 20:19:05 +00:00
pttyHandler(QString portName, quint32 baudRate);
bool serialError;
~pttyHandler();
private slots:
2021-05-11 08:38:05 +00:00
void receiveDataIn(int fd); // from physical port
2021-03-04 20:19:05 +00:00
void receiveDataFromRigToPtty(const QByteArray& data);
void debugThis();
void receiveFoundRigID(rigCapabilities rigCaps);
2021-03-04 20:19:05 +00:00
signals:
void haveTextMessage(QString message); // status, debug only
void haveDataFromPort(QByteArray data); // emit this when we have data, connect to rigcommander
void haveSerialPortError(const QString port, const QString error);
void haveStatusUpdate(const QString text);
private:
void setupPtty();
void openPort();
void closePort();
void sendDataOut(const QByteArray& writeData); // out to radio
void debugMe();
void hexPrint();
//QDataStream stream;
QByteArray outPortData;
QByteArray inPortData;
//QDataStream outStream;
//QDataStream inStream;
unsigned char buffer[256];
QString portName;
2021-05-13 22:13:48 +00:00
QSerialPort* port = Q_NULLPTR;
2021-03-04 20:19:05 +00:00
qint32 baudRate;
unsigned char stopBits;
bool rolledBack;
int ptfd; // pseudo-terminal file desc.
2021-09-22 09:59:03 +00:00
int ptKeepAlive=0; // Used to keep the pty alive after client disconects.
2021-03-04 20:19:05 +00:00
bool havePt;
QString ptDevSlave;
2021-05-12 08:14:48 +00:00
bool isConnected=false; // port opened
2021-03-04 20:19:05 +00:00
mutable QMutex mutex;
void printHex(const QByteArray& pdata, bool printVert, bool printHoriz);
bool disableTransceive = false;
QSocketNotifier *ptReader = Q_NULLPTR;
quint8 civId=0;
rigCapabilities rigCaps;
2021-03-04 20:19:05 +00:00
};
#endif // PTTYHANDLER_H