PX4 Firmware
PX4 Autopilot Software http://px4.io
UavcanCDevSensorBridgeBase Class Reference

This is the base class for redundant sensors with an independent ORB topic per each redundancy channel. More...

#include <sensor_bridge.hpp>

Inheritance diagram for UavcanCDevSensorBridgeBase:
Collaboration diagram for UavcanCDevSensorBridgeBase:

Classes

struct  Channel
 

Public Member Functions

virtual ~UavcanCDevSensorBridgeBase ()
 
unsigned get_num_redundant_channels () const override
 Returns number of active redundancy channels. More...
 
void print_status () const override
 Prints current status in a human readable format to stdout. More...
 
- Public Member Functions inherited from IUavcanSensorBridge
virtual ~IUavcanSensorBridge ()=default
 
virtual const char * get_name () const =0
 Returns ASCII name of the bridge. More...
 
virtual int init ()=0
 Starts the bridge. More...
 
- Public Member Functions inherited from ListNode< IUavcanSensorBridge *>
void setSibling (IUavcanSensorBridge * sibling)
 
const IUavcanSensorBridgegetSibling () const
 
- Public Member Functions inherited from device::CDev
 CDev (const char *name, const char *devname)
 Constructor. More...
 
virtual ~CDev ()=default
 
virtual int init ()
 
virtual int ioctl (file_t *filep, int cmd, unsigned long arg)
 Perform an ioctl operation on the device. More...
 
- Public Member Functions inherited from device::Device
 Device (const Device &)=delete
 
Deviceoperator= (const Device &)=delete
 
 Device (Device &&)=delete
 
Deviceoperator= (Device &&)=delete
 
virtual ~Device ()=default
 Destructor. More...
 
virtual int read (unsigned address, void *data, unsigned count)
 Read directly from the device. More...
 
virtual int write (unsigned address, void *data, unsigned count)
 Write directly to the device. More...
 
virtual int ioctl (unsigned operation, unsigned &arg)
 Perform a device-specific operation. More...
 
uint32_t get_device_id () const
 
DeviceBusType get_device_bus_type () const
 Return the bus type the device is connected to. More...
 
void set_device_bus_type (DeviceBusType bus_type)
 
uint8_t get_device_bus () const
 Return the bus ID the device is connected to. More...
 
void set_device_bus (uint8_t bus)
 
uint8_t get_device_address () const
 Return the bus address of the device. More...
 
void set_device_address (int address)
 
uint8_t get_device_type () const
 Return the device type. More...
 
void set_device_type (uint8_t devtype)
 
virtual bool external () const
 
- Public Member Functions inherited from cdev::CDev
 CDev (const char *devname)
 Constructor. More...
 
 CDev (const CDev &)=delete
 
CDevoperator= (const CDev &)=delete
 
 CDev (CDev &&)=delete
 
CDevoperator= (CDev &&)=delete
 
virtual int open (file_t *filep)
 Handle an open of the device. More...
 
virtual int close (file_t *filep)
 Handle a close of the device. More...
 
virtual ssize_t read (file_t *filep, char *buffer, size_t buflen)
 Perform a read from the device. More...
 
virtual ssize_t write (file_t *filep, const char *buffer, size_t buflen)
 Perform a write to the device. More...
 
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...
 

Protected Member Functions

 UavcanCDevSensorBridgeBase (const char *name, const char *devname, const char *class_devname, const orb_id_t orb_topic_sensor, const unsigned max_channels=DEFAULT_MAX_CHANNELS)
 
void publish (const int node_id, const void *report)
 Sends one measurement into appropriate ORB topic. More...
 
- Protected Member Functions inherited from device::Device
 Device (const char *name)
 
 Device (const char *name, DeviceBusType bus_type, uint8_t bus, uint8_t address, uint8_t devtype=0)
 
 Device (DeviceBusType bus_type, uint8_t bus, uint8_t address, uint8_t devtype=0)
 
- Protected Member Functions inherited from cdev::CDev
virtual pollevent_t poll_state (file_t *filep)
 Check the current state of the device for poll events from the perspective of the file. More...
 
virtual void poll_notify (pollevent_t events)
 Report new poll events. More...
 
virtual void poll_notify_one (px4_pollfd_struct_t *fds, pollevent_t events)
 Internal implementation of poll_notify. 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. More...
 
int unregister_driver_and_memory ()
 First, unregisters the driver. More...
 

Static Protected Attributes

static constexpr unsigned DEFAULT_MAX_CHANNELS = 5
 
- 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. More...
 

Private Attributes

const unsigned _max_channels
 
const char *const _class_devname
 
const orb_id_t _orb_topic
 
Channel *const _channels
 
bool _out_of_channels = false
 

Additional Inherited Members

- Public Types inherited from device::Device
enum  DeviceBusType {
  DeviceBusType_UNKNOWN = 0, DeviceBusType_I2C = 1, DeviceBusType_SPI = 2, DeviceBusType_UAVCAN = 3,
  DeviceBusType_SIMULATION = 4
}
 Device bus types for DEVID. More...
 
- Static Public Member Functions inherited from IUavcanSensorBridge
static void make_all (uavcan::INode &node, List< IUavcanSensorBridge *> &list)
 Sensor bridge factory. More...
 
- Static Public Member Functions inherited from device::Device
static const char * get_device_bus_string (DeviceBusType bus)
 
static int device_id_print_buffer (char *buffer, int length, uint32_t id)
 Print decoded device id string to a buffer. More...
 
- Static Public Attributes inherited from IUavcanSensorBridge
static constexpr unsigned MAX_NAME_LEN = 20
 
- Protected Attributes inherited from ListNode< IUavcanSensorBridge *>
IUavcanSensorBridge_list_node_sibling
 
- Protected Attributes inherited from device::CDev
bool _pub_blocked {false}
 true if publishing should be blocked More...
 
- Protected Attributes inherited from device::Device
const char * _name {nullptr}
 driver name More...
 
bool _debug_enabled {false}
 if true, debug messages are printed More...
 
- Protected Attributes inherited from cdev::CDev
px4_sem_t _lock
 lock to protect access to all class members (also for derived classes) More...
 

Detailed Description

This is the base class for redundant sensors with an independent ORB topic per each redundancy channel.

For example, sensor_mag0, sensor_mag1, etc.

Definition at line 88 of file sensor_bridge.hpp.

Constructor & Destructor Documentation

◆ UavcanCDevSensorBridgeBase()

UavcanCDevSensorBridgeBase::UavcanCDevSensorBridgeBase ( const char *  name,
const char *  devname,
const char *  class_devname,
const orb_id_t  orb_topic_sensor,
const unsigned  max_channels = DEFAULT_MAX_CHANNELS 
)
inlineprotected

Definition at line 106 of file sensor_bridge.hpp.

References IUavcanSensorBridge::get_num_redundant_channels(), and IUavcanSensorBridge::print_status().

Here is the call graph for this function:

◆ ~UavcanCDevSensorBridgeBase()

UavcanCDevSensorBridgeBase::~UavcanCDevSensorBridgeBase ( )
virtual

Definition at line 62 of file sensor_bridge.cpp.

Member Function Documentation

◆ get_num_redundant_channels()

unsigned UavcanCDevSensorBridgeBase::get_num_redundant_channels ( ) const
overridevirtual

Returns number of active redundancy channels.

Implements IUavcanSensorBridge.

Definition at line 144 of file sensor_bridge.cpp.

◆ print_status()

void UavcanCDevSensorBridgeBase::print_status ( ) const
overridevirtual

Prints current status in a human readable format to stdout.

Implements IUavcanSensorBridge.

Definition at line 158 of file sensor_bridge.cpp.

◆ publish()

void UavcanCDevSensorBridgeBase::publish ( const int  node_id,
const void *  report 
)
protected

Sends one measurement into appropriate ORB topic.

New redundancy channels will be registered automatically.

Parameters
node_idSensor's Node ID
reportPointer to ORB message object

Definition at line 74 of file sensor_bridge.cpp.

References UavcanCDevSensorBridgeBase::Channel::class_instance, DEVICE_LOG, UavcanCDevSensorBridgeBase::Channel::node_id, UavcanCDevSensorBridgeBase::Channel::orb_advert, orb_advertise_multi(), UavcanCDevSensorBridgeBase::Channel::orb_instance, ORB_PRIO_VERY_HIGH, and orb_publish().

Referenced by UavcanBarometerBridge::air_pressure_sub_cb(), UavcanBatteryBridge::battery_sub_cb(), UavcanFlowBridge::flow_sub_cb(), UavcanMagnetometerBridge::mag2_sub_cb(), and UavcanMagnetometerBridge::mag_sub_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _channels

Channel* const UavcanCDevSensorBridgeBase::_channels
private

Definition at line 100 of file sensor_bridge.hpp.

◆ _class_devname

const char* const UavcanCDevSensorBridgeBase::_class_devname
private

Definition at line 98 of file sensor_bridge.hpp.

◆ _max_channels

const unsigned UavcanCDevSensorBridgeBase::_max_channels
private

Definition at line 97 of file sensor_bridge.hpp.

◆ _orb_topic

const orb_id_t UavcanCDevSensorBridgeBase::_orb_topic
private

Definition at line 99 of file sensor_bridge.hpp.

◆ _out_of_channels

bool UavcanCDevSensorBridgeBase::_out_of_channels = false
private

Definition at line 101 of file sensor_bridge.hpp.

◆ DEFAULT_MAX_CHANNELS

constexpr unsigned UavcanCDevSensorBridgeBase::DEFAULT_MAX_CHANNELS = 5
staticprotected

Definition at line 104 of file sensor_bridge.hpp.


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