Skip to content

Commit

Permalink
Add raw data accessors to the channel data classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Feb 21, 2018
1 parent 4b2df61 commit 7696add
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 34 deletions.
2 changes: 1 addition & 1 deletion NXDNControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ void CNXDNControl::writeNetwork()
CSync::addNXDNSync(data + 2U);

CNXDNLICH lich;
lich.setData(netData[0U]);
lich.setRaw(netData[0U]);
unsigned char usc = lich.getFCT();
unsigned char option = lich.getOption();
lich.setDirection(m_remoteGateway ? NXDN_LICH_DIRECTION_INBOUND : NXDN_LICH_DIRECTION_OUTBOUND);
Expand Down
27 changes: 19 additions & 8 deletions NXDNFACCH1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,21 @@ void CNXDNFACCH1::encode(unsigned char* data, unsigned int offset) const
}
}

void CNXDNFACCH1::getData(unsigned char* data, bool checksum) const
void CNXDNFACCH1::getData(unsigned char* data) const
{
assert(data != NULL);

if (checksum) {
::memset(data, 0x00U, 12U);
::memcpy(data, m_data, 10U);
CNXDNCRC::encodeCRC12(data, 80U);
} else {
::memcpy(data, m_data, 10U);
}
::memcpy(data, m_data, 10U);
}

void CNXDNFACCH1::getRaw(unsigned char* data) const
{
assert(data != NULL);

::memset(data, 0x00U, 12U);
::memcpy(data, m_data, 10U);

CNXDNCRC::encodeCRC12(data, 80U);
}

void CNXDNFACCH1::setData(const unsigned char* data)
Expand All @@ -168,6 +172,13 @@ void CNXDNFACCH1::setData(const unsigned char* data)
::memcpy(m_data, data, 10U);
}

void CNXDNFACCH1::setRaw(const unsigned char* data)
{
assert(data != NULL);

::memcpy(m_data, data, 12U);
}

CNXDNFACCH1& CNXDNFACCH1::operator=(const CNXDNFACCH1& facch1)
{
if (&facch1 != this)
Expand Down
4 changes: 3 additions & 1 deletion NXDNFACCH1.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ class CNXDNFACCH1 {

void encode(unsigned char* data, unsigned int offset) const;

void getData(unsigned char* data, bool checksum = false) const;
void getData(unsigned char* data) const;
void getRaw(unsigned char* data) const;

void setData(const unsigned char* data);
void setRaw(const unsigned char* data);

CNXDNFACCH1& operator=(const CNXDNFACCH1& facch);

Expand Down
4 changes: 2 additions & 2 deletions NXDNLICH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ unsigned char CNXDNLICH::getDirection() const
return (m_lich[0U] >> 1) & 0x01U;
}

unsigned char CNXDNLICH::getData() const
unsigned char CNXDNLICH::getRaw() const
{
return m_lich[0U];
}
Expand Down Expand Up @@ -136,7 +136,7 @@ void CNXDNLICH::setDirection(unsigned char direction)
m_lich[0U] |= (direction << 1) & 0x02U;
}

void CNXDNLICH::setData(unsigned char lich)
void CNXDNLICH::setRaw(unsigned char lich)
{
m_lich[0U] = lich;
}
Expand Down
4 changes: 2 additions & 2 deletions NXDNLICH.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class CNXDNLICH {
unsigned char getFCT() const;
unsigned char getOption() const;
unsigned char getDirection() const;
unsigned char getData() const;
unsigned char getRaw() const;

void setRFCT(unsigned char rfct);
void setFCT(unsigned char usc);
void setOption(unsigned char option);
void setDirection(unsigned char direction);
void setData(unsigned char lich);
void setRaw(unsigned char lich);

CNXDNLICH& operator=(const CNXDNLICH& lich);

Expand Down
31 changes: 21 additions & 10 deletions NXDNSACCH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,26 @@ unsigned char CNXDNSACCH::getStructure() const
return (m_data[0U] >> 6) & 0x03U;
}

