mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
fixes modulo in rx queue
This commit is contained in:
parent
e69f63611a
commit
84a0ce3c22
@ -1204,19 +1204,19 @@ void TpUartDataLinkLayer::processRxQueue()
|
|||||||
void TpUartDataLinkLayer::pushByteToRxQueue(uint8_t byte)
|
void TpUartDataLinkLayer::pushByteToRxQueue(uint8_t byte)
|
||||||
{
|
{
|
||||||
_rxBuffer[_rxBufferFront] = byte;
|
_rxBuffer[_rxBufferFront] = byte;
|
||||||
_rxBufferFront = (_rxBufferFront + 1) % MAX_RX_QUEUE_BYTES;
|
_rxBufferFront = (_rxBufferFront + 1) % (MAX_RX_QUEUE_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t TpUartDataLinkLayer::pullByteFromRxQueue()
|
uint8_t TpUartDataLinkLayer::pullByteFromRxQueue()
|
||||||
{
|
{
|
||||||
uint8_t byte = _rxBuffer[_rxBufferRear];
|
uint8_t byte = _rxBuffer[_rxBufferRear];
|
||||||
_rxBufferRear = (_rxBufferRear + 1) % MAX_RX_QUEUE_BYTES;
|
_rxBufferRear = (_rxBufferRear + 1) % (MAX_RX_QUEUE_BYTES);
|
||||||
return byte;
|
return byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t TpUartDataLinkLayer::availableInRxQueue()
|
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
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user