Bugfix of the DMRTA decoding for blocks comes in with random order

This commit is contained in:
Shawn Chain 2018-12-09 17:24:11 +08:00
parent afdb36f7b6
commit 334307cd4a
3 changed files with 33 additions and 17 deletions

View file

@ -630,7 +630,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
if (!(m_rfTalkerId & TALKER_ID_HEADER)) { if (!(m_rfTalkerId & TALKER_ID_HEADER)) {
if (m_rfTalkerId == TALKER_ID_NONE) if (m_rfTalkerId == TALKER_ID_NONE)
m_rfTalkerAlias.reset(); m_rfTalkerAlias.reset();
m_rfTalkerAlias.add(data, 6U); m_rfTalkerAlias.add(0, data, 6U);
m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "R"); m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "R");
if (m_dumpTAData) { if (m_dumpTAData) {
@ -649,7 +649,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
if (!(m_rfTalkerId & TALKER_ID_BLOCK1)) { if (!(m_rfTalkerId & TALKER_ID_BLOCK1)) {
if (m_rfTalkerId == TALKER_ID_NONE) if (m_rfTalkerId == TALKER_ID_NONE)
m_rfTalkerAlias.reset(); m_rfTalkerAlias.reset();
m_rfTalkerAlias.add(data, 7U); m_rfTalkerAlias.add(1, data, 7U);
m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "R"); m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "R");
if (m_dumpTAData) { if (m_dumpTAData) {
@ -668,7 +668,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
if (!(m_rfTalkerId & TALKER_ID_BLOCK2)) { if (!(m_rfTalkerId & TALKER_ID_BLOCK2)) {
if (m_rfTalkerId == TALKER_ID_NONE) if (m_rfTalkerId == TALKER_ID_NONE)
m_rfTalkerAlias.reset(); m_rfTalkerAlias.reset();
m_rfTalkerAlias.add(data, 7U); m_rfTalkerAlias.add(2, data, 7U);
m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "R"); m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "R");
if (m_dumpTAData) { if (m_dumpTAData) {
@ -687,7 +687,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
if (!(m_rfTalkerId & TALKER_ID_BLOCK3)) { if (!(m_rfTalkerId & TALKER_ID_BLOCK3)) {
if (m_rfTalkerId == TALKER_ID_NONE) if (m_rfTalkerId == TALKER_ID_NONE)
m_rfTalkerAlias.reset(); m_rfTalkerAlias.reset();
m_rfTalkerAlias.add(data, 7U); m_rfTalkerAlias.add(3, data, 7U);
m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "R"); m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "R");
if (m_dumpTAData) { if (m_dumpTAData) {
@ -1424,7 +1424,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
if (!(m_netTalkerId & TALKER_ID_HEADER)) { if (!(m_netTalkerId & TALKER_ID_HEADER)) {
if (!m_netTalkerId) if (!m_netTalkerId)
m_rfTalkerAlias.reset(); m_rfTalkerAlias.reset();
m_rfTalkerAlias.add(data + 2U, 7U); m_rfTalkerAlias.add(0, data + 2U, 7U);
m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "N"); m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "N");
if (m_dumpTAData) { if (m_dumpTAData) {
@ -1439,7 +1439,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
if (!(m_netTalkerId & TALKER_ID_BLOCK1)) { if (!(m_netTalkerId & TALKER_ID_BLOCK1)) {
if (!m_netTalkerId) if (!m_netTalkerId)
m_rfTalkerAlias.reset(); m_rfTalkerAlias.reset();
m_rfTalkerAlias.add(data + 2U, 7U); m_rfTalkerAlias.add(1, data + 2U, 7U);
m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "N"); m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "N");
if (m_dumpTAData) { if (m_dumpTAData) {
@ -1454,7 +1454,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
if (!(m_netTalkerId & TALKER_ID_BLOCK2)) { if (!(m_netTalkerId & TALKER_ID_BLOCK2)) {
if (!m_netTalkerId) if (!m_netTalkerId)
m_rfTalkerAlias.reset(); m_rfTalkerAlias.reset();
m_rfTalkerAlias.add(data + 2U, 7U); m_rfTalkerAlias.add(2, data + 2U, 7U);
m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "N"); m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "N");
if (m_dumpTAData) { if (m_dumpTAData) {
@ -1469,7 +1469,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
if (!(m_netTalkerId & TALKER_ID_BLOCK3)) { if (!(m_netTalkerId & TALKER_ID_BLOCK3)) {
if (!m_netTalkerId) if (!m_netTalkerId)
m_rfTalkerAlias.reset(); m_rfTalkerAlias.reset();
m_rfTalkerAlias.add(data+2U, 7U); m_rfTalkerAlias.add(3, data+2U, 7U);
m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "N"); m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "N");
if (m_dumpTAData) { if (m_dumpTAData) {

View file

@ -20,8 +20,7 @@
CDMRTA::CDMRTA() : CDMRTA::CDMRTA() :
m_TA(), m_TA(),
m_buf(), m_buf()
m_bufOffset(0)
{ {
} }
@ -29,18 +28,37 @@ CDMRTA::~CDMRTA()
{ {
} }
bool CDMRTA::add(const unsigned char* data, unsigned int len) bool CDMRTA::add(unsigned int blockId, const unsigned char* data, unsigned int len)
{ {
assert(data != NULL); assert(data != NULL);
if (m_bufOffset + len >= sizeof(m_buf)) { unsigned int offset;
switch(blockId) {
case 0:
offset = 0;
break;
case 1:
offset = 6;
break;
case 2:
offset = 13;
break;
case 3:
offset = 20;
break;
default:
// invalid block id
reset();
return false;
}
if (offset + len >= sizeof(m_buf)) {
// buffer overflow // buffer overflow
reset(); reset();
return false; return false;
} }
::memcpy(m_buf + m_bufOffset, data, len); ::memcpy(m_buf + offset, data, len);
m_bufOffset += len;
decodeTA(); decodeTA();
return true; return true;
@ -55,7 +73,6 @@ void CDMRTA::reset()
{ {
::memset(m_TA, 0, sizeof(m_TA)); ::memset(m_TA, 0, sizeof(m_TA));
::memset(m_buf, 0, sizeof(m_buf)); ::memset(m_buf, 0, sizeof(m_buf));
m_bufOffset = 0;
} }
void CDMRTA::decodeTA() void CDMRTA::decodeTA()

View file

@ -20,7 +20,7 @@ public:
CDMRTA(); CDMRTA();
~CDMRTA(); ~CDMRTA();
bool add(const unsigned char* data, unsigned int len); bool add(unsigned int blockId, const unsigned char* data, unsigned int len);
const unsigned char* get(); const unsigned char* get();
void reset(); void reset();
@ -30,7 +30,6 @@ protected:
private: private:
char m_TA[32]; char m_TA[32];
unsigned char m_buf[32]; unsigned char m_buf[32];
unsigned int m_bufOffset;
}; };
#endif #endif