Firmware
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
AirspeedSim Class Referenceabstract
Inheritance diagram for AirspeedSim:
cdev::CDev MEASAirspeedSim

Classes

struct  _work
 

Public Member Functions

 AirspeedSim (int bus, int address, unsigned conversion_interval, const char *path)
 
virtual int init ()
 
virtual ssize_t read (cdev::file_t *filp, char *buffer, size_t buflen)
 Perform a read from the device. More...
 
virtual int ioctl (cdev::file_t *filp, int cmd, unsigned long arg)
 Perform an ioctl operation on the device. More...
 
virtual void print_info ()
 Diagnostics - print some basic information about the driver.
 
- Public Member Functions inherited from cdev::CDev
 CDev (const char *devname)
 Constructor. More...
 
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 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

virtual int probe ()
 
virtual void cycle ()=0
 Perform a poll cycle; collect from the previous measurement and start a new one.
 
virtual int measure ()=0
 
virtual int collect ()=0
 
virtual int transfer (const uint8_t *send, unsigned send_len, uint8_t *recv, unsigned recv_len)
 
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.
 
void new_report (const differential_pressure_s &report)
 add a new report to the reports queue More...
 
- 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.
 

Static Protected Member Functions

static void cycle_trampoline (void *arg)
 Static trampoline from the workq context; because we don't have a generic workq wrapper yet. More...
 

Protected Attributes

bool _sensor_ok
 
int _measure_ticks
 
bool _collect_phase
 
float _diff_pres_offset
 
orb_advert_t _airspeed_pub
 
int _class_instance
 
int _conversion_interval
 
perf_counter_t _sample_perf
 
perf_counter_t _comms_errors
 
- Protected Attributes inherited from cdev::CDev
px4_sem_t _lock
 lock to protect access to all class members (also for derived classes)
 

Additional Inherited Members

- 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.
 

Member Function Documentation

§ cycle_trampoline()

void AirspeedSim::cycle_trampoline ( void *  arg)
staticprotected

Static trampoline from the workq context; because we don't have a generic workq wrapper yet.

Parameters
argInstance pointer for the driver that is polling.

§ ioctl()

int AirspeedSim::ioctl ( cdev::file_t filep,
int  cmd,
unsigned long  arg 
)
virtual

Perform an ioctl operation on the device.

The default implementation handles DIOC_GETPRIV, and otherwise returns -ENOTTY. Subclasses should call the default implementation for any command they do not handle themselves.

Parameters
filepPointer to the NuttX file structure.
cmdThe ioctl command value.
argThe ioctl argument value.
Returns
OK on success, or -errno otherwise.

Reimplemented from cdev::CDev.

§ new_report()

void AirspeedSim::new_report ( const differential_pressure_s &  report)
protected

add a new report to the reports queue

Parameters
reportdifferential_pressure_s report

§ probe_address()

int AirspeedSim::probe_address ( uint8_t  address)
protected

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 AirspeedSim::read ( cdev::file_t filep,
char *  buffer,
size_t  buflen 
)
virtual

Perform a read from the device.

The default implementation returns -ENOSYS.

Parameters
filepPointer to the NuttX file structure.
bufferPointer to the buffer into which data should be placed.
buflenThe number of bytes to be read.
Returns
The number of bytes read or -errno otherwise.

Reimplemented from cdev::CDev.

§ start()

void AirspeedSim::start ( void  )
protected

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.

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