Added function to determine the checksum size needed for a buffered command
This commit is contained in:
parent
7868c3fe70
commit
565bdb5690
@ -3742,7 +3742,7 @@ void MainWindow::logCallActivity(CallDetail d, bool spot){
|
|||||||
if(m_callActivity.contains(d.call)){
|
if(m_callActivity.contains(d.call)){
|
||||||
// update (keep grid)
|
// update (keep grid)
|
||||||
CallDetail old = m_callActivity[d.call];
|
CallDetail old = m_callActivity[d.call];
|
||||||
if(!old.grid.isEmpty()){
|
if(d.grid.isEmpty() && !old.grid.isEmpty()){
|
||||||
d.grid = old.grid;
|
d.grid = old.grid;
|
||||||
}
|
}
|
||||||
m_callActivity[d.call] = d;
|
m_callActivity[d.call] = d;
|
||||||
@ -6190,10 +6190,14 @@ QStringList MainWindow::buildFT8MessageFrames(QString const& text){
|
|||||||
line = lstrip(line);
|
line = lstrip(line);
|
||||||
|
|
||||||
qDebug() << "before:" << line;
|
qDebug() << "before:" << line;
|
||||||
if(dirCmd == "#"){
|
int checksumSize = Varicode::isCommandChecksumed(dirCmd);
|
||||||
line = line + " " + Varicode::checksum32(line);
|
|
||||||
} else {
|
if(checksumSize == 32){
|
||||||
line = line + " " + Varicode::checksum16(line);
|
line = line + " " + Varicode::checksum32(line);
|
||||||
|
} else if (checksumSize == 16) {
|
||||||
|
line = line + " " + Varicode::checksum16(line);
|
||||||
|
} else if (checksumSize == 0) {
|
||||||
|
// pass
|
||||||
}
|
}
|
||||||
qDebug() << "after:" << line;
|
qDebug() << "after:" << line;
|
||||||
}
|
}
|
||||||
@ -8909,14 +8913,18 @@ void MainWindow::processBufferedActivity() {
|
|||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
|
||||||
if(Varicode::isCommandBuffered(buffer.cmd.cmd)){
|
if(Varicode::isCommandBuffered(buffer.cmd.cmd)){
|
||||||
if(buffer.cmd.cmd == "#"){
|
int checksumSize = Varicode::isCommandChecksumed(buffer.cmd.cmd);
|
||||||
|
|
||||||
|
if(checksumSize == 32) {
|
||||||
checksum = message.right(6);
|
checksum = message.right(6);
|
||||||
message = message.left(message.length() - 7);
|
message = message.left(message.length() - 7);
|
||||||
valid = Varicode::checksum32Valid(checksum, message);
|
valid = Varicode::checksum32Valid(checksum, message);
|
||||||
} else {
|
} else if(checksumSize == 16) {
|
||||||
checksum = message.right(3);
|
checksum = message.right(3);
|
||||||
message = message.left(message.length() - 4);
|
message = message.left(message.length() - 4);
|
||||||
valid = Varicode::checksum16Valid(checksum, message);
|
valid = Varicode::checksum16Valid(checksum, message);
|
||||||
|
} else if (checksumSize == 0) {
|
||||||
|
valid = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
valid = true;
|
valid = true;
|
||||||
|
15
varicode.cpp
15
varicode.cpp
@ -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};
|
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 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_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})?");
|
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]);
|
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
|
// CQCQCQ EM73
|
||||||
// BEACON EM73
|
// BEACON EM73
|
||||||
QString Varicode::packBeaconMessage(QString const &text, const QString &callsign, int *n){
|
QString Varicode::packBeaconMessage(QString const &text, const QString &callsign, int *n){
|
||||||
|
@ -121,6 +121,7 @@ public:
|
|||||||
|
|
||||||
static bool isCommandAllowed(const QString &cmd);
|
static bool isCommandAllowed(const QString &cmd);
|
||||||
static bool isCommandBuffered(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 QString packBeaconMessage(QString const &text, QString const&callsign, int *n);
|
||||||
static QStringList unpackBeaconMessage(const QString &text, quint8 *pType, bool *isAlt);
|
static QStringList unpackBeaconMessage(const QString &text, quint8 *pType, bool *isAlt);
|
||||||
|
Loading…
Reference in New Issue
Block a user