AP_HAL: add discard_input method on UARTDriver

This commit is contained in:
Peter Barker 2020-05-23 10:21:38 +10:00 committed by Andrew Tridgell
parent f199ca54bd
commit a8d03990ec
2 changed files with 6 additions and 0 deletions

View File

@ -38,6 +38,7 @@ public:
uint32_t available() override { return 0; }
int16_t read() override { return -1; }
uint32_t txspace() override { return 0; }
bool discard_input() override { return false; }
};
int AP_HAL::Util::snprintf(char* str, size_t size, const char *format, ...)

View File

@ -43,6 +43,11 @@ public:
* -1 if nothing available, uint8_t value otherwise. */
virtual int16_t read() = 0;
// no base-class implementation to force descendants to
// do things efficiently. Looping over 2^32-1 bytes would be bad.
// returns false if discard failed (e.g. port locked)
virtual bool discard_input() = 0; // discard all bytes available for reading
/* NB txspace was traditionally a member of BetterStream in the
* FastSerial library. As far as concerns go, it belongs with available() */
virtual uint32_t txspace() = 0;