Experimental foundation of all or nothing checksummed messages

This commit is contained in:
Jordan Sherer 2018-07-25 09:06:47 -04:00
parent 115a9d65f7
commit 39a536bb91
2 changed files with 43 additions and 42 deletions

View File

@ -3238,24 +3238,36 @@ void MainWindow::readFromStdout() //readFromStdout
d.isFree = !decodedtext.isStandardMessage();
d.isCompound = decodedtext.isCompoundMessage();
d.bits = decodedtext.bits();
d.firstCall = decodedtext.CQersCall();
if(d.firstCall.isEmpty()){
auto words = decodedtext.messageWords();
if(words.length() == 2){
d.firstCall = words.at(0);
d.secondCall = words.at(1);
} else if(words.length() == 3){
d.firstCall = words.at(1);
d.secondCall = words.at(2);
}
}
d.freq = offset;
d.text = decodedtext.messageWords().isEmpty() ? "" : decodedtext.messageWords().first().trimmed();
d.utcTimestamp = QDateTime::currentDateTimeUtc();
d.snr = decodedtext.snr();
m_bandActivity[offset].append(d);
#if TEST_ALL_OR_NOTHING
if(m_messageCache.contains(d.freq/10*10)){
m_messageCache[d.freq/10*10].second.append(d);
if(d.bits == Varicode::FT8CallLast){
auto c = m_messageCache[d.freq/10*10].first;
auto fs = m_messageCache[d.freq/10*10].second;
if(!fs.isEmpty()){
qDebug() << "MESSAGE COMPLETE:" << c.from << c.to;
QString message;
foreach(auto f, fs){
message.append(f.text);
}
QString checksum = message.left(3);
message = message.mid(3);
qDebug() << "> CHECKSUM:" << checksum;
qDebug() << "> MESSAGE:" << message;
qDebug() << "> VALID:" << Varicode::checksum16Valid(checksum, message);
}
m_messageCache.remove(d.freq/10*10);
}
}
#endif
while(m_bandActivity[offset].count() > 10){
m_bandActivity[offset].removeFirst();
}
@ -3331,6 +3343,14 @@ void MainWindow::readFromStdout() //readFromStdout
d.utcTimestamp = QDateTime::currentDateTimeUtc();
m_rxCommandQueue.append(d);
// TODO: jsherer - process this elsewhere?
if(d.cmd == "|"){
// cache the message buffer commands
m_messageCache[d.freq/10*10].first = d;
m_messageCache[d.freq/10*10].second.clear();
}
CallDetail cd;
cd.call = d.from;
cd.grid = "";
@ -3434,7 +3454,7 @@ void MainWindow::readFromStdout() //readFromStdout
m_QSOText = decodedtext.string ().trimmed ();
// TODO: jsherer - parse decode...
RXDetail d;
ActivityDetail d;
d.isFree = !decodedtext.isStandardMessage();
d.isCompound = decodedtext.isCompoundMessage();
d.bits = decodedtext.bits();
@ -5619,18 +5639,6 @@ QPair<QStringList, QStringList> MainWindow::buildFT8MessageFrames(QString const&
foreach(QString line, text.split(QRegExp("[\\r\\n]"), QString::SkipEmptyParts)){
#if 0
// TODO: jsherer - maybe preprocess the line for validated messages in Varicode?
QRegularExpression r("^(?<cmd>[A-Z0-9/]+\\s?[|])(?<text>.+)");
auto match = r.match(line);
if(match.hasMatch()){
auto lineCmd = match.captured("cmd");
auto lineText = match.captured("text");
auto checksum = Varicode::checksum(lineText);
line = lineCmd + checksum + lineText;
}
#endif
// once we find a directed call, data encode the rest of the line.
bool hasDirected = false;
@ -5701,11 +5709,14 @@ QPair<QStringList, QStringList> MainWindow::buildFT8MessageFrames(QString const&
lines.append(line.left(n) + " ");
line = line.mid(n);
#if 0
// TODO: jsherer - this is how we'll prepend a 16-bit checksum to the message, just encode it in the data...
#if TEST_ALL_OR_NOTHING
// TODO: jsherer - don't do this... refactor pack to return the packed frame _and_ its components instead
if(Varicode::unpackDirectedMessage(dirFrame).at(2) == "|"){
// TODO: jsherer - this is how we can add 16-bit checksum to the message, just encode it in the data...
if(!line.isEmpty()){
line = Varicode::checksum16(line) + line;
}
}
#endif
}
@ -8544,7 +8555,7 @@ void MainWindow::displayActivity(bool force){
// Recently Directed Activity
while(!m_rxFrameQueue.isEmpty()){
RXDetail d = m_rxFrameQueue.dequeue();
ActivityDetail d = m_rxFrameQueue.dequeue();
// TODO: jsherer - is it safe to just ignore printing these?
if(d.isCompound){

View File

@ -664,31 +664,20 @@ private:
bool isLowConfidence;
bool isCompound;
int bits;
QString firstCall;
QString secondCall;
int freq;
QString text;
QDateTime utcTimestamp;
int snr;
};
struct RXDetail
{
bool isFree;
bool isLowConfidence;
bool isCompound;
int bits;
int freq;
QString text;
QDateTime utcTimestamp;
};
bool m_rxDirty;
int m_txFrameCount;
QString m_lastTxMessage;
QDateTime m_lastTxTime;
QQueue<QString> m_txFrameQueue;
QQueue<RXDetail> m_rxFrameQueue;
QQueue<ActivityDetail> m_rxFrameQueue;
QQueue<CommandDetail> m_rxCommandQueue;
QMap<QString, QString> m_compoundCallCache; // base callsign -> compound callsign
QCache<QString, QDateTime> m_txAllcallCommandCache; // callsign -> last tx
@ -697,6 +686,7 @@ private:
QCache<QString, int> m_rxCallCache; // call -> last freq seen
QMap<int, int> m_rxFrameBlockNumbers; // freq -> block
QMap<int, QList<ActivityDetail>> m_bandActivity; // freq -> [(text, last timestamp), ...]
QMap<int, QPair<CommandDetail, QList<ActivityDetail>>> m_messageCache; // freq -> (cmd, [frames, ...])
QMap<QString, CallDetail> m_callActivity; // call -> (last freq, last timestamp)
QSet<QString> m_callSeenBeacon; // call
int m_previousFreq;