kopia lustrzana https://gitlab.com/eliggett/wfview
Fixes for pty
rodzic
ce55c560af
commit
80e0e808e2
|
@ -63,8 +63,10 @@ void pttyHandler::setupPtty()
|
||||||
qDebug(logSerial()) << "Setting up Pseudo Term";
|
qDebug(logSerial()) << "Setting up Pseudo Term";
|
||||||
serialError = false;
|
serialError = false;
|
||||||
port->setPortName(portName);
|
port->setPortName(portName);
|
||||||
//port->setBaudRate(baudRate);
|
#ifdef Q_OS_WIN
|
||||||
//port->setStopBits(QSerialPort::OneStop);// OneStop is other option
|
port->setBaudRate(baudRate);
|
||||||
|
port->setStopBits(QSerialPort::OneStop);// OneStop is other option
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,11 +133,11 @@ pttyHandler::~pttyHandler()
|
||||||
|
|
||||||
void pttyHandler::receiveDataFromRigToPtty(const QByteArray& data)
|
void pttyHandler::receiveDataFromRigToPtty(const QByteArray& data)
|
||||||
{
|
{
|
||||||
if (data[2] != (char)0xE1 && data[3] != (char)0xE1)
|
if ((unsigned char)data[2] != (unsigned char)0xE1 && (unsigned char)data[3] != (unsigned char)0xE1)
|
||||||
{
|
{
|
||||||
// send to the pseudo port as well
|
// send to the pseudo port as well
|
||||||
// index 2 is dest, 0xE1 is wfview, 0xE0 is assumed to be the other device.
|
// index 2 is dest, 0xE1 is wfview, 0xE0 is assumed to be the other device.
|
||||||
// Maybe change to "Not 0xE1"
|
// Changed to "Not 0xE1"
|
||||||
// 0xE1 = wfview
|
// 0xE1 = wfview
|
||||||
// 0xE0 = pseudo-term host
|
// 0xE0 = pseudo-term host
|
||||||
// 0x00 = broadcast to all
|
// 0x00 = broadcast to all
|
||||||
|
@ -146,11 +148,10 @@ void pttyHandler::receiveDataFromRigToPtty(const QByteArray& data)
|
||||||
|
|
||||||
void pttyHandler::sendDataOut(const QByteArray& writeData)
|
void pttyHandler::sendDataOut(const QByteArray& writeData)
|
||||||
{
|
{
|
||||||
|
|
||||||
qint64 bytesWritten = 0;
|
qint64 bytesWritten = 0;
|
||||||
|
|
||||||
qDebug(logSerial()) << "Data to term:";
|
//qDebug(logSerial()) << "Data to pseudo term:";
|
||||||
printHex(writeData, false, true);
|
//printHex(writeData, false, true);
|
||||||
|
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
|
|
||||||
|
@ -181,12 +182,22 @@ void pttyHandler::receiveDataIn()
|
||||||
// good!
|
// good!
|
||||||
port->commitTransaction();
|
port->commitTransaction();
|
||||||
|
|
||||||
// filter 1A 05 01 12 = C-IV transceive command before forwarding on.
|
// filter 1A 05 01 12/27 = C-IV transceive command before forwarding on.
|
||||||
if (inPortData.length()>6 && inPortData[4] != (char)0x1A && inPortData[5] != (char)0x05 && inPortData[6] != (char)0x01 && inPortData[7] != (char)0x12)
|
if (inPortData.length() > 7 && (inPortData.mid(4, 4) == QByteArrayLiteral("\x1a\x05\x01\x12") && (inPortData.mid(4, 4) == QByteArrayLiteral("\x1a\x05\x01\x27"))))
|
||||||
|
{
|
||||||
|
//qDebug(logSerial()) << "Filtered transceive command";
|
||||||
|
//printHex(inPortData, false, true);
|
||||||
|
QByteArray reply= QByteArrayLiteral("\xfe\xfe\x00\x00\xfb\xfd");
|
||||||
|
reply[2] = inPortData[3];
|
||||||
|
reply[3] = inPortData[2];
|
||||||
|
sendDataOut(inPortData); // Echo command back
|
||||||
|
sendDataOut(reply);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
emit haveDataFromPort(inPortData);
|
emit haveDataFromPort(inPortData);
|
||||||
qDebug(logSerial()) << "Data from pseudo term:";
|
//qDebug(logSerial()) << "Data from pseudo term:";
|
||||||
printHex(inPortData, false, true);
|
//printHex(inPortData, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rolledBack)
|
if (rolledBack)
|
||||||
|
|
|
@ -61,7 +61,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, qu
|
||||||
connect(this, SIGNAL(dataForComm(QByteArray)), comm, SLOT(receiveDataFromUserToRig(QByteArray)));
|
connect(this, SIGNAL(dataForComm(QByteArray)), comm, SLOT(receiveDataFromUserToRig(QByteArray)));
|
||||||
|
|
||||||
// data from the rig to the ptty:
|
// data from the rig to the ptty:
|
||||||
connect(this, SIGNAL(dataForComm(QByteArray)), ptty, SLOT(receiveDataFromRigToPtty(QByteArray)));
|
connect(comm, SIGNAL(haveDataFromPort(QByteArray)), ptty, SLOT(receiveDataFromRigToPtty(QByteArray)));
|
||||||
|
|
||||||
connect(comm, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString)));
|
connect(comm, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString)));
|
||||||
connect(ptty, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString)));
|
connect(ptty, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString)));
|
||||||
|
@ -105,30 +105,27 @@ void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs)
|
||||||
connect(this, SIGNAL(initUdpHandler()), udp, SLOT(init()));
|
connect(this, SIGNAL(initUdpHandler()), udp, SLOT(init()));
|
||||||
connect(udpHandlerThread, SIGNAL(finished()), udp, SLOT(deleteLater()));
|
connect(udpHandlerThread, SIGNAL(finished()), udp, SLOT(deleteLater()));
|
||||||
|
|
||||||
|
|
||||||
udpHandlerThread->start();
|
udpHandlerThread->start();
|
||||||
|
|
||||||
emit initUdpHandler();
|
emit initUdpHandler();
|
||||||
|
|
||||||
|
//this->rigSerialPort = rigSerialPort;
|
||||||
this->rigSerialPort = rigSerialPort;
|
//this->rigBaudRate = rigBaudRate;
|
||||||
this->rigBaudRate = rigBaudRate;
|
|
||||||
|
|
||||||
ptty = new pttyHandler();
|
ptty = new pttyHandler();
|
||||||
|
|
||||||
|
// Data from UDP to the program
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
connect(udp, SIGNAL(haveDataFromPort(QByteArray)), this, SLOT(handleNewData(QByteArray)));
|
connect(udp, SIGNAL(haveDataFromPort(QByteArray)), this, SLOT(handleNewData(QByteArray)));
|
||||||
|
|
||||||
// data from the rig to the ptty:
|
// data from the rig to the ptty:
|
||||||
connect(udp, SIGNAL(haveDataFromPort(QByteArray)), ptty, SLOT(receiveDataFromRigToPtty(QByteArray)));
|
connect(udp, SIGNAL(haveDataFromPort(QByteArray)), ptty, SLOT(receiveDataFromRigToPtty(QByteArray)));
|
||||||
|
|
||||||
|
// Audio from UDP
|
||||||
connect(udp, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket)));
|
connect(udp, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket)));
|
||||||
|
|
||||||
|
// data from the program to the rig:
|
||||||
// data from the program to the comm port:
|
|
||||||
connect(this, SIGNAL(dataForComm(QByteArray)), udp, SLOT(receiveDataFromUserToRig(QByteArray)));
|
connect(this, SIGNAL(dataForComm(QByteArray)), udp, SLOT(receiveDataFromUserToRig(QByteArray)));
|
||||||
|
|
||||||
// data from the ptty to the rig:
|
// data from the ptty to the rig:
|
||||||
connect(ptty, SIGNAL(haveDataFromPort(QByteArray)), udp, SLOT(receiveDataFromUserToRig(QByteArray)));
|
connect(ptty, SIGNAL(haveDataFromPort(QByteArray)), udp, SLOT(receiveDataFromUserToRig(QByteArray)));
|
||||||
|
|
||||||
|
@ -167,6 +164,7 @@ void rigCommander::closeComm()
|
||||||
if (ptty != Q_NULLPTR) {
|
if (ptty != Q_NULLPTR) {
|
||||||
delete ptty;
|
delete ptty;
|
||||||
}
|
}
|
||||||
|
ptty = Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rigCommander::setup()
|
void rigCommander::setup()
|
||||||
|
|
Ładowanie…
Reference in New Issue