AP_HAL_ChibiOS: add available method for locked state

This commit is contained in:
Siddharth Purohit 2020-05-31 17:48:59 +05:30 committed by Andrew Tridgell
parent cdf8e369f1
commit a7d641c705
2 changed files with 18 additions and 0 deletions

View File

@ -556,6 +556,22 @@ uint32_t UARTDriver::available() {
return _readbuf.available();
}
uint32_t UARTDriver::available_locked(uint32_t key)
{
if (lock_read_key != 0 && key != lock_read_key) {
return -1;
}
if (sdef.is_usb) {
#ifdef HAVE_USB_SERIAL
if (((SerialUSBDriver*)sdef.serial)->config->usbp->state != USB_ACTIVE) {
return 0;
}
#endif
}
return _readbuf.available();
}
uint32_t UARTDriver::txspace()
{
if (!_initialised) {

View File

@ -42,6 +42,8 @@ public:
uint32_t available() override;
uint32_t available_locked(uint32_t key) override;
uint32_t txspace() override;
int16_t read() override;
ssize_t read(uint8_t *buffer, uint16_t count) override;