merge-requests/2/head
Phil Taylor 2021-03-05 12:53:23 +00:00
rodzic ce55c560af
commit 80e0e808e2
2 zmienionych plików z 31 dodań i 22 usunięć

Wyświetl plik

@ -63,8 +63,10 @@ void pttyHandler::setupPtty()
qDebug(logSerial()) << "Setting up Pseudo Term";
serialError = false;
port->setPortName(portName);
//port->setBaudRate(baudRate);
//port->setStopBits(QSerialPort::OneStop);// OneStop is other option
#ifdef Q_OS_WIN
port->setBaudRate(baudRate);
port->setStopBits(QSerialPort::OneStop);// OneStop is other option
#endif
}
@ -131,11 +133,11 @@ pttyHandler::~pttyHandler()
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
// 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
// 0xE0 = pseudo-term host
// 0x00 = broadcast to all
@ -146,11 +148,10 @@ void pttyHandler::receiveDataFromRigToPtty(const QByteArray& data)
void pttyHandler::sendDataOut(const QByteArray& writeData)
{
qint64 bytesWritten = 0;
qDebug(logSerial()) << "Data to term:";
printHex(writeData, false, true);
//qDebug(logSerial()) << "Data to pseudo term:";
//printHex(writeData, false, true);
mutex.lock();
@ -181,12 +182,22 @@ void pttyHandler::receiveDataIn()
// good!
port->commitTransaction();
// filter 1A 05 01 12 = 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)
// filter 1A 05 01 12/27 = C-IV transceive command before forwarding on.
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);
qDebug(logSerial()) << "Data from pseudo term:";
printHex(inPortData, false, true);
//qDebug(logSerial()) << "Data from pseudo term:";
//printHex(inPortData, false, true);
}
if (rolledBack)

Wyświetl plik

@ -61,7 +61,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, qu
connect(this, SIGNAL(dataForComm(QByteArray)), comm, SLOT(receiveDataFromUserToRig(QByteArray)));
// 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(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(udpHandlerThread, SIGNAL(finished()), udp, SLOT(deleteLater()));
udpHandlerThread->start();
emit initUdpHandler();
this->rigSerialPort = rigSerialPort;
this->rigBaudRate = rigBaudRate;
//this->rigSerialPort = rigSerialPort;
//this->rigBaudRate = rigBaudRate;
ptty = new pttyHandler();
// Data from UDP to the program
connect(udp, SIGNAL(haveDataFromPort(QByteArray)), this, SLOT(handleNewData(QByteArray)));
// data from the rig to the ptty:
connect(udp, SIGNAL(haveDataFromPort(QByteArray)), ptty, SLOT(receiveDataFromRigToPtty(QByteArray)));
// Audio from UDP
connect(udp, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket)));
// data from the program to the comm port:
// data from the program to the rig:
connect(this, SIGNAL(dataForComm(QByteArray)), udp, SLOT(receiveDataFromUserToRig(QByteArray)));
// data from the ptty to the rig:
connect(ptty, SIGNAL(haveDataFromPort(QByteArray)), udp, SLOT(receiveDataFromUserToRig(QByteArray)));
@ -167,6 +164,7 @@ void rigCommander::closeComm()
if (ptty != Q_NULLPTR) {
delete ptty;
}
ptty = Q_NULLPTR;
}
void rigCommander::setup()