Browse Source

HAL_SITL: take account of available bytes in receive_time_constraint_us

mission-4.1.18
Andrew Tridgell 7 years ago
parent
commit
049e3ae02d
  1. 4
      libraries/AP_HAL_SITL/UARTDriver.cpp
  2. 2
      libraries/AP_HAL_SITL/UARTDriver.h

4
libraries/AP_HAL_SITL/UARTDriver.cpp

@ -518,12 +518,12 @@ void UARTDriver::_timer_tick(void) @@ -518,12 +518,12 @@ void UARTDriver::_timer_tick(void)
A return value of zero means the HAL does not support this API
*/
uint64_t UARTDriver::receive_time_constraint_us(uint16_t nbytes) const
uint64_t UARTDriver::receive_time_constraint_us(uint16_t nbytes)
{
uint64_t last_receive_us = _receive_timestamp;
if (_uart_baudrate > 0) {
// assume 10 bits per byte.
uint32_t transport_time_us = (1000000UL * 10UL / _uart_baudrate) * nbytes;
uint32_t transport_time_us = (1000000UL * 10UL / _uart_baudrate) * (nbytes+available());
last_receive_us -= transport_time_us;
}
return last_receive_us;

2
libraries/AP_HAL_SITL/UARTDriver.h

@ -80,7 +80,7 @@ public: @@ -80,7 +80,7 @@ public:
A return value of zero means the HAL does not support this API
*/
uint64_t receive_time_constraint_us(uint16_t nbytes) const override;
uint64_t receive_time_constraint_us(uint16_t nbytes) override;
private:
uint8_t _portNumber;

Loading…
Cancel
Save