void CNXDNSACCH::getData(unsigned char* data, bool checksum) const
void CNXDNSACCH::getData(unsigned char* data) const
{
assert(data != NULL);

if (checksum) {
::memcpy(data, m_data, 4U);
CNXDNCRC::encodeCRC6(data, 26U);
} else {
unsigned int offset = 8U;
for (unsigned int i = 0U; i < 18U; i++, offset++) {
bool b = READ_BIT1(m_data, offset);
WRITE_BIT1(data, i, b);
}
unsigned int offset = 8U;
for (unsigned int i = 0U; i < 18U; i++, offset++) {
bool b = READ_BIT1(m_data, offset);
WRITE_BIT1(data, i, b);
}
}

void CNXDNSACCH::getRaw(unsigned char* data) const
{
assert(data != NULL);

::memcpy(data, m_data, 4U);

CNXDNCRC::encodeCRC6(data, 26U);
}

void CNXDNSACCH::setRAN(unsigned char ran)
{
m_data[0U] &= 0xC0U;
Expand All @@ -194,6 +198,13 @@ void CNXDNSACCH::setData(const unsigned char* data)
}
}

void CNXDNSACCH::setRaw(const unsigned char* data)
{
assert(data != NULL);

::memcpy(m_data, data, 4U);
}

CNXDNSACCH& CNXDNSACCH::operator=(const CNXDNSACCH& sacch)
{
if (&sacch != this)
Expand Down
4 changes: 3 additions & 1 deletion NXDNSACCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ class CNXDNSACCH {
unsigned char getRAN() const;
unsigned char getStructure() const;

void getData(unsigned char* data, bool checksum = false) const;
void getData(unsigned char* data) const;
void getRaw(unsigned char* data) const;

void setRAN(unsigned char ran);
void setStructure(unsigned char structure);

void setData(const unsigned char* data);
void setRaw(const unsigned char* data);

CNXDNSACCH& operator=(const CNXDNSACCH& sacch);

Expand Down
27 changes: 19 additions & 8 deletions NXDNUDCH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,21 @@ unsigned char CNXDNUDCH::getRAN() const
return m_data[0U] & 0x3FU;
}

void CNXDNUDCH::getData(unsigned char* data, bool checksum) const
void CNXDNUDCH::getData(unsigned char* data) const
{
assert(data != NULL);

if (checksum) {
::memset(data, 0x00U, 25U);
::memcpy(data, m_data, 23U);
CNXDNCRC::encodeCRC15(data, 184U);
} else {
::memcpy(data, m_data + 1U, 22U);
}
::memcpy(data, m_data + 1U, 22U);
}

void CNXDNUDCH::getRaw(unsigned char* data) const
{
assert(data != NULL);

::memset(data, 0x00U, 25U);
::memcpy(data, m_data, 23U);

CNXDNCRC::encodeCRC15(data, 184U);
}

void CNXDNUDCH::setRAN(unsigned char ran)
Expand All @@ -199,6 +203,13 @@ void CNXDNUDCH::setData(const unsigned char* data)
::memcpy(m_data + 1U, data, 22U);
}

void CNXDNUDCH::setRaw(const unsigned char* data)
{
assert(data != NULL);

::memcpy(m_data, data, 25U);
}

CNXDNUDCH& CNXDNUDCH::operator=(const CNXDNUDCH& udch)
{
if (&udch != this)
Expand Down
4 changes: 3 additions & 1 deletion NXDNUDCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ class CNXDNUDCH {

unsigned char getRAN() const;

void getData(unsigned char* data, bool checksum = false) const;
void getData(unsigned char* data) const;
void getRaw(unsigned char* data) const;

void setRAN(unsigned char ran);

void setData(const unsigned char* data);
void setRaw(const unsigned char* data);

CNXDNUDCH& operator=(const CNXDNUDCH& udch);

Expand Down

0 comments on commit 7696add

Please sign in to comment.