PX4 Firmware
PX4 Autopilot Software http://px4.io
SF1XX Class Reference
Inheritance diagram for SF1XX:
Collaboration diagram for SF1XX:

Public Member Functions

 SF1XX (uint8_t rotation=distance_sensor_s::ROTATION_DOWNWARD_FACING, int bus=SF1XX_BUS_DEFAULT, int address=SF1XX_BASEADDR)
 
virtual ~SF1XX () override
 
int init () override
 
ssize_t read (device::file_t *filp, char *buffer, size_t buflen) override
 
int ioctl (device::file_t *filp, int cmd, unsigned long arg) override
 
void print_info ()
 Diagnostics - print some basic information about the driver. More...
 

Protected Member Functions

int probe () override
 

Private Member Functions

int probe_address (uint8_t address)
 Test whether the device supported by the driver is present at a specific address. More...
 
void start ()
 Initialise the automatic measurement state machine and start it. More...
 
void stop ()
 Stop the automatic measurement state machine. More...
 
void set_minimum_distance (float min)
 Set the min and max distance thresholds if you want the end points of the sensors range to be brought in at all, otherwise it will use the defaults SF1XX_MIN_DISTANCE and SF1XX_MAX_DISTANCE. More...
 
void set_maximum_distance (float max)
 
float get_minimum_distance ()
 
float get_maximum_distance ()
 
void Run () override
 Perform a poll cycle; collect from the previous measurement and start a new one. More...
 
int measure ()
 
int collect ()
 

Private Attributes

bool _sensor_ok {false}
 
int _class_instance {-1}
 
int _conversion_interval {-1}
 
int _measure_interval {0}
 
int _orb_class_instance {-1}
 
float _max_distance {-1.0f}
 
float _min_distance {-1.0f}
 
uint8_t _rotation {0}
 
ringbuffer::RingBuffer * _reports {nullptr}
 
orb_advert_t _distance_sensor_topic {nullptr}
 
perf_counter_t _sample_perf {perf_alloc(PC_ELAPSED, "sf1xx_read")}
 
perf_counter_t _comms_errors {perf_alloc(PC_COUNT, "sf1xx_com_err")}
 

Detailed Description

Definition at line 82 of file sf1xx.cpp.

Constructor & Destructor Documentation

◆ SF1XX()

SF1XX::SF1XX ( uint8_t  rotation = distance_sensor_s::ROTATION_DOWNWARD_FACING,
int  bus = SF1XX_BUS_DEFAULT,
int  address = SF1XX_BASEADDR 
)

Definition at line 169 of file sf1xx.cpp.

Referenced by sf1xx::start_bus().

Here is the caller graph for this function:

◆ ~SF1XX()

SF1XX::~SF1XX ( )
overridevirtual

Definition at line 176 of file sf1xx.cpp.

References _class_instance, _comms_errors, _distance_sensor_topic, _reports, _sample_perf, orb_unadvertise(), perf_free(), RANGE_FINDER_BASE_DEVICE_PATH, and stop().

Here is the call graph for this function:

Member Function Documentation

◆ collect()

int SF1XX::collect ( )
private

Definition at line 469 of file sf1xx.cpp.

References _comms_errors, _distance_sensor_topic, _reports, _rotation, _sample_perf, distance_sensor_s::current_distance, f(), get_maximum_distance(), get_minimum_distance(), hrt_absolute_time(), distance_sensor_s::id, distance_sensor_s::max_distance, distance_sensor_s::min_distance, OK, ORB_ID, orb_publish(), distance_sensor_s::orientation, perf_begin(), perf_count(), perf_end(), distance_sensor_s::signal_quality, distance_sensor_s::timestamp, distance_sensor_s::type, and distance_sensor_s::variance.

Referenced by read(), and Run().

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

◆ get_maximum_distance()

float SF1XX::get_maximum_distance ( )
private

Definition at line 319 of file sf1xx.cpp.

References _max_distance.

Referenced by collect().

Here is the caller graph for this function:

◆ get_minimum_distance()

float SF1XX::get_minimum_distance ( )
private

Definition at line 313 of file sf1xx.cpp.

References _min_distance.

Referenced by collect().

Here is the caller graph for this function:

◆ init()

int SF1XX::init ( )
override

Definition at line 200 of file sf1xx.cpp.

References _class_instance, _conversion_interval, _distance_sensor_topic, _max_distance, _min_distance, _orb_class_instance, _reports, _sensor_ok, ToneAlarmInterface::init(), measure(), OK, orb_advertise_multi(), ORB_ID, ORB_PRIO_HIGH, param_find(), param_get(), RANGE_FINDER_BASE_DEVICE_PATH, and SF1XX_BASEADDR.

Referenced by sf1xx::start_bus().

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

◆ ioctl()

int SF1XX::ioctl ( device::file_t filp,
int  cmd,
unsigned long  arg 
)
override

Definition at line 325 of file sf1xx.cpp.

References _conversion_interval, _measure_interval, OK, SENSOR_POLLRATE_DEFAULT, SENSORIOCSPOLLRATE, and start().

