[SerialImpl]: add function to return pollfd

This commit is contained in:
Alexander Lerach
2025-12-09 18:42:46 +01:00
parent 73a8fc8fb0
commit f0d40d7a43
6 changed files with 29 additions and 0 deletions
@@ -289,6 +289,18 @@ bool SerialImpl::close()
return true;
}
bool SerialImpl::getPollFd(const px4_pollevent_t events, px4_pollfd_struct_t *pfd)
{
if (!_open) {
PX4_ERR("Device not open!");
return false;
}
pfd->fd = _serial_fd;
pfd->events = events;
return true;
}
ssize_t SerialImpl::bytesAvailable()
{
if (!_open) {
@@ -36,6 +36,7 @@
#include <stdint.h>
#include <unistd.h>
#include <px4_platform_common/posix.h>
#include <px4_platform_common/SerialCommon.hpp>
using device::SerialConfig::ByteSize;
@@ -59,6 +60,8 @@ public:
bool close();
bool getPollFd(const px4_pollevent_t events, px4_pollfd_struct_t *pfd);
ssize_t bytesAvailable();
ssize_t read(uint8_t *buffer, size_t buffer_size);
ssize_t readAtLeast(uint8_t *buffer, size_t buffer_size, size_t character_count = 1, uint32_t timeout_us = 0);