mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-02 23:10:35 +08:00
serial: add txSpaceAvailable function (#26069)
* serial: add txSpaceAvailable function * serial: txSpaceAvailable and bytesAvailable fixups
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user