Revert "First attempt at detecting D-Star data frames, Kenwood and Icom."
This reverts commit 3362e29b62
.
This commit is contained in:
parent
7aabb96351
commit
1fd1a4f6d1
171
DStarControl.cpp
171
DStarControl.cpp
|
@ -127,7 +127,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
|||
|
||||
unsigned char type = data[0U];
|
||||
|
||||
if (type == TAG_LOST && (m_rfState == RS_RF_AUDIO || m_rfState == RS_RF_DATA)) {
|
||||
if (type == TAG_LOST && m_rfState == RS_RF_AUDIO) {
|
||||
unsigned char my1[DSTAR_LONG_CALLSIGN_LENGTH];
|
||||
unsigned char my2[DSTAR_SHORT_CALLSIGN_LENGTH];
|
||||
unsigned char your[DSTAR_LONG_CALLSIGN_LENGTH];
|
||||
|
@ -316,7 +316,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
|||
}
|
||||
|
||||
return false;
|
||||
} else if (m_rfState == RS_RF_AUDIO || m_rfState == RS_RF_DATA) {
|
||||
} else if (m_rfState == RS_RF_AUDIO) {
|
||||
if (m_net)
|
||||
writeNetworkDataRF(DSTAR_END_PATTERN_BYTES, 0U, true);
|
||||
|
||||
|
@ -340,13 +340,11 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
|||
|
||||
return false;
|
||||
} else if (type == TAG_DATA) {
|
||||
if (m_rfState == RS_RF_REJECTED)
|
||||
if (m_rfState == RS_RF_REJECTED) {
|
||||
return false;
|
||||
|
||||
if (m_rfState == RS_RF_INVALID)
|
||||
} else if (m_rfState == RS_RF_INVALID) {
|
||||
return false;
|
||||
|
||||
if (m_rfState == RS_RF_LISTENING) {
|
||||
} else if (m_rfState == RS_RF_LISTENING) {
|
||||
// The sync is regenerated by the modem so can do exact match
|
||||
if (::memcmp(data + 1U + DSTAR_VOICE_FRAME_LENGTH_BYTES, DSTAR_SYNC_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES) == 0) {
|
||||
m_slowData.start();
|
||||
|
@ -354,41 +352,6 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
|||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Data signatures only appear at the beginning of the frame
|
||||
if (m_rfState == RS_RF_AUDIO && m_rfFrames < 21U) {
|
||||
if (CUtils::compare(data + 1U, DSTAR_KENWOOD_DATA_MODE_BYTES, DSTAR_VOICE_FRAME_LENGTH_BYTES) < 5U) {
|
||||
LogMessage("D-Star, switching to data mode (Kenwood)");
|
||||
m_rfState = RS_RF_DATA;
|
||||
} else if (CUtils::compare(data + 1U, DSTAR_ICOM_DATA_MODE_BYTES, DSTAR_VOICE_FRAME_LENGTH_BYTES) < 5U) {
|
||||
LogMessage("D-Star, switching to data mode (Icom)");
|
||||
m_rfState = RS_RF_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_rfState == RS_RF_DATA) {
|
||||
m_rfBits += 72U;
|
||||
m_rfErrs = 0U;
|
||||
m_rfFrames++;
|
||||
|
||||
// The sync is regenerated by the modem so can do exact match
|
||||
if (::memcmp(data + 1U + DSTAR_VOICE_FRAME_LENGTH_BYTES, DSTAR_SYNC_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES) == 0)
|
||||
m_rfN = 0U;
|
||||
|
||||
// Regenerate the sync and send the RSSI data to the display
|
||||
if (m_rfN == 0U) {
|
||||
CSync::addDStarSync(data + 1U);
|
||||
m_display->writeDStarRSSI(m_rssi);
|
||||
}
|
||||
|
||||
if (m_net)
|
||||
writeNetworkDataRF(data, 0U, false);
|
||||
|
||||
if (m_duplex)
|
||||
writeQueueDataRF(data);
|
||||
|
||||
m_rfN = (m_rfN + 1U) % 21U;
|
||||
} else if (m_rfState == RS_RF_AUDIO) {
|
||||
unsigned int errors = 0U;
|
||||
if (!m_rfHeader.isDataPacket()) {
|
||||
|
@ -396,10 +359,6 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
|||
m_display->writeDStarBER(float(errors) / 0.48F);
|
||||
LogDebug("D-Star, audio sequence no. %u, errs: %u/48 (%.1f%%)", m_rfN, errors, float(errors) / 0.48F);
|
||||
m_rfErrs += errors;
|
||||
|
||||
// The sync is regenerated by the modem so can do exact match
|
||||
if (::memcmp(data + 1U + DSTAR_VOICE_FRAME_LENGTH_BYTES, DSTAR_SYNC_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES) == 0)
|
||||
m_rfN = 0U;
|
||||
}
|
||||
|
||||
m_rfBits += 48U;
|
||||
|
@ -630,7 +589,7 @@ void CDStarControl::writeNetwork()
|
|||
if (!m_enabled)
|
||||
return;
|
||||
|
||||
if ((m_rfState == RS_RF_AUDIO || m_rfState == RS_RF_DATA) && m_netState == RS_NET_IDLE)
|
||||
if (m_rfState == RS_RF_AUDIO && m_netState == RS_NET_IDLE)
|
||||
return;
|
||||
|
||||
m_networkWatchdog.start();
|
||||
|
@ -700,94 +659,64 @@ void CDStarControl::writeNetwork()
|
|||
m_elapsed.start();
|
||||
|
||||
} else if (type == TAG_EOT) {
|
||||
if (m_netState == RS_NET_AUDIO || m_netState == RS_NET_DATA) {
|
||||
writeQueueEOTNet();
|
||||
if (m_netState != RS_NET_AUDIO)
|
||||
return;
|
||||
|
||||
data[1U] = TAG_EOT;
|
||||
writeQueueEOTNet();
|
||||
|
||||
data[1U] = TAG_EOT;
|
||||
|
||||
#if defined(DUMP_DSTAR)
|
||||
writeFile(data + 1U, length - 1U);
|
||||
closeFile();
|
||||
writeFile(data + 1U, length - 1U);
|
||||
closeFile();
|
||||
#endif
|
||||
unsigned char my1[DSTAR_LONG_CALLSIGN_LENGTH];
|
||||
unsigned char my2[DSTAR_SHORT_CALLSIGN_LENGTH];
|
||||
unsigned char your[DSTAR_LONG_CALLSIGN_LENGTH];
|
||||
m_netHeader.getMyCall1(my1);
|
||||
m_netHeader.getMyCall2(my2);
|
||||
m_netHeader.getYourCall(your);
|
||||
unsigned char my1[DSTAR_LONG_CALLSIGN_LENGTH];
|
||||
unsigned char my2[DSTAR_SHORT_CALLSIGN_LENGTH];
|
||||
unsigned char your[DSTAR_LONG_CALLSIGN_LENGTH];
|
||||
m_netHeader.getMyCall1(my1);
|
||||
m_netHeader.getMyCall2(my2);
|
||||
m_netHeader.getYourCall(your);
|
||||
|
||||
// We've received the header and EOT haven't we?
|
||||
m_netFrames += 2U;
|
||||
LogMessage("D-Star, received network end of transmission from %8.8s/%4.4s to %8.8s, %.1f seconds, %u%% packet loss, BER: %.1f%%", my1, my2, your, float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits));
|
||||
// We've received the header and EOT haven't we?
|
||||
m_netFrames += 2U;
|
||||
LogMessage("D-Star, received network end of transmission from %8.8s/%4.4s to %8.8s, %.1f seconds, %u%% packet loss, BER: %.1f%%", my1, my2, your, float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits));
|
||||
|
||||
writeEndNet();
|
||||
}
|
||||
writeEndNet();
|
||||
} else if (type == TAG_DATA) {
|
||||
// Data signatures only appear at the beginning of the frame
|
||||
if (m_netState == RS_NET_AUDIO && m_netFrames < 21U) {
|
||||
if (CUtils::compare(data + 2U, DSTAR_KENWOOD_DATA_MODE_BYTES, DSTAR_VOICE_FRAME_LENGTH_BYTES) < 5U) {
|
||||
LogMessage("D-Star, switching to data mode (Kenwood)");
|
||||
m_rfState = RS_RF_DATA;
|
||||
} else if (CUtils::compare(data + 2U, DSTAR_ICOM_DATA_MODE_BYTES, DSTAR_VOICE_FRAME_LENGTH_BYTES) < 5U) {
|
||||
LogMessage("D-Star, switching to data mode (Icom)");
|
||||
m_rfState = RS_RF_DATA;
|
||||
}
|
||||
}
|
||||
if (m_netState != RS_NET_AUDIO)
|
||||
return;
|
||||
|
||||
if (m_netState == RS_NET_DATA) {
|
||||
unsigned char n = data[1U];
|
||||
unsigned char n = data[1U];
|
||||
|
||||
data[1U] = TAG_DATA;
|
||||
unsigned int errors = 0U;
|
||||
if (!m_netHeader.isDataPacket())
|
||||
errors = m_fec.regenerateDStar(data + 2U);
|
||||
|
||||
m_netBits += 72U;
|
||||
m_netErrs = 0U;
|
||||
blankDTMF(data + 2U);
|
||||
|
||||
m_netN = n;
|
||||
data[1U] = TAG_DATA;
|
||||
|
||||
// Regenerate the sync
|
||||
if (n == 0U)
|
||||
CSync::addDStarSync(data + 2U);
|
||||
// Insert silence and reject if in the past
|
||||
bool ret = insertSilence(data + 1U, n);
|
||||
if (!ret)
|
||||
return;
|
||||
|
||||
m_packetTimer.start();
|
||||
m_netFrames++;
|
||||
m_netErrs += errors;
|
||||
m_netBits += 48U;
|
||||
|
||||
m_netN = n;
|
||||
|
||||
// Regenerate the sync
|
||||
if (n == 0U)
|
||||
CSync::addDStarSync(data + 2U);
|
||||
|
||||
m_packetTimer.start();
|
||||
m_netFrames++;
|
||||
|
||||
#if defined(DUMP_DSTAR)
|
||||
writeFile(data + 1U, length - 1U);
|
||||
writeFile(data + 1U, length - 1U);
|
||||
#endif
|
||||
writeQueueDataNet(data + 1U);
|
||||
} else if (m_netState == RS_NET_AUDIO) {
|
||||
unsigned char n = data[1U];
|
||||
|
||||
unsigned int errors = 0U;
|
||||
if (!m_netHeader.isDataPacket())
|
||||
errors = m_fec.regenerateDStar(data + 2U);
|
||||
|
||||
blankDTMF(data + 2U);
|
||||
|
||||
data[1U] = TAG_DATA;
|
||||
|
||||
// Insert silence and reject if in the past
|
||||
bool ret = insertSilence(data + 1U, n);
|
||||
if (!ret)
|
||||
return;
|
||||
|
||||
m_netErrs += errors;
|
||||
m_netBits += 48U;
|
||||
|
||||
m_netN = n;
|
||||
|
||||
// Regenerate the sync
|
||||
if (n == 0U)
|
||||
CSync::addDStarSync(data + 2U);
|
||||
|
||||
m_packetTimer.start();
|
||||
m_netFrames++;
|
||||
|
||||
#if defined(DUMP_DSTAR)
|
||||
writeFile(data + 1U, length - 1U);
|
||||
#endif
|
||||
writeQueueDataNet(data + 1U);
|
||||
}
|
||||
writeQueueDataNet(data + 1U);
|
||||
} else {
|
||||
CUtils::dump("D-Star, unknown data from network", data, DSTAR_FRAME_LENGTH_BYTES + 1U);
|
||||
}
|
||||
|
@ -816,7 +745,7 @@ void CDStarControl::clock()
|
|||
m_rfTimeoutTimer.clock(ms);
|
||||
m_netTimeoutTimer.clock(ms);
|
||||
|
||||
if (m_netState == RS_NET_AUDIO || m_netState == RS_NET_DATA) {
|
||||
if (m_netState == RS_NET_AUDIO) {
|
||||
m_networkWatchdog.clock(ms);
|
||||
|
||||
if (m_networkWatchdog.hasExpired()) {
|
||||
|
@ -830,7 +759,7 @@ void CDStarControl::clock()
|
|||
}
|
||||
}
|
||||
|
||||
if (m_netState == RS_NET_AUDIO || m_netState == RS_NET_DATA) {
|
||||
if (m_netState == RS_NET_AUDIO) {
|
||||
m_packetTimer.clock(ms);
|
||||
|
||||
if (m_packetTimer.isRunning() && m_packetTimer.hasExpired()) {
|
||||
|
|
|
@ -36,9 +36,6 @@ const unsigned char DSTAR_NULL_SLOW_DATA_BYTES[] = { 0x16, 0x29, 0xF5 };
|
|||
const unsigned char DSTAR_NULL_FRAME_SYNC_BYTES[] = { TAG_DATA, 0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8, 0x55, 0x2D, 0x16 };
|
||||
const unsigned char DSTAR_NULL_FRAME_DATA_BYTES[] = { TAG_DATA, 0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8, 0x16, 0x29, 0xF5 };
|
||||
|
||||
const unsigned char DSTAR_KENWOOD_DATA_MODE_BYTES[] = { 0xEEU, 0xC2U, 0xA1U, 0xC8U, 0x42U, 0x6EU, 0x52U, 0x51U, 0xC3U };
|
||||
const unsigned char DSTAR_ICOM_DATA_MODE_BYTES[] = { 0xB2U, 0x4DU, 0x22U, 0x48U, 0xC0U, 0x16U, 0x28U, 0x26U, 0xC8U };
|
||||
|
||||
const unsigned int DSTAR_VOICE_FRAME_LENGTH_BYTES = 9U;
|
||||
const unsigned int DSTAR_DATA_FRAME_LENGTH_BYTES = 3U;
|
||||
|
||||
|
|
19
Utils.cpp
19
Utils.cpp
|
@ -144,22 +144,3 @@ void CUtils::bitsToByteLE(const bool* bits, unsigned char& byte)
|
|||
byte |= bits[6U] ? 0x40U : 0x00U;
|
||||
byte |= bits[7U] ? 0x80U : 0x00U;
|
||||
}
|
||||
|
||||
unsigned int CUtils::compare(const unsigned char* bytes1, const unsigned char* bytes2, unsigned int length)
|
||||
{
|
||||
assert(bytes1 != NULL);
|
||||
assert(bytes2 != NULL);
|
||||
|
||||
unsigned int diffs = 0U;
|
||||
|
||||
for (unsigned int i = 0U; i < length; i++) {
|
||||
unsigned char v = bytes1[i] ^ bytes2[i];
|
||||
while (v != 0U) {
|
||||
v &= v - 1U;
|
||||
diffs++;
|
||||
}
|
||||
}
|
||||
|
||||
return diffs;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue