Skip to content

Commit 0a4c784

Browse files
committed
fix incorrect handling of writeData and createData for long frames;
1 parent f8358ed commit 0a4c784

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

p25/P25TX.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,15 @@ uint8_t P25TX::writeData(const uint8_t* data, uint16_t length)
163163
return RSN_RINGBUFF_FULL;
164164
}
165165

166-
m_fifo.put(length - 1U);
166+
if (length <= 255U) {
167+
m_fifo.put(DVM_SHORT_FRAME_START);
168+
m_fifo.put(length - 1U);
169+
} else {
170+
m_fifo.put(DVM_LONG_FRAME_START);
171+
m_fifo.put(((length - 1U) >> 8U) & 0xFFU);
172+
m_fifo.put((length - 1U) & 0xFFU);
173+
}
174+
167175
for (uint16_t i = 0U; i < (length - 1U); i++)
168176
m_fifo.put(data[i + 1U]);
169177

@@ -257,7 +265,17 @@ void P25TX::createData()
257265
m_poBuffer[m_poLen++] = P25_START_SYNC;
258266
}
259267
else {
260-
uint16_t length = m_fifo.get();
268+
uint8_t frameType = m_fifo.get();
269+
uint16_t length = 0U;
270+
switch (frameType) {
271+
case DVM_SHORT_FRAME_START:
272+
length = m_fifo.get();
273+
break;
274+
case DVM_LONG_FRAME_START:
275+
length = ((m_fifo.get() & 0xFFU) << 8) + (m_fifo.get());
276+
break;
277+
}
278+
261279
DEBUG3("P25TX::createData() dataLength/fifoSpace", length, m_fifo.getSpace());
262280
for (uint16_t i = 0U; i < length; i++) {
263281
m_poBuffer[m_poLen++] = m_fifo.get();

0 commit comments

Comments
 (0)