Added function to determine the checksum size needed for a buffered command

This commit is contained in:
Jordan Sherer 2018-08-27 22:04:17 -04:00
parent 7868c3fe70
commit 565bdb5690
3 changed files with 31 additions and 7 deletions

View File

@ -3742,7 +3742,7 @@ void MainWindow::logCallActivity(CallDetail d, bool spot){
if(m_callActivity.contains(d.call)){
// update (keep grid)
CallDetail old = m_callActivity[d.call];
if(!old.grid.isEmpty()){
if(d.grid.isEmpty() && !old.grid.isEmpty()){
d.grid = old.grid;
}
m_callActivity[d.call] = d;
@ -6190,10 +6190,14 @@ QStringList MainWindow::buildFT8MessageFrames(QString const& text){
line = lstrip(line);
qDebug() << "before:" << line;
if(dirCmd == "#"){
line = line + " " + Varicode::checksum32(line);
} else {
line = line + " " + Varicode::checksum16(line);
int checksumSize = Varicode::isCommandChecksumed(dirCmd);
if(checksumSize == 32){
line = line + " " + Varicode::checksum32(line);
} else if (checksumSize == 16) {
line = line + " " + Varicode::checksum16(line);
} else if (checksumSize == 0) {
// pass
}
qDebug() << "after:" << line;
}
@ -8909,14 +8913,18 @@ void MainWindow::processBufferedActivity() {
bool valid = false;
if(Varicode::isCommandBuffered(buffer.cmd.cmd)){
if(buffer.cmd.cmd == "#"){
int checksumSize = Varicode::isCommandChecksumed(buffer.cmd.cmd);
if(checksumSize == 32) {
checksum = message.right(6);
message = message.left(message.length() - 7);
valid = Varicode::checksum32Valid(checksum, message);
} else {
} else if(checksumSize == 16) {
checksum = message.right(3);
message = message.left(message.length() - 4);
valid = Varicode::checksum16Valid(checksum, message);
} else if (checksumSize == 0) {
valid = true;
}
} else {
valid = true;

View File

@ -78,6 +78,13 @@ QSet<int> allowed_cmds = {0, 1, 2, 3, 4, 5, 6, 7, 8, /*...*/ 15, 16, 17, 18, 19,
QSet<int> buffered_cmds = {6, 7, 8, 15};
QMap<int, int> checksum_cmds = {
{6, 16},
{7, 16},
{8, 32},
{15, 0}
};
QString callsign_pattern = QString("(?<callsign>[A-Z0-9/]+)");
QString optional_cmd_pattern = QString("(?<cmd>\\s?(?:AGN[?]|ACK|73|YES|NO|SNR|PWR|QSL[?]?|RR|HEARING|HW CPY[?]|FB|QTH|QTC|GRID|[?@&$%|!#^ ]))?");
QString optional_grid_pattern = QString("(?<grid>\\s?[A-R]{2}[0-9]{2})?");
@ -1121,6 +1128,14 @@ bool Varicode::isCommandBuffered(const QString &cmd){
return directed_cmds.contains(cmd) && buffered_cmds.contains(directed_cmds[cmd]);
}
int Varicode::isCommandChecksumed(const QString &cmd){
if(!directed_cmds.contains(cmd) || !checksum_cmds.contains(directed_cmds[cmd])){
return 0;
}
return checksum_cmds[directed_cmds[cmd]];
}
// CQCQCQ EM73
// BEACON EM73
QString Varicode::packBeaconMessage(QString const &text, const QString &callsign, int *n){

View File

@ -121,6 +121,7 @@ public:
static bool isCommandAllowed(const QString &cmd);
static bool isCommandBuffered(const QString &cmd);
static int isCommandChecksumed(const QString &cmd);
static QString packBeaconMessage(QString const &text, QString const&callsign, int *n);
static QStringList unpackBeaconMessage(const QString &text, quint8 *pType, bool *isAlt);