47 #include "nuttx/cdev_platform.hpp" 49 #include "posix/cdev_platform.hpp" 67 CDev(
const char *devname);
82 virtual int open(
file_t *filep);
93 virtual int close(
file_t *filep);
129 virtual off_t
seek(
file_t *filep, off_t offset,
int whence) {
return -ENOSYS; }
143 virtual int ioctl(
file_t *filep,
int cmd,
unsigned long arg);
156 virtual int poll(
file_t *filep, px4_pollfd_struct_t *fds,
bool setup);
194 virtual void poll_notify(pollevent_t
events);
202 virtual void poll_notify_one(px4_pollfd_struct_t *fds, pollevent_t events);
237 virtual int register_class_devname(
const char *class_devname);
247 virtual int unregister_class_devname(
const char *class_devname,
unsigned class_instance);
258 void lock() {
do {}
while (px4_sem_wait(&_lock) != 0); }
268 const char *_devname{
nullptr};
270 px4_pollfd_struct_t **_pollset{
nullptr};
272 bool _registered{
false};
274 uint8_t _max_pollwaiters{0};
275 uint16_t _open_count{0};
284 inline int store_poll_waiter(px4_pollfd_struct_t *fds);
291 inline int remove_poll_waiter(px4_pollfd_struct_t *fds);
void unlock()
Release the driver lock.
Definition: CDev.hpp:263
virtual ssize_t write(file_t *filep, const char *buffer, size_t buflen)
Perform a write to the device.
Definition: CDev.hpp:117
virtual ssize_t read(file_t *filep, char *buffer, size_t buflen)
Perform a read from the device.
Definition: CDev.hpp:105
void lock()
Take the driver lock.
Definition: CDev.hpp:258
Configuration flags used in code.
Includes POSIX-like functions for virtual character devices.
static const px4_file_operations_t fops
Pointer to the default cdev file operations table; useful for registering clone devices etc...
Definition: CDev.hpp:170
px4_sem_t _lock
lock to protect access to all class members (also for derived classes)
Definition: CDev.hpp:265
virtual int open_first(file_t *filep)
Notification of the first open.
Definition: CDev.hpp:215
const char * get_devname() const
Get the device name.
Definition: CDev.hpp:163
virtual pollevent_t poll_state(file_t *filep)
Check the current state of the device for poll events from the perspective of the file...
Definition: CDev.hpp:184
Definition: cdev_platform.hpp:20
Definition: cdev_platform.hpp:13
Definition: rc_loss_alarm.cpp:50
Abstract class for any character device.
Definition: CDev.hpp:58
Definition: video_device.h:50
virtual off_t seek(file_t *filep, off_t offset, int whence)
Perform a logical seek operation on the device.
Definition: CDev.hpp:129
virtual int close_last(file_t *filep)
Notification of the last close.
Definition: CDev.hpp:228