Skip to content

Commit

Permalink
Oops! Forgot the P25 NID changes for the TSDU datatype.
Browse files Browse the repository at this point in the history
  • Loading branch information
gatekeep committed May 14, 2018
1 parent 62dd3c4 commit 074919e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions P25NID.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2018 by Bryan Biedenkapp <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -72,6 +73,13 @@ m_pdu(NULL)
bch.encode(m_term);
m_term[7U] &= 0xFEU; // Clear the parity bit

m_tsdu = new unsigned char[P25_NID_LENGTH_BYTES];

This comment has been minimized.

Copy link
@shawnchain

shawnchain Jul 3, 2018

Contributor

Don't forget to release m_tsdu inside destructor.

This comment has been minimized.

Copy link
@g4klx

g4klx via email Jul 3, 2018

Owner
m_tsdu[0U] = (nac >> 4) & 0xFFU;
m_tsdu[1U] = (nac << 4) & 0xF0U;
m_tsdu[1U] |= P25_DUID_TSDU;
bch.encode(m_tsdu);
m_tsdu[7U] &= 0xFEU; // Clear the parity bit

m_pdu = new unsigned char[P25_NID_LENGTH_BYTES];
m_pdu[0U] = (nac >> 4) & 0xFFU;
m_pdu[1U] = (nac << 4) & 0xF0U;
Expand Down Expand Up @@ -127,6 +135,12 @@ bool CP25NID::decode(const unsigned char* data)
return true;
}

errs = CP25Utils::compare(nid, m_tsdu, P25_NID_LENGTH_BYTES);
if (errs < MAX_NID_ERRS) {
m_duid = P25_DUID_TSDU;
return true;
}

errs = CP25Utils::compare(nid, m_pdu, P25_NID_LENGTH_BYTES);
if (errs < MAX_NID_ERRS) {
m_duid = P25_DUID_PDU;
Expand Down Expand Up @@ -156,6 +170,9 @@ void CP25NID::encode(unsigned char* data, unsigned char duid) const
case P25_DUID_TERM_LC:
CP25Utils::encode(m_termlc, data, 48U, 114U);
break;
case P25_DUID_TSDU:
CP25Utils::encode(m_tsdu, data, 48U, 114U);
break;
case P25_DUID_PDU:
CP25Utils::encode(m_pdu, data, 48U, 114U);
break;
Expand Down
2 changes: 2 additions & 0 deletions P25NID.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2018 by Bryan Biedenkapp <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -37,6 +38,7 @@ class CP25NID {
unsigned char* m_ldu2;
unsigned char* m_termlc;
unsigned char* m_term;
unsigned char* m_tsdu;
unsigned char* m_pdu;
};

Expand Down

0 comments on commit 074919e

Please sign in to comment.