Skip to content

Commit

Permalink
fixes modulo in rx queue
Browse files Browse the repository at this point in the history
  • Loading branch information
traxanos committed Aug 3, 2024
1 parent e69f636 commit 84a0ce3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/knx/tpuart_data_link_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,19 +1204,19 @@ void TpUartDataLinkLayer::processRxQueue()
void TpUartDataLinkLayer::pushByteToRxQueue(uint8_t byte)
{
_rxBuffer[_rxBufferFront] = byte;
_rxBufferFront = (_rxBufferFront + 1) % MAX_RX_QUEUE_BYTES;
_rxBufferFront = (_rxBufferFront + 1) % (MAX_RX_QUEUE_BYTES);
}

uint8_t TpUartDataLinkLayer::pullByteFromRxQueue()
{
uint8_t byte = _rxBuffer[_rxBufferRear];
_rxBufferRear = (_rxBufferRear + 1) % MAX_RX_QUEUE_BYTES;
_rxBufferRear = (_rxBufferRear + 1) % (MAX_RX_QUEUE_BYTES);
return byte;
}

uint16_t TpUartDataLinkLayer::availableInRxQueue()
{
return ((_rxBufferFront == _rxBufferRear) ? MAX_RX_QUEUE_BYTES : (((MAX_RX_QUEUE_BYTES - _rxBufferFront) + _rxBufferRear) % MAX_RX_QUEUE_BYTES)) - 1;
return ((_rxBufferFront == _rxBufferRear) ? (MAX_RX_QUEUE_BYTES) : ((((MAX_RX_QUEUE_BYTES) - _rxBufferFront) + _rxBufferRear) % (MAX_RX_QUEUE_BYTES))) - 1;
}
#endif

Expand Down

0 comments on commit 84a0ce3

Please sign in to comment.