Fixed issue with APRS packet queue processing
This commit is contained in:
parent
f979e3c4a7
commit
ffbfb3b133
@ -255,17 +255,13 @@ void APRSISClient::processQueue(bool disconnect){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QQueue<QPair<QString, QDateTime>> delayed;
|
||||||
|
|
||||||
while(!m_frameQueue.isEmpty()){
|
while(!m_frameQueue.isEmpty()){
|
||||||
auto pair = m_frameQueue.head();
|
auto pair = m_frameQueue.head();
|
||||||
auto frame = pair.first;
|
auto frame = pair.first;
|
||||||
auto timestamp = pair.second;
|
auto timestamp = pair.second;
|
||||||
|
|
||||||
// random delay 50% of the time for throttling (a skip will add 60 seconds to the processing time)
|
|
||||||
if(qrand() % 100 <= 50){
|
|
||||||
qDebug() << "APRSISClient Throttle: Skipping Frame";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the packet is older than the timeout, drop it.
|
// if the packet is older than the timeout, drop it.
|
||||||
if(timestamp.secsTo(QDateTime::currentDateTimeUtc()) > PACKET_TIMEOUT_SECONDS){
|
if(timestamp.secsTo(QDateTime::currentDateTimeUtc()) > PACKET_TIMEOUT_SECONDS){
|
||||||
qDebug() << "APRSISClient Packet Timeout:" << frame;
|
qDebug() << "APRSISClient Packet Timeout:" << frame;
|
||||||
@ -273,19 +269,20 @@ void APRSISClient::processQueue(bool disconnect){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// random delay 25% of the time for throttling (a skip will add 60 seconds to the processing time)
|
||||||
|
if(qrand() % 100 <= 25){
|
||||||
|
qDebug() << "APRSISClient Throttle: Skipping Frame";
|
||||||
|
delayed.enqueue(m_frameQueue.dequeue());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray data = frame.toLocal8Bit();
|
QByteArray data = frame.toLocal8Bit();
|
||||||
if(write(data) == -1){
|
if(write(data) == -1){
|
||||||
qDebug() << "APRSISClient Write Error:" << errorString();
|
qDebug() << "APRSISClient Write Error:" << errorString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!waitForBytesWritten(5000)){
|
|
||||||
qDebug() << "APRSISClient Cannot Write Error: Write Timeout";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "APRSISClient Write:" << data;
|
qDebug() << "APRSISClient Write:" << data;
|
||||||
|
|
||||||
if(waitForReadyRead(5000)){
|
if(waitForReadyRead(5000)){
|
||||||
line = QString(readLine());
|
line = QString(readLine());
|
||||||
|
|
||||||
@ -300,6 +297,11 @@ void APRSISClient::processQueue(bool disconnect){
|
|||||||
m_frameQueue.dequeue();
|
m_frameQueue.dequeue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// enqueue the delayed frames for later processing
|
||||||
|
while(!delayed.isEmpty()){
|
||||||
|
m_frameQueue.enqueue(delayed.dequeue());
|
||||||
|
}
|
||||||
|
|
||||||
if(disconnect){
|
if(disconnect){
|
||||||
disconnectFromHost();
|
disconnectFromHost();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user