Firmware
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
uORB::DeviceNode Class Reference

Per-object device instance. More...

#include <uORBDeviceNode.hpp>

Inheritance diagram for uORB::DeviceNode:
cdev::CDev ListNode< uORB::DeviceNode *>

Public Member Functions

 DeviceNode (const struct orb_metadata *meta, const uint8_t instance, const char *path, uint8_t priority, uint8_t queue_size=1)
 
 DeviceNode (const DeviceNode &)=delete
 
DeviceNodeoperator= (const DeviceNode &)=delete
 
 DeviceNode (DeviceNode &&)=delete
 
DeviceNodeoperator= (DeviceNode &&)=delete
 
int open (cdev::file_t *filp) override
 Method to create a subscriber instance and return the struct pointing to the subscriber as a file pointer.
 
int close (cdev::file_t *filp) override
 Method to close a subscriber for this topic.
 
ssize_t read (cdev::file_t *filp, char *buffer, size_t buflen) override
 reads data from a subscriber node to the buffer provided. More...
 
ssize_t write (cdev::file_t *filp, const char *buffer, size_t buflen) override
 writes the published data to the internal buffer to be read by subscribers later. More...
 
int ioctl (cdev::file_t *filp, int cmd, unsigned long arg) override
 IOCTL control for the subscriber.
 
void add_internal_subscriber ()
 Add the subscriber to the node's list of subscriber. More...
 
void remove_internal_subscriber ()
 Removes the subscriber from the list. More...
 
bool is_published () const
 Return true if this topic has been published. More...
 
int update_queue_size (unsigned int queue_size)
 Try to change the size of the queue. More...
 
bool print_statistics (bool reset)
 Print statistics (nr of lost messages) More...
 
uint8_t get_queue_size () const
 
int8_t subscriber_count () const
 
uint32_t lost_message_count () const
 
unsigned published_message_count () const
 
const orb_metadataget_meta () const
 
const char * get_name () const
 
uint8_t get_instance () const
 
int get_priority () const
 
void set_priority (uint8_t priority)
 
- Public Member Functions inherited from cdev::CDev
 CDev (const char *devname)
 Constructor. More...
 
virtual int init ()
 
virtual off_t seek (file_t *filep, off_t offset, int whence)
 Perform a logical seek operation on the device. More...
 
virtual int poll (file_t *filep, px4_pollfd_struct_t *fds, bool setup)
 Perform a poll setup/teardown operation. More...
 
const char * get_devname () const
 Get the device name. More...
 
- Public Member Functions inherited from ListNode< uORB::DeviceNode *>
void setSibling (uORB::DeviceNode * sibling)
 
const uORB::DeviceNodegetSibling () const
 

Static Public Member Functions

static ssize_t publish (const orb_metadata *meta, orb_advert_t handle, const void *data)
 Method to publish a data to this node.
 
static int unadvertise (orb_advert_t handle)
 

Protected Member Functions

pollevent_t poll_state (cdev::file_t *filp) override
 Check the current state of the device for poll events from the perspective of the file. More...
 
void poll_notify_one (px4_pollfd_struct_t *fds, pollevent_t events) override
 Internal implementation of poll_notify. More...
 
- Protected Member Functions inherited from cdev::CDev
virtual void poll_notify (pollevent_t events)
 Report new poll events. More...
 
virtual int open_first (file_t *filep)
 Notification of the first open. More...
 
virtual int close_last (file_t *filep)
 Notification of the last close. More...
 
virtual int register_class_devname (const char *class_devname)
 Register a class device name, automatically adding device class instance suffix if need be. More...
 
virtual int unregister_class_devname (const char *class_devname, unsigned class_instance)
 Register a class device name, automatically adding device class instance suffix if need be. More...
 
void lock ()
 Take the driver lock. More...
 
void unlock ()
 Release the driver lock.
 

Additional Inherited Members

- Protected Attributes inherited from cdev::CDev
px4_sem_t _lock
 lock to protect access to all class members (also for derived classes)
 
- Protected Attributes inherited from ListNode< uORB::DeviceNode *>
uORB::DeviceNode_sibling
 
- Static Protected Attributes inherited from cdev::CDev
static const px4_file_operations_t fops = {}
 Pointer to the default cdev file operations table; useful for registering clone devices etc.
 

Detailed Description

Per-object device instance.

Member Function Documentation

§ add_internal_subscriber()

void uORB::DeviceNode::add_internal_subscriber ( )

Add the subscriber to the node's list of subscriber.

If there is remote proxy to which this subscription needs to be sent, it will done via uORBCommunicator::IChannel interface.

Parameters
sdthe subscriber to be added.

§ is_published()

bool uORB::DeviceNode::is_published ( ) const
inline

Return true if this topic has been published.

This is used in the case of multi_pub/sub to check if it's valid to advertise and publish to this node or if another node should be tried.

§ poll_notify_one()

void uORB::DeviceNode::poll_notify_one ( px4_pollfd_struct_t *  fds,
pollevent_t  events 
)
overrideprotectedvirtual

Internal implementation of poll_notify.

Parameters
fdsA poll waiter to notify.
eventsThe event(s) to send to the waiter.

Reimplemented from cdev::CDev.

§ poll_state()

pollevent_t uORB::DeviceNode::poll_state ( cdev::file_t filep)
overrideprotectedvirtual

Check the current state of the device for poll events from the perspective of the file.

This function is called by the default poll() implementation when a poll is set up to determine whether the poll should return immediately.

The default implementation returns no events.

Parameters
filepThe file that's interested.
Returns
The current set of poll events.

Reimplemented from cdev::CDev.

§ print_statistics()

bool uORB::DeviceNode::print_statistics ( bool  reset)

Print statistics (nr of lost messages)

Parameters
resetif true, reset statistics afterwards
Returns
true if printed something, false otherwise (if no lost messages)

§ read()

ssize_t uORB::DeviceNode::read ( cdev::file_t filp,
char *  buffer,
size_t  buflen 
)
overridevirtual

reads data from a subscriber node to the buffer provided.

Parameters
filpThe subscriber from which the data needs to be read from.
bufferThe buffer into which the data is read into.
buflenthe length of the buffer
Returns
ssize_t the number of bytes read.

Reimplemented from cdev::CDev.

§ remove_internal_subscriber()

void uORB::DeviceNode::remove_internal_subscriber ( )

Removes the subscriber from the list.

Also notifies the remote if there a uORBCommunicator::IChannel instance.

Parameters
sdthe Subscriber to be removed.

§ update_queue_size()

int uORB::DeviceNode::update_queue_size ( unsigned int  queue_size)

Try to change the size of the queue.

This can only be done as long as nobody published yet. This is the case, for example when orb_subscribe was called before an orb_advertise. The queue size can only be increased.

Parameters
queue_sizenew size of the queue
Returns
PX4_OK if queue size successfully set

§ write()

ssize_t uORB::DeviceNode::write ( cdev::file_t filp,
const char *  buffer,
size_t  buflen 
)
overridevirtual

writes the published data to the internal buffer to be read by subscribers later.

Parameters
filpthe subscriber; this is not used.
bufferThe buffer for the input data
buflenthe length of the buffer.
Returns
ssize_t The number of bytes that are written

Reimplemented from cdev::CDev.


The documentation for this class was generated from the following files: