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

Public Member Functions

 IRLOCK (int bus=IRLOCK_I2C_BUS, int address=IRLOCK_I2C_ADDRESS)
 constructor More...
 
virtual ~IRLOCK ()
 destructor More...
 
virtual int init ()
 initialise driver to communicate with sensor More...
 
virtual int probe ()
 probe the device is on the I2C bus More...
 
virtual int info ()
 display driver info More...
 
virtual int test ()
 test driver More...
 
virtual ssize_t read (struct file *filp, char *buffer, size_t buflen)
 

Private Member Functions

void start ()
 start periodic reads from sensor More...
 
void stop ()
 stop periodic reads from sensor More...
 
void Run () override
 read from device and schedule next read More...
 
int read_device ()
 low level communication with sensor More...
 
bool sync_device ()
 sync device to ensure reading starts at new frame More...
 
int read_device_word (uint16_t *word)
 read a word (two bytes) from sensor More...
 
int read_device_block (struct irlock_target_s *block)
 read a single block (a full frame) from sensor More...
 

Private Attributes

ringbuffer::RingBuffer * _reports
 internal variables More...
 
bool _sensor_ok
 
uint32_t _read_failures
 
int _orb_class_instance
 
orb_advert_t _irlock_report_topic
 

Detailed Description

Definition at line 99 of file irlock.cpp.

Constructor & Destructor Documentation

◆ IRLOCK()

IRLOCK::IRLOCK ( int  bus = IRLOCK_I2C_BUS,
int  address = IRLOCK_I2C_ADDRESS 
)

constructor

Definition at line 149 of file irlock.cpp.

Referenced by irlock_main().

Here is the caller graph for this function:

◆ ~IRLOCK()

IRLOCK::~IRLOCK ( )
virtual

destructor

clear reports queue

Definition at line 161 of file irlock.cpp.

References _reports, and stop().

Here is the call graph for this function:

Member Function Documentation

◆ info()

int IRLOCK::info ( )
virtual

display driver info

display reports in queue

Definition at line 213 of file irlock.cpp.

References _read_failures, _reports, _sensor_ok, errx, OK, and warnx.

◆ init()

int IRLOCK::init ( )
virtual

initialise driver to communicate with sensor

initialise I2C bus

allocate buffer storing values read from sensor

start work queue

Definition at line 172 of file irlock.cpp.

References _reports, _sensor_ok, ToneAlarmInterface::init(), OK, and start().

Here is the call graph for this function:

◆ probe()

int IRLOCK::probe ( )
virtual

probe the device is on the I2C bus

Definition at line 196 of file irlock.cpp.

References OK.

◆ read()

ssize_t IRLOCK::read ( struct file filp,
char *  buffer,
size_t  buflen 
)
virtual

try to read

Definition at line 296 of file irlock.cpp.

References _reports.

◆ read_device()

int IRLOCK::read_device ( )
private

low level communication with sensor

read all available frames from sensor

if we sync, then we are starting a new frame, else fail

Definition at line 344 of file irlock.cpp.

References _irlock_report_topic, _orb_class_instance, _reports, DEVICE_LOG, hrt_absolute_time(), IRLOCK_OBJECTS_MAX, irlock_s::num_targets, OK, orb_advertise_multi(), ORB_ID, ORB_PRIO_LOW, orb_publish(), irlock_report_s::pos_x, irlock_target_s::pos_x, irlock_report_s::pos_y, irlock_target_s::pos_y, read_device_block(), irlock_report_s::signature, irlock_target_s::signature, irlock_report_s::size_x, irlock_target_s::size_x, irlock_report_s::size_y, irlock_target_s::size_y, sync_device(), irlock_s::targets, irlock_report_s::timestamp, and irlock_s::timestamp.

Referenced by Run().

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

◆ read_device_block()

int IRLOCK::read_device_block ( struct irlock_target_s block)
private

read a single block (a full frame) from sensor

crc check

convert to angles

Definition at line 406 of file irlock.cpp.

References _read_failures, IRLOCK_CENTER_X, IRLOCK_CENTER_Y, IRLOCK_TAN_ANG_PER_PIXEL_X, IRLOCK_TAN_ANG_PER_PIXEL_Y, irlock_target_s::pos_x, irlock_target_s::pos_y, irlock_report_s::signature, irlock_target_s::signature, irlock_target_s::size_x, irlock_target_s::size_y, and status.

Referenced by read_device().

Here is the caller graph for this function:

◆ read_device_word()

int IRLOCK::read_device_word ( uint16_t *  word)
private

read a word (two bytes) from sensor

Definition at line 394 of file irlock.cpp.

References status.

Referenced by sync_device().

Here is the caller graph for this function:

◆ Run()

void IRLOCK::Run ( )
overrideprivate

read from device and schedule next read

ignoring failure, if we do, we will be back again right away...

schedule the next cycle

Definition at line 287 of file irlock.cpp.

References IRLOCK_CONVERSION_INTERVAL_US, and read_device().

Here is the call graph for this function:

◆ start()

void IRLOCK::start ( )
private

start periodic reads from sensor

flush ring and reset state machine

start work queue cycle

Definition at line 272 of file irlock.cpp.

References _reports.

Referenced by init().

Here is the caller graph for this function:

◆ stop()

void IRLOCK::stop ( )
private

stop periodic reads from sensor

Definition at line 282 of file irlock.cpp.

Referenced by ~IRLOCK().

Here is the caller graph for this function:

◆ sync_device()

bool IRLOCK::sync_device ( )
private

sync device to ensure reading starts at new frame

Definition at line 320 of file irlock.cpp.

References IRLOCK_ADJUST, IRLOCK_RESYNC, IRLOCK_SYNC, OK, and read_device_word().

Referenced by read_device().

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

◆ test()

int IRLOCK::test ( )
virtual

test driver

exit immediately if driver not running

exit immediately if sensor is not healty

instructions to user

read from sensor for 10 seconds

output all objects found

sleep for 0.05 seconds

Definition at line 232 of file irlock.cpp.

References _reports, _sensor_ok, errx, hrt_absolute_time(), irlock_s::num_targets, OK, irlock_target_s::pos_x, irlock_target_s::pos_y, irlock_target_s::signature, irlock_target_s::size_x, irlock_target_s::size_y, irlock_s::targets, and warnx.

Here is the call graph for this function:

Member Data Documentation

◆ _irlock_report_topic

orb_advert_t IRLOCK::_irlock_report_topic
private

Definition at line 135 of file irlock.cpp.

Referenced by read_device().

◆ _orb_class_instance

int IRLOCK::_orb_class_instance
private

Definition at line 134 of file irlock.cpp.

Referenced by read_device().

◆ _read_failures

uint32_t IRLOCK::_read_failures
private

Definition at line 132 of file irlock.cpp.

Referenced by info(), and read_device_block().

◆ _reports

ringbuffer::RingBuffer* IRLOCK::_reports
private

internal variables

Definition at line 130 of file irlock.cpp.

Referenced by info(), init(), read(), read_device(), start(), test(), and ~IRLOCK().

◆ _sensor_ok

bool IRLOCK::_sensor_ok
private

Definition at line 131 of file irlock.cpp.

Referenced by info(), init(), and test().


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