Skip to content

Commit

Permalink
M17 bug fixing.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Oct 20, 2020
1 parent d58a0c5 commit 1bb1e9d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
16 changes: 9 additions & 7 deletions M17Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)

writeQueueRF(data);
}

return true;
} else {
m_rfState = RS_RF_LATE_ENTRY;
}
Expand Down Expand Up @@ -396,10 +398,6 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
// Add the Convolution FEC
conv.encodeData(frame, rfData + 2U + M17_SYNC_LENGTH_BYTES + M17_LICH_FRAGMENT_FEC_LENGTH_BYTES);

unsigned char temp[M17_FRAME_LENGTH_BYTES];
interleaver(rfData + 2U, temp);
decorrelator(rfData, data + 2U);

// Calculate the BER
if (valid) {
for (unsigned int i = 2U; i < (M17_FRAME_LENGTH_BYTES + 2U); i++)
Expand All @@ -411,6 +409,10 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
m_display->writeM17BER(ber);
}

unsigned char temp[M17_FRAME_LENGTH_BYTES];
interleaver(rfData + 2U, temp);
decorrelator(rfData, data + 2U);

if (m_duplex)
writeQueueRF(rfData);

Expand All @@ -419,7 +421,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
m_rfLICH.getNetwork(netData + 0U);

// Copy the FN and payload from the frame
::memcpy(netData + M17_LICH_LENGTH_BYTES, frame, M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES);
::memcpy(netData + M17_LICH_LENGTH_BYTES - M17_CRC_LENGTH_BYTES, frame, M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES);

// The CRC is added in the networking code

Expand Down Expand Up @@ -572,7 +574,7 @@ void CM17Control::writeNetwork()
m_netFrames++;

// Add the fragment LICH
uint16_t fn = (netData[38U] << 8) + (netData[39U] << 0);
uint16_t fn = (netData[28U] << 8) + (netData[29U] << 0);

unsigned char lich[M17_LICH_FRAGMENT_LENGTH_BYTES];
m_netLICH.getFragment(lich, fn);
Expand All @@ -590,7 +592,7 @@ void CM17Control::writeNetwork()

// Add the FN and the data/audio
unsigned char payload[M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES + M17_CRC_LENGTH_BYTES];
::memcpy(payload, netData + 38U, M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES);
::memcpy(payload, netData + 28U, M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES);

// Add the CRC
CM17CRC::encodeCRC(payload, M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES + M17_CRC_LENGTH_BYTES);
Expand Down
8 changes: 4 additions & 4 deletions M17Convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void CM17Convolution::decodeLinkSetup(const unsigned char* in, unsigned char* ou
assert(in != NULL);
assert(out != NULL);

uint8_t temp[488U];
uint8_t temp[500U];

unsigned int n = 0U;
unsigned int index = 0U;
Expand All @@ -151,15 +151,15 @@ void CM17Convolution::decodeLinkSetup(const unsigned char* in, unsigned char* ou
decode(s0, s1);
}

chainback(out, 244U);
chainback(out, 240U);
}

void CM17Convolution::decodeData(const unsigned char* in, unsigned char* out)
{
assert(in != NULL);
assert(out != NULL);

uint8_t temp[328U];
uint8_t temp[350U];

unsigned int n = 0U;
unsigned int index = 0U;
Expand All @@ -186,7 +186,7 @@ void CM17Convolution::decodeData(const unsigned char* in, unsigned char* out)
decode(s0, s1);
}

chainback(out, 164U);
chainback(out, 160U);
}

void CM17Convolution::start()
Expand Down
6 changes: 3 additions & 3 deletions M17LICH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ void CM17LICH::setDest(const std::string& callsign)

unsigned char CM17LICH::getDataType() const
{
return (m_lich[12U] >> 1) & 0x03U;
return (m_lich[13U] >> 1) & 0x03U;
}

void CM17LICH::setDataType(unsigned char type)
{
m_lich[12U] &= 0xF9U;
m_lich[12U] |= (type << 1) & 0x06U;
m_lich[13U] &= 0xF9U;
m_lich[13U] |= (type << 1) & 0x06U;
}

void CM17LICH::reset()
Expand Down
2 changes: 1 addition & 1 deletion M17Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void CM17Network::clock(unsigned int ms)
unsigned char c = length - 6U;
m_buffer.addData(&c, 1U);

m_buffer.addData(buffer + 6U, length - 6U);
m_buffer.addData(buffer + 6U, length - 8U);
}

bool CM17Network::read(unsigned char* data)
Expand Down

0 comments on commit 1bb1e9d

Please sign in to comment.