Merge pull request #481 from hamclub/dmr-ta-decode

Fixed incorrect DMRTA header packet length from RF side
This commit is contained in:
Jonathan Naylor 2018-12-09 17:54:59 +00:00 committed by GitHub
commit 2d0570f0f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 27 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_NONE)
m_rfTalkerAlias.reset();
m_rfTalkerAlias.add(0, data, 6U);
m_rfTalkerAlias.add(0, data, 7U);
m_display->writeDMRTA(m_slotNo, (unsigned char*)m_rfTalkerAlias.get(), "R");
if (m_dumpTAData) {

View file

@ -31,27 +31,14 @@ CDMRTA::~CDMRTA()
bool CDMRTA::add(unsigned int blockId, const unsigned char* data, unsigned int len)
{
assert(data != NULL);
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:
if (blockId > 3) {
// invalid block id
reset();
return false;
}
unsigned int offset = blockId * 7;
if (offset + len >= sizeof(m_buf)) {
// buffer overflow
reset();
@ -60,8 +47,7 @@ bool CDMRTA::add(unsigned int blockId, const unsigned char* data, unsigned int l
::memcpy(m_buf + offset, data, len);
decodeTA();
return true;
return decodeTA();
}
const unsigned char* CDMRTA::get()
@ -75,7 +61,7 @@ void CDMRTA::reset()
::memset(m_buf, 0, sizeof(m_buf));
}
void CDMRTA::decodeTA()
bool CDMRTA::decodeTA()
{
unsigned char *b;
unsigned char c;
@ -126,12 +112,15 @@ void CDMRTA::decodeTA()
break;
}
LogMessage("DMR Talker Alias (Data Format %u, Received %u/%u char): '%s'", TAformat, ::strlen(m_TA), TAsize, m_TA);
size_t TAlen = ::strlen(m_TA);
LogMessage("DMR Talker Alias (Data Format %u, Received %u/%u char): '%s'", TAformat, TAlen, TAsize, m_TA);
if (::strlen(m_TA) > TAsize) {
if (strlen(m_TA) < 29U)
if (TAlen > TAsize) {
if (TAlen < 29U)
strcat(m_TA," ?");
else
strcpy(m_TA + 28U," ?");
}
return TAlen >= TAsize;
}

View file

@ -25,7 +25,7 @@ public:
void reset();
protected:
void decodeTA();
bool decodeTA();
private:
char m_TA[32];