Updated directed frames to take advantage of the extra numerical bits so we don't have to delineate between positive and negative frame types
This commit is contained in:
parent
3318fa1005
commit
3e67f4ef1f
30
varicode.cpp
30
varicode.cpp
@ -1290,7 +1290,7 @@ QString Varicode::packCompoundFrame(const QString &baseCallsign, const QString &
|
|||||||
QString frame;
|
QString frame;
|
||||||
|
|
||||||
// needs to be a compound type...
|
// needs to be a compound type...
|
||||||
if(type == FrameDataPadded || type == FrameDataUnpadded || type == FrameDirectedPositive || type == FrameDirectedNegative){
|
if(type == FrameDataPadded || type == FrameDataUnpadded || type == FrameDirected){
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1333,7 +1333,7 @@ QStringList Varicode::unpackCompoundFrame(const QString &text, quint8 *pType, qu
|
|||||||
quint8 packed_flag = Varicode::bitsToInt(bits.mid(0, 3));
|
quint8 packed_flag = Varicode::bitsToInt(bits.mid(0, 3));
|
||||||
|
|
||||||
// needs to be a beacon type...
|
// needs to be a beacon type...
|
||||||
if(packed_flag == FrameDataPadded || packed_flag == FrameDataUnpadded || packed_flag == FrameDirectedPositive || packed_flag == FrameDirectedNegative){
|
if(packed_flag == FrameDataPadded || packed_flag == FrameDataUnpadded || packed_flag == FrameDirected){
|
||||||
return unpacked;
|
return unpacked;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1435,10 +1435,10 @@ QString Varicode::packDirectedMessage(const QString &text, const QString &callsi
|
|||||||
}
|
}
|
||||||
|
|
||||||
quint8 packed_cmd = directed_cmds[cmd];
|
quint8 packed_cmd = directed_cmds[cmd];
|
||||||
quint8 packed_flag = inum < 31 ? FrameDirectedNegative : FrameDirectedPositive;
|
quint8 packed_flag = FrameDirected;
|
||||||
quint8 packed_extra = inum < 31 ? inum : inum - 31;
|
quint8 packed_extra = inum;
|
||||||
|
|
||||||
// [3][28][28][5],[3][5] = 72
|
// [3][28][28][5],[2][6] = 72
|
||||||
auto bits = (
|
auto bits = (
|
||||||
Varicode::intToBits(packed_flag, 3) +
|
Varicode::intToBits(packed_flag, 3) +
|
||||||
Varicode::intToBits(packed_from, 28) +
|
Varicode::intToBits(packed_from, 28) +
|
||||||
@ -1448,7 +1448,7 @@ QString Varicode::packDirectedMessage(const QString &text, const QString &callsi
|
|||||||
|
|
||||||
if(pCmd) *pCmd = cmd;
|
if(pCmd) *pCmd = cmd;
|
||||||
if(n) *n = match.captured(0).length();
|
if(n) *n = match.captured(0).length();
|
||||||
return Varicode::pack72bits(Varicode::bitsToInt(bits), packed_extra % 32);
|
return Varicode::pack72bits(Varicode::bitsToInt(bits), packed_extra % 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Varicode::unpackDirectedMessage(const QString &text, quint8 *pType){
|
QStringList Varicode::unpackDirectedMessage(const QString &text, quint8 *pType){
|
||||||
@ -1458,17 +1458,12 @@ QStringList Varicode::unpackDirectedMessage(const QString &text, quint8 *pType){
|
|||||||
return unpacked;
|
return unpacked;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [3][28][22][11],[3][5] = 72
|
// [3][28][22][11],[2][6] = 72
|
||||||
quint8 extra = 0;
|
quint8 extra = 0;
|
||||||
auto bits = Varicode::intToBits(Varicode::unpack72bits(text, &extra), 64);
|
auto bits = Varicode::intToBits(Varicode::unpack72bits(text, &extra), 64);
|
||||||
|
|
||||||
int numSign = 0;
|
|
||||||
quint8 packed_flag = Varicode::bitsToInt(bits.mid(0, 3));
|
quint8 packed_flag = Varicode::bitsToInt(bits.mid(0, 3));
|
||||||
if(packed_flag == FrameDirectedPositive){
|
if(packed_flag != FrameDirected){
|
||||||
numSign = 31;
|
|
||||||
} else if(packed_flag == FrameDirectedNegative){
|
|
||||||
numSign = 0;
|
|
||||||
} else {
|
|
||||||
return unpacked;
|
return unpacked;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1484,15 +1479,14 @@ QStringList Varicode::unpackDirectedMessage(const QString &text, quint8 *pType){
|
|||||||
unpacked.append(to);
|
unpacked.append(to);
|
||||||
unpacked.append(cmd);
|
unpacked.append(cmd);
|
||||||
|
|
||||||
quint8 num = extra + numSign;
|
if(extra != 0){
|
||||||
if(num != 0){
|
|
||||||
// TODO: jsherer - should we decide which format to use on the command, or something else?
|
// TODO: jsherer - should we decide which format to use on the command, or something else?
|
||||||
if(packed_cmd == directed_cmds[" PWR"]){
|
if(packed_cmd == directed_cmds[" PWR"]){
|
||||||
unpacked.append(Varicode::formatPWR(num-1));
|
unpacked.append(Varicode::formatPWR(extra-1));
|
||||||
} else if(packed_cmd == directed_cmds[" SNR"]) {
|
} else if(packed_cmd == directed_cmds[" SNR"]) {
|
||||||
unpacked.append(Varicode::formatSNR((int)num-31));
|
unpacked.append(Varicode::formatSNR((int)extra-31));
|
||||||
} else {
|
} else {
|
||||||
unpacked.append(QString("%1").arg(num-31));
|
unpacked.append(QString("%1").arg(extra-31));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,11 +31,11 @@ public:
|
|||||||
FrameBeacon = 0, // [000]
|
FrameBeacon = 0, // [000]
|
||||||
FrameCompound = 1, // [001]
|
FrameCompound = 1, // [001]
|
||||||
FrameCompoundDirected = 2, // [010]
|
FrameCompoundDirected = 2, // [010]
|
||||||
FrameDirectedPositive = 3, // [011]
|
FrameDirected = 3, // [011]
|
||||||
FrameDirectedNegative = 4, // [100]
|
FrameReservedA = 4, // [100] <- Reserved for future use, likely an extension of one of these formats.
|
||||||
FrameDataUnpadded = 5, // [101]
|
FrameDataUnpadded = 5, // [101]
|
||||||
FrameDataPadded = 6, // [110]
|
FrameDataPadded = 6, // [110]
|
||||||
FrameReserved = 7, // [111] <- Reserved for future use, likely binary data / other formats.
|
FrameReservedB = 7, // [111] <- Reserved for future use, likely binary data / other formats.
|
||||||
};
|
};
|
||||||
|
|
||||||
static const quint8 FrameTypeMax = 7;
|
static const quint8 FrameTypeMax = 7;
|
||||||
|
Loading…
Reference in New Issue
Block a user