tx throttle.

This commit is contained in:
Mike Pieper 2022-01-22 08:56:51 +01:00
parent 6720f86e5c
commit 1ee4377e61
2 changed files with 14 additions and 4 deletions

View File

@ -96,6 +96,7 @@ enum {
#define EOP_TIMEOUT 2 //milli seconds; end of layer-2 packet gap
#define CONFIRM_TIMEOUT 500 //milli seconds
#define RESET_TIMEOUT 100 //milli seconds
#define TX_THROTTLE_TIME 1 //milli seconds
void TpUartDataLinkLayer::loop()
{
@ -295,6 +296,7 @@ void TpUartDataLinkLayer::loop()
}
// Hint: We can send directly here, this doesn't disturb other transmissions
// We don't have to update _lastByteTxTime because after ACK the timing is not so tight
_platform.writeUart(c);
}
}
@ -377,13 +379,20 @@ void TpUartDataLinkLayer::loop()
}
break;
case TX_FRAME:
if (sendSingleFrameByte() == false)
if (millis() - _lastByteTxTime >= TX_THROTTLE_TIME)
{
_waitConfirmStartTime = millis();
_txState = TX_WAIT_ECHO;
if (sendSingleFrameByte() == false)
{
_waitConfirmStartTime = millis();
_txState = TX_WAIT_ECHO;
#ifdef DBG_TRACE
println("TX_WAIT_ECHO");
println("TX_WAIT_ECHO");
#endif
}
else
{
_lastByteTxTime = millis();
}
}
break;
case TX_WAIT_ECHO:

View File

@ -43,6 +43,7 @@ class TpUartDataLinkLayer : public DataLinkLayer
bool _convert = false;
uint8_t _xorSum = 0;
uint32_t _lastByteRxTime;
uint32_t _lastByteTxTime;
uint32_t _waitConfirmStartTime;
uint32_t _lastResetChipTime = 0;