Added large checksum message processing
This commit is contained in:
parent
e649a375cf
commit
5f3ca913b7
@ -254,19 +254,21 @@ namespace
|
||||
QString rstrip(const QString& str) {
|
||||
int n = str.size() - 1;
|
||||
for (; n >= 0; --n) {
|
||||
if (!str.at(n).isSpace()) {
|
||||
return str.left(n + 1);
|
||||
if (str.at(n).isSpace()) {
|
||||
continue;
|
||||
}
|
||||
return str.left(n + 1);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
QString lstrip(const QString& str) {
|
||||
int len = str.size() - 1;
|
||||
int len = str.size();
|
||||
for (int n = 0; n < len; n++) {
|
||||
if (!str.at(n).isSpace()) {
|
||||
if(str.at(n).isSpace()){
|
||||
continue;
|
||||
}
|
||||
return str.mid(n);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@ -6009,12 +6011,18 @@ QStringList MainWindow::buildFT8MessageFrames(QString const& text){
|
||||
|
||||
// generate a checksum for buffered commands with line data
|
||||
if(Varicode::isCommandBuffered(dirCmd) && !line.isEmpty()){
|
||||
qDebug() << "generating checksum for line" << line << line.mid(1);
|
||||
|
||||
// strip leading whitespace after a buffered directed command
|
||||
line = lstrip(line);
|
||||
// TODO: jsherer - this is how we can add 16-bit checksum to the message, just encode it in the data...
|
||||
qDebug() << "generating checksum for line" << line;
|
||||
line = line + " " + Varicode::checksum16(line);
|
||||
qDebug() << line;
|
||||
|
||||
qDebug() << "before:" << line;
|
||||
if(dirCmd == "#"){
|
||||
line = line + " " + Varicode::checksum32(line);
|
||||
} else {
|
||||
line = line + " " + Varicode::checksum16(line);
|
||||
}
|
||||
qDebug() << "after:" << line;
|
||||
}
|
||||
}
|
||||
|
||||
@ -8889,10 +8897,21 @@ void MainWindow::processBufferedActivity() {
|
||||
}
|
||||
message = rstrip(message);
|
||||
|
||||
QString checksum = message.right(3);
|
||||
message = message.left(message.length() - 4);
|
||||
QString checksum;
|
||||
|
||||
if (Varicode::checksum16Valid(checksum, message)) {
|
||||
bool valid = false;
|
||||
|
||||
if(buffer.cmd.cmd == "#"){
|
||||
checksum = message.right(6);
|
||||
message = message.left(message.length() - 7);
|
||||
valid = Varicode::checksum32Valid(checksum, message);
|
||||
} else {
|
||||
checksum = message.right(3);
|
||||
message = message.left(message.length() - 4);
|
||||
valid = Varicode::checksum16Valid(checksum, message);
|
||||
}
|
||||
|
||||
if (valid) {
|
||||
buffer.cmd.text = message;
|
||||
buffer.cmd.isBuffered = true;
|
||||
m_rxCommandQueue.append(buffer.cmd);
|
||||
|
11
varicode.cpp
11
varicode.cpp
@ -47,9 +47,10 @@ QMap<QString, int> directed_cmds = {
|
||||
{"%", 5 }, // query pwr
|
||||
{"|", 6 }, // relay message?
|
||||
{"!", 7 }, // alert message?
|
||||
{"#", 8 }, // all or nothing message
|
||||
|
||||
// {"=", 8 }, // unused? (can we even use equals?)
|
||||
// {"/", 9 }, // unused? (can we even use stroke?)
|
||||
// {"=", 9 }, // unused? (can we even use equals?)
|
||||
// {"/", 10 }, // unused? (can we even use stroke?)
|
||||
|
||||
// directed responses
|
||||
{" ACK", 23 }, // acknowledged
|
||||
@ -63,13 +64,13 @@ QMap<QString, int> directed_cmds = {
|
||||
{" ", 31 }, // send freetext
|
||||
};
|
||||
|
||||
QSet<int> allowed_cmds = {0, 1, 2, 3, 4, 5, 6, 7, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
||||
QSet<int> allowed_cmds = {0, 1, 2, 3, 4, 5, 6, 7, 8, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
||||
|
||||
QSet<int> buffered_cmds = {6, 7};
|
||||
QSet<int> buffered_cmds = {6, 7, 8};
|
||||
|
||||
QRegularExpression directed_re("^"
|
||||
"(?<to>[A-Z0-9/]+)"
|
||||
"(?<cmd>\\s?(?:AGN[?]|RR|73|YES|NO|SNR|PWR|ACK|[?@&$^%|! ]))"
|
||||
"(?<cmd>\\s?(?:AGN[?]|RR|73|YES|NO|SNR|PWR|ACK|[?@&$^%|!# ]))"
|
||||
"(?<pwr>\\s?\\d+\\s?[KM]?W)?"
|
||||
"(?<num>\\s?[-+]?(?:3[01]|[0-2]?[0-9]))?"
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user