41 #ifdef ORB_COMMUNICATOR 58 uint8_t priority, uint8_t queue_size) :
71 CDev::unregister_driver_and_memory();
78 if (filp->
f_oflags == PX4_F_WRONLY) {
85 return CDev::open(filp);
89 if (filp->
f_oflags == PX4_F_RDONLY) {
102 filp->
f_priv = (
void *)sd;
104 int ret = CDev::open(filp);
109 PX4_ERR(
"CDev::open failed");
117 return CDev::open(filp);
127 if (filp->
f_oflags == PX4_F_RDONLY) {
138 return CDev::close(filp);
144 bool updated =
false;
146 if ((dst !=
nullptr) && (
_data !=
nullptr)) {
149 if (current_generation > generation +
_queue_size) {
155 if ((current_generation == generation) && (generation > 0)) {
164 if (generation < current_generation) {
203 if (
_data ==
nullptr) {
243 if (
nullptr ==
_data) {
247 if (!up_interrupt_context()) {
253 if (
nullptr ==
_data) {
265 if (
nullptr ==
_data) {
350 *(uintptr_t *)arg = (uintptr_t)
this;
369 *(
unsigned *)arg = 0;
381 return CDev::ioctl(filp, cmd, arg);
392 if ((devnode ==
nullptr) || (meta ==
nullptr) || (data ==
nullptr)) {
398 if (devnode->
_meta != meta) {
404 ret = devnode->
write(
nullptr, (
const char *)data, meta->
o_size);
411 if (ret != (
int)meta->
o_size) {
416 #ifdef ORB_COMMUNICATOR 424 PX4_ERR(
"Error Sending [%s] topic data over comm_channel", meta->
o_name);
436 if (handle ==
nullptr) {
458 #ifdef ORB_COMMUNICATOR 459 int16_t uORB::DeviceNode::topic_advertised(
const orb_metadata *meta,
int priority)
463 if (ch !=
nullptr && meta !=
nullptr) {
507 CDev::poll_notify_one(fds, events);
515 if (
_data ==
nullptr) {
556 #ifdef ORB_COMMUNICATOR 576 #ifdef ORB_COMMUNICATOR 590 #ifdef ORB_COMMUNICATOR 591 int16_t uORB::DeviceNode::process_add_subscription(int32_t rateInHz)
598 if (
_data !=
nullptr && ch !=
nullptr) {
605 int16_t uORB::DeviceNode::process_remove_subscription()
610 int16_t uORB::DeviceNode::process_received_message(int32_t length, uint8_t *
data)
615 PX4_ERR(
"Received '%s' with DataLength[%d] != ExpectedLen[%d]",
_meta->
o_name, (
int)length, (
int)
_meta->
o_size);
653 if (callback_sub !=
nullptr) {
658 if (callback_sub == existing_callbacks) {
664 _callbacks.add(callback_sub);
static ssize_t publish(const orb_metadata *meta, orb_advert_t handle, const void *data)
Method to publish a data to this node.
bool copy_locked(void *dst, unsigned &generation)
Copies data and the corresponding generation from a node to the buffer provided.
static uORB::Manager * get_instance()
Method to get the singleton instance for the uORB::Manager.
virtual int16_t topic_advertised(const char *messageName)=0
Interface to notify the remote entity of a topic being advertised.
px4::atomic< unsigned > _generation
object generation count
virtual int16_t send_message(const char *messageName, int32_t length, uint8_t *data)=0
Sends the data message over the communication link.
void unregister_callback(SubscriptionCallback *callback_sub)
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...
uint64_t last_update
time at which the last update was provided, used when update_interval is nonzero
virtual int16_t remove_subscription(const char *messageName)=0
Interface to notify the remote entity of removal of a subscription.
const orb_metadata * _meta
object metadata information
int update_queue_size(unsigned int queue_size)
Try to change the size of the queue.
void poll_notify_one(px4_pollfd_struct_t *fds, pollevent_t events) override
Internal implementation of poll_notify.
void lock()
Take the driver lock.
#define ORBIOCGETINTERVAL
Get the minimum interval at which the topic can be seen to be updated for this subscription.
int reset(enum LPS22HB_BUS busid)
Reset the driver.
void mark_as_advertised()
int open(cdev::file_t *filp) override
Method to create a subscriber instance and return the struct pointing to the subscriber as a file poi...
#define ORBIOCGPRIORITY
Get the priority for the topic.
uint8_t * _data
allocated object buffer
virtual void poll_notify(pollevent_t events)
Report new poll events.
#define ORBIOCSETINTERVAL
Set the minimum interval at which the topic can be seen to be updated for this subscription.
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. ...
uint8_t _priority
priority of the topic
virtual int16_t add_subscription(const char *messageName, int32_t msgRateInHz)=0
Interface to notify the remote entity of a topic being unadvertised and is no longer publishing messa...
unsigned published_message_count() const
uint32_t _lost_messages
nr of lost messages for all subscribers.
Per-object device instance.
uint64_t copy_and_get_timestamp(void *dst, unsigned &generation)
Copies data and the corresponding generation from a node to the buffer provided.
static hrt_abstime hrt_elapsed_time(const hrt_abstime *then)
Compute the delta between a timestamp taken in the past and now.
void remove_internal_subscriber()
Removes the subscriber from the list.
hrt_abstime _last_update
time the object was last updated
bool appears_updated(SubscriberData *sd)
Check whether a topic appears updated to a subscriber.
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
__BEGIN_DECLS typedef void * orb_advert_t
ORB topic advertiser handle.
#define ORBIOCISADVERTISED
Check whether the topic is advertised, sets *(unsigned long *)arg to 1 if advertised, 0 otherwise.
const uint8_t _instance
orb multi instance identifier
UpdateIntervalData * update_interval
if null, no update interval
int close(cdev::file_t *filp) override
Method to close a subscriber for this topic.
static SubscriberData * filp_to_sd(cdev::file_t *filp)
ssize_t read(cdev::file_t *filp, char *buffer, size_t buflen) override
reads data from a subscriber node to the buffer provided.
#define ORBIOCUPDATED
Check whether the topic has been updated since it was last read, sets *(bool *)arg.
#define ORBIOCLASTUPDATE
Fetch the time at which the topic was last updated into *(uint64_t *)arg.
void add_internal_subscriber()
Add the subscriber to the node's list of subscriber.
unsigned interval
if nonzero minimum interval between updates
bool copy(void *dst, unsigned &generation)
Copies data and the corresponding generation from a node to the buffer provided.
bool register_callback(SubscriptionCallback *callback_sub)
CDev(const char *devname)
Constructor.
DeviceNode(const struct orb_metadata *meta, const uint8_t instance, const char *path, uint8_t priority, uint8_t queue_size=1)
Interface to enable remote subscriptions.
List< uORB::SubscriptionCallback * > _callbacks
#define ORBIOCSETQUEUESIZE
Set the queue size of the topic.
static int unadvertise(orb_advert_t handle)
#define ORBIOCGADVERTISER
Get the global advertiser handle for the topic.
int ioctl(cdev::file_t *filp, int cmd, unsigned long arg) override
IOCTL control for the subscriber.
bool print_statistics(bool reset)
Print statistics (nr of lost messages)
void unlock()
Release the driver lock.
uint8_t _queue_size
maximum number of elements in the queue
unsigned generation
last generation the subscriber has seen
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
bool _advertised
has ever been advertised (not necessarily published data yet)