Referenced by sf1xx::reset(), sf1xx::start_bus(), and sf1xx::test().

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

◆ measure()

int SF1XX::measure ( )
private

Definition at line 446 of file sf1xx.cpp.

References _comms_errors, OK, and perf_count().

Referenced by init(), probe(), read(), and start().

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

◆ print_info()

void SF1XX::print_info ( )

Diagnostics - print some basic information about the driver.

Definition at line 552 of file sf1xx.cpp.

References _comms_errors, _measure_interval, _reports, _sample_perf, and perf_print_counter().

Referenced by sf1xx::info().

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

◆ probe()

int SF1XX::probe ( )
overrideprotected

Definition at line 295 of file sf1xx.cpp.

References measure().

Here is the call graph for this function:

◆ probe_address()

int SF1XX::probe_address ( uint8_t  address)
private

Test whether the device supported by the driver is present at a specific address.

Parameters
addressThe I2C bus address to probe.
Returns
True if the device is present.

◆ read()

ssize_t SF1XX::read ( device::file_t filp,
char *  buffer,
size_t  buflen 
)
override

Definition at line 386 of file sf1xx.cpp.

References _conversion_interval, _measure_interval, _reports, collect(), measure(), and OK.

Referenced by sf1xx::test().

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

◆ Run()

void SF1XX::Run ( )
overrideprivate

Perform a poll cycle; collect from the previous measurement and start a new one.

Definition at line 537 of file sf1xx.cpp.

References _conversion_interval, collect(), OK, and start().

Here is the call graph for this function:

◆ set_maximum_distance()

void SF1XX::set_maximum_distance ( float  max)
private

Definition at line 307 of file sf1xx.cpp.

References _max_distance, and math::max().

Here is the call graph for this function:

◆ set_minimum_distance()

void SF1XX::set_minimum_distance ( float  min)
private

Set the min and max distance thresholds if you want the end points of the sensors range to be brought in at all, otherwise it will use the defaults SF1XX_MIN_DISTANCE and SF1XX_MAX_DISTANCE.

Definition at line 301 of file sf1xx.cpp.

References _min_distance, and math::min().

Here is the call graph for this function:

◆ start()

void SF1XX::start ( )
private

Initialise the automatic measurement state machine and start it.

Note
This function is called at open and error time. It might make sense to make it more aggressive about resetting the bus in case of errors.

Definition at line 518 of file sf1xx.cpp.

References _conversion_interval, _reports, and measure().

Referenced by ioctl(), and Run().

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

◆ stop()

void SF1XX::stop ( )
private

Stop the automatic measurement state machine.

Definition at line 531 of file sf1xx.cpp.

Referenced by ~SF1XX().

Here is the caller graph for this function:

Member Data Documentation

◆ _class_instance

int SF1XX::_class_instance {-1}
private

Definition at line 146 of file sf1xx.cpp.

Referenced by init(), and ~SF1XX().

◆ _comms_errors

perf_counter_t SF1XX::_comms_errors {perf_alloc(PC_COUNT, "sf1xx_com_err")}
private

Definition at line 161 of file sf1xx.cpp.

Referenced by collect(), measure(), print_info(), and ~SF1XX().

◆ _conversion_interval

int SF1XX::_conversion_interval {-1}
private

Definition at line 147 of file sf1xx.cpp.

Referenced by init(), ioctl(), read(), Run(), and start().

◆ _distance_sensor_topic

orb_advert_t SF1XX::_distance_sensor_topic {nullptr}
private

Definition at line 158 of file sf1xx.cpp.

Referenced by collect(), init(), and ~SF1XX().

◆ _max_distance

float SF1XX::_max_distance {-1.0f}
private

Definition at line 151 of file sf1xx.cpp.

Referenced by get_maximum_distance(), init(), and set_maximum_distance().

◆ _measure_interval

int SF1XX::_measure_interval {0}
private

Definition at line 148 of file sf1xx.cpp.

Referenced by ioctl(), print_info(), and read().

◆ _min_distance

float SF1XX::_min_distance {-1.0f}
private

Definition at line 152 of file sf1xx.cpp.

Referenced by get_minimum_distance(), init(), and set_minimum_distance().

◆ _orb_class_instance

int SF1XX::_orb_class_instance {-1}
private

Definition at line 149 of file sf1xx.cpp.

Referenced by init().

◆ _reports

ringbuffer::RingBuffer* SF1XX::_reports {nullptr}
private

Definition at line 156 of file sf1xx.cpp.

Referenced by collect(), init(), print_info(), read(), start(), and ~SF1XX().

◆ _rotation

uint8_t SF1XX::_rotation {0}
private

Definition at line 154 of file sf1xx.cpp.

Referenced by collect().

◆ _sample_perf

perf_counter_t SF1XX::_sample_perf {perf_alloc(PC_ELAPSED, "sf1xx_read")}
private

Definition at line 160 of file sf1xx.cpp.

Referenced by collect(), print_info(), and ~SF1XX().

◆ _sensor_ok

bool SF1XX::_sensor_ok {false}
private

Definition at line 144 of file sf1xx.cpp.

Referenced by init().


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