serial: add txSpaceAvailable function (#26069)

* serial: add txSpaceAvailable function

* serial: txSpaceAvailable and bytesAvailable fixups
This commit is contained in:
Jacob Dahl
2025-12-12 09:31:33 -09:00
committed by GitHub
parent 12745baf6c
commit b92d21bd31
8 changed files with 74 additions and 3 deletions
+20 -1
View File
@@ -156,14 +156,33 @@ ssize_t SerialImpl::bytesAvailable()
{
if (!_open) {
PX4_ERR("Device not open!");
errno = EBADF;
return -1;
}
uint32_t rx_bytes = 0;
(void) fc_uart_rx_available(_serial_fd, &rx_bytes);
int ret = fc_uart_rx_available(_serial_fd, &rx_bytes);
if (ret < 0) {
return -1;
}
return (ssize_t) rx_bytes;
}
ssize_t SerialImpl::txSpaceAvailable()
{
if (!_open) {
PX4_ERR("Device not open!");
errno = EBADF;
return -1;
}
// QURT doesn't have a direct equivalent to NuttX's FIONSPACE
errno = ENOSYS;
return -1;
}
ssize_t SerialImpl::read(uint8_t *buffer, size_t buffer_size)
{
if (!_open) {