AP_HAL_SITL: add and use a "bool read(c)" method to AP_HAL

this is much less likely to not work vs the int16_t equivalent
This commit is contained in:
Peter Barker 2023-02-21 20:35:57 +11:00 committed by Peter Barker
parent a10f5dbd0a
commit d626197c0b
2 changed files with 4 additions and 5 deletions

View File

@ -219,13 +219,12 @@ uint32_t UARTDriver::txspace(void)
return _writebuffer.space();
}
int16_t UARTDriver::read(void)
bool UARTDriver::read(uint8_t &c)
{
uint8_t c;
if (read(&c, 1) == 0) {
return -1;
return false;
}
return c;
return true;
}
ssize_t UARTDriver::read(uint8_t *buffer, uint16_t count)

View File

@ -50,7 +50,7 @@ public:
/* Implementations of Stream virtual methods */
uint32_t available() override;
uint32_t txspace() override;
int16_t read() override;
bool read(uint8_t &b) override WARN_IF_UNUSED;
ssize_t read(uint8_t *buffer, uint16_t count) override;
bool discard_input() override;