mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 06:03:35 +08:00
DriverFramework purge
The bulk of this change was tightly coupled and needed to be deleted in one pass. Some of the smaller changes were things that broke as a result of the initial purge and subsequently fixed by further eradicating unnecessary platform differences. Finally, I deleted any dead code I came across in the related files I touched while going through everything.
- DriverFramework (src/lib/DriverFramework submodule) completely removed
- added dspal submodule in qurt platform (was brought in via DriverFramework)
- all df wrapper drivers removed
- all boards using df wrapper drivers updated to use in tree equivalents
- unused empty arch/board.h on posix and qurt removed
- unused IOCTLs removed (pub block, priv, etc)
- Integrator delete methods only used from df wrapper drivers
- commander: sensor calibration use "NuttX version" everywhere for now
- sensors: update to px4_{open, read, close} instead of DevMgr wrapper (adc open for analog differential pressure)
- battery_status: update to px4_{open, read, close} instead of DevMgr wrapper (adc open for analog differential pressure)
- cdev cleanup conflicting typedefs and names with actual OS (pollevent_t, etc)
- load_mon and top remove from linux boards (unused)
- delete unused PX4_MAIN_FUNCTION
- delete unused getreg32 macro
- delete unused SIOCDEVPRIVATE define
- named each platform tasks consistently
- posix list_devices and list_topics removed (list_files now shows all virtual files)
This commit is contained in:
Submodule src/lib/DriverFramework deleted from c7d2fe2d4f
+2
-23
@@ -188,27 +188,6 @@ CDev::close(file_t *filep)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
CDev::ioctl(file_t *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
PX4_DEBUG("CDev::ioctl");
|
||||
int ret = -ENOTTY;
|
||||
|
||||
switch (cmd) {
|
||||
|
||||
/* fetch a pointer to the driver's private data */
|
||||
case DIOC_GETPRIV:
|
||||
*(void **)(uintptr_t)arg = (void *)this;
|
||||
ret = PX4_OK;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
CDev::poll(file_t *filep, px4_pollfd_struct_t *fds, bool setup)
|
||||
{
|
||||
@@ -327,7 +306,7 @@ CDev::poll(file_t *filep, px4_pollfd_struct_t *fds, bool setup)
|
||||
}
|
||||
|
||||
void
|
||||
CDev::poll_notify(pollevent_t events)
|
||||
CDev::poll_notify(px4_pollevent_t events)
|
||||
{
|
||||
PX4_DEBUG("CDev::poll_notify events = %0x", events);
|
||||
|
||||
@@ -344,7 +323,7 @@ CDev::poll_notify(pollevent_t events)
|
||||
}
|
||||
|
||||
void
|
||||
CDev::poll_notify_one(px4_pollfd_struct_t *fds, pollevent_t events)
|
||||
CDev::poll_notify_one(px4_pollfd_struct_t *fds, px4_pollevent_t events)
|
||||
{
|
||||
PX4_DEBUG("CDev::poll_notify_one");
|
||||
|
||||
|
||||
@@ -137,8 +137,8 @@ public:
|
||||
/**
|
||||
* Perform an ioctl operation on the device.
|
||||
*
|
||||
* The default implementation handles DIOC_GETPRIV, and otherwise
|
||||
* returns -ENOTTY. Subclasses should call the default implementation
|
||||
* The default implementation returns -ENOTTY.
|
||||
* Subclasses should call the default implementation
|
||||
* for any command they do not handle themselves.
|
||||
*
|
||||
* @param filep Pointer to the NuttX file structure.
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
* @param arg The ioctl argument value.
|
||||
* @return OK on success, or -errno otherwise.
|
||||
*/
|
||||
virtual int ioctl(file_t *filep, int cmd, unsigned long arg);
|
||||
virtual int ioctl(file_t *filep, int cmd, unsigned long arg) { return -ENOTTY; };
|
||||
|
||||
/**
|
||||
* Perform a poll setup/teardown operation.
|
||||
@@ -187,7 +187,7 @@ protected:
|
||||
* @param filep The file that's interested.
|
||||
* @return The current set of poll events.
|
||||
*/
|
||||
virtual pollevent_t poll_state(file_t *filep) { return 0; }
|
||||
virtual px4_pollevent_t poll_state(file_t *filep) { return 0; }
|
||||
|
||||
/**
|
||||
* Report new poll events.
|
||||
@@ -197,7 +197,7 @@ protected:
|
||||
*
|
||||
* @param events The new event(s) being announced.
|
||||
*/
|
||||
virtual void poll_notify(pollevent_t events);
|
||||
virtual void poll_notify(px4_pollevent_t events);
|
||||
|
||||
/**
|
||||
* Internal implementation of poll_notify.
|
||||
@@ -205,7 +205,7 @@ protected:
|
||||
* @param fds A poll waiter to notify.
|
||||
* @param events The event(s) to send to the waiter.
|
||||
*/
|
||||
virtual void poll_notify_one(px4_pollfd_struct_t *fds, pollevent_t events);
|
||||
virtual void poll_notify_one(px4_pollfd_struct_t *fds, px4_pollevent_t events);
|
||||
|
||||
/**
|
||||
* Notification of the first open.
|
||||
|
||||
@@ -44,10 +44,7 @@
|
||||
#include <px4_platform_common/posix.h>
|
||||
#include <px4_platform_common/time.h>
|
||||
|
||||
#include "DevMgr.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace DriverFramework;
|
||||
|
||||
const cdev::px4_file_operations_t cdev::CDev::fops = {};
|
||||
|
||||
@@ -60,8 +57,6 @@ static cdev::file_t filemap[PX4_MAX_FD] = {};
|
||||
|
||||
extern "C" {
|
||||
|
||||
int px4_errno;
|
||||
|
||||
static cdev::CDev *getDev(const char *path)
|
||||
{
|
||||
PX4_DEBUG("CDev::getDev");
|
||||
@@ -233,7 +228,6 @@ extern "C" {
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
px4_errno = -ret;
|
||||
ret = PX4_ERROR;
|
||||
}
|
||||
|
||||
@@ -255,7 +249,6 @@ extern "C" {
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
px4_errno = -ret;
|
||||
ret = PX4_ERROR;
|
||||
}
|
||||
|
||||
@@ -277,7 +270,6 @@ extern "C" {
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
px4_errno = -ret;
|
||||
ret = PX4_ERROR;
|
||||
}
|
||||
|
||||
@@ -298,14 +290,10 @@ extern "C" {
|
||||
ret = -EINVAL;
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
px4_errno = -ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int px4_poll(px4_pollfd_struct_t *fds, nfds_t nfds, int timeout)
|
||||
int px4_poll(px4_pollfd_struct_t *fds, unsigned int nfds, int timeout)
|
||||
{
|
||||
if (nfds == 0) {
|
||||
PX4_WARN("px4_poll with no fds");
|
||||
@@ -315,7 +303,6 @@ extern "C" {
|
||||
px4_sem_t sem;
|
||||
int count = 0;
|
||||
int ret = -1;
|
||||
unsigned int i;
|
||||
|
||||
const unsigned NAMELEN = 32;
|
||||
char thread_name[NAMELEN] = {};
|
||||
@@ -339,7 +326,7 @@ extern "C" {
|
||||
// Go through all fds and check them for a pollable state
|
||||
bool fd_pollable = false;
|
||||
|
||||
for (i = 0; i < nfds; ++i) {
|
||||
for (unsigned int i = 0; i < nfds; ++i) {
|
||||
fds[i].sem = &sem;
|
||||
fds[i].revents = 0;
|
||||
fds[i].priv = nullptr;
|
||||
@@ -393,7 +380,7 @@ extern "C" {
|
||||
|
||||
// We have waited now (or not, depending on timeout),
|
||||
// go through all fds and count how many have data
|
||||
for (i = 0; i < nfds; ++i) {
|
||||
for (unsigned int i = 0; i < nfds; ++i) {
|
||||
|
||||
cdev::CDev *dev = get_vdev(fds[i].fd);
|
||||
|
||||
@@ -421,11 +408,6 @@ extern "C" {
|
||||
return (count) ? count : ret;
|
||||
}
|
||||
|
||||
int px4_fsync(int fd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int px4_access(const char *pathname, int mode)
|
||||
{
|
||||
if (mode != F_OK) {
|
||||
@@ -437,51 +419,6 @@ extern "C" {
|
||||
return (dev != nullptr) ? 0 : -1;
|
||||
}
|
||||
|
||||
void px4_show_devices()
|
||||
{
|
||||
int i = 0;
|
||||
PX4_INFO("PX4 Devices:");
|
||||
|
||||
pthread_mutex_lock(&devmutex);
|
||||
|
||||
for (const auto &dev : devmap) {
|
||||
if (strncmp(dev.first.c_str(), "/dev/", 5) == 0) {
|
||||
PX4_INFO(" %s", dev.first.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&devmutex);
|
||||
|
||||
PX4_INFO("DF Devices:");
|
||||
const char *dev_path;
|
||||
unsigned int index = 0;
|
||||
i = 0;
|
||||
|
||||
do {
|
||||
// Each look increments index and returns -1 if end reached
|
||||
i = DevMgr::getNextDeviceName(index, &dev_path);
|
||||
|
||||
if (i == 0) {
|
||||
PX4_INFO(" %s", dev_path);
|
||||
}
|
||||
} while (i == 0);
|
||||
}
|
||||
|
||||
void px4_show_topics()
|
||||
{
|
||||
PX4_INFO("Devices:");
|
||||
|
||||
pthread_mutex_lock(&devmutex);
|
||||
|
||||
for (const auto &dev : devmap) {
|
||||
if (strncmp(dev.first.c_str(), "/obj/", 5) == 0) {
|
||||
PX4_INFO(" %s", dev.first.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&devmutex);
|
||||
}
|
||||
|
||||
void px4_show_files()
|
||||
{
|
||||
PX4_INFO("Files:");
|
||||
@@ -489,10 +426,7 @@ extern "C" {
|
||||
pthread_mutex_lock(&devmutex);
|
||||
|
||||
for (const auto &dev : devmap) {
|
||||
if (strncmp(dev.first.c_str(), "/obj/", 5) != 0 &&
|
||||
strncmp(dev.first.c_str(), "/dev/", 5) != 0) {
|
||||
PX4_INFO(" %s", dev.first.c_str());
|
||||
}
|
||||
PX4_INFO_RAW(" %s\n", dev.first.c_str());
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&devmutex);
|
||||
|
||||
@@ -74,8 +74,6 @@ PX4Barometer::update(hrt_abstime timestamp, float pressure)
|
||||
report.timestamp = timestamp;
|
||||
report.pressure = pressure;
|
||||
|
||||
poll_notify(POLLIN);
|
||||
|
||||
_sensor_baro_pub.update();
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,9 @@ CDev::CDev(const char *name, const char *devname) :
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
CDev::init()
|
||||
int CDev::init()
|
||||
{
|
||||
DEVICE_DEBUG("CDev::init");
|
||||
PX4_DEBUG("CDev::init");
|
||||
|
||||
// base class init first
|
||||
int ret = Device::init();
|
||||
@@ -78,29 +77,12 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
CDev::ioctl(file_t *filep, int cmd, unsigned long arg)
|
||||
int CDev::ioctl(file_t *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
DEVICE_DEBUG("CDev::ioctl");
|
||||
PX4_DEBUG("CDev::ioctl");
|
||||
int ret = -ENOTTY;
|
||||
|
||||
switch (cmd) {
|
||||
|
||||
/* fetch a pointer to the driver's private data */
|
||||
case DIOC_GETPRIV:
|
||||
*(void **)(uintptr_t)arg = (void *)this;
|
||||
ret = PX4_OK;
|
||||
break;
|
||||
|
||||
case DEVIOCSPUBBLOCK:
|
||||
_pub_blocked = (arg != 0);
|
||||
ret = PX4_OK;
|
||||
break;
|
||||
|
||||
case DEVIOCGPUBBLOCK:
|
||||
ret = _pub_blocked;
|
||||
break;
|
||||
|
||||
case DEVIOCGDEVICEID:
|
||||
ret = (int)_device_id.devid;
|
||||
break;
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
/**
|
||||
* Perform an ioctl operation on the device.
|
||||
*
|
||||
* The default implementation handles DIOC_GETPRIV, and otherwise
|
||||
* The default implementation handles DEVIOCGDEVICEID, and otherwise
|
||||
* returns -ENOTTY. Subclasses should call the default implementation
|
||||
* for any command they do not handle themselves.
|
||||
*
|
||||
|
||||
@@ -114,50 +114,6 @@ Integrator::put(const hrt_abstime ×tamp, const matrix::Vector3f &val, matri
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Integrator::put_with_interval(unsigned interval_us, matrix::Vector3f &val, matrix::Vector3f &integral,
|
||||
uint32_t &integral_dt)
|
||||
{
|
||||
if (_last_integration_time == 0) {
|
||||
/* this is the first item in the integrator */
|
||||
hrt_abstime now = hrt_absolute_time();
|
||||
_last_integration_time = now;
|
||||
_last_reset_time = now;
|
||||
_last_val = val;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the timestamp artifically.
|
||||
const hrt_abstime timestamp = _last_integration_time + interval_us;
|
||||
|
||||
return put(timestamp, val, integral, integral_dt);
|
||||
}
|
||||
|
||||
matrix::Vector3f
|
||||
Integrator::get(bool reset, uint32_t &integral_dt)
|
||||
{
|
||||
matrix::Vector3f val = _alpha;
|
||||
|
||||
if (reset) {
|
||||
_reset(integral_dt);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
matrix::Vector3f
|
||||
Integrator::get_and_filtered(bool reset, uint32_t &integral_dt, matrix::Vector3f &filtered_val)
|
||||
{
|
||||
// Do the usual get with reset first but don't return yet.
|
||||
const matrix::Vector3f ret_integral = get(reset, integral_dt);
|
||||
|
||||
// Because we need both the integral and the integral_dt.
|
||||
filtered_val = ret_integral * 1000000 / integral_dt;
|
||||
|
||||
return ret_integral;
|
||||
}
|
||||
|
||||
void
|
||||
Integrator::_reset(uint32_t &integral_dt)
|
||||
{
|
||||
|
||||
@@ -51,12 +51,6 @@ public:
|
||||
Integrator(uint32_t auto_reset_interval = 4000 /* 250 Hz */, bool coning_compensation = false);
|
||||
~Integrator() = default;
|
||||
|
||||
// no copy, assignment, move, move assignment
|
||||
Integrator(const Integrator &) = delete;
|
||||
Integrator &operator=(const Integrator &) = delete;
|
||||
Integrator(Integrator &&) = delete;
|
||||
Integrator &operator=(Integrator &&) = delete;
|
||||
|
||||
/**
|
||||
* Put an item into the integral.
|
||||
*
|
||||
@@ -69,42 +63,6 @@ public:
|
||||
*/
|
||||
bool put(const uint64_t ×tamp, const matrix::Vector3f &val, matrix::Vector3f &integral, uint32_t &integral_dt);
|
||||
|
||||
/**
|
||||
* Put an item into the integral but provide an interval instead of a timestamp.
|
||||
*
|
||||
* @param interval_us Interval in us since last integration.
|
||||
* @param val Item to put.
|
||||
* @param integral Current integral in case the integrator did reset, else the value will not be modified
|
||||
* @param integral_dt Get the dt in us of the current integration (only if reset). Note that this
|
||||
* values might not be accurate vs. hrt_absolute_time because it is just the sum of the
|
||||
* supplied intervals.
|
||||
* @return true if putting the item triggered an integral reset and the integral should be
|
||||
* published.
|
||||
*/
|
||||
bool put_with_interval(unsigned interval_us, matrix::Vector3f &val, matrix::Vector3f &integral, uint32_t &integral_dt);
|
||||
|
||||
/**
|
||||
* Get the current integral and reset the integrator if needed.
|
||||
*
|
||||
* @param reset Reset the integral to zero.
|
||||
* @param integral_dt Get the dt in us of the current integration (only if reset).
|
||||
* @return the integral since the last read-reset
|
||||
*/
|
||||
matrix::Vector3f get(bool reset, uint32_t &integral_dt);
|
||||
|
||||
|
||||
/**
|
||||
* Get the current integral and reset the integrator if needed. Additionally give the
|
||||
* integral over the samples differentiated by the integration time (mean filtered values).
|
||||
*
|
||||
* @param reset Reset the integral to zero.
|
||||
* @param integral_dt Get the dt in us of the current integration (only if reset).
|
||||
* @param filtered_val The integral differentiated by the integration time.
|
||||
* @return the integral since the last read-reset
|
||||
*/
|
||||
matrix::Vector3f get_and_filtered(bool reset, uint32_t &integral_dt, matrix::Vector3f &filtered_val);
|
||||
|
||||
|
||||
/**
|
||||
* Set auto reset interval during runtime. This won't reset the integrator.
|
||||
*
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
|
||||
#include "../CDev.hpp"
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
|
||||
namespace device __EXPORT
|
||||
{
|
||||
|
||||
|
||||
@@ -131,7 +131,6 @@ PX4Magnetometer::update(hrt_abstime timestamp, int16_t x, int16_t y, int16_t z)
|
||||
report.y = val_calibrated(1);
|
||||
report.z = val_calibrated(2);
|
||||
|
||||
poll_notify(POLLIN);
|
||||
_sensor_mag_pub.update();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,20 +33,20 @@
|
||||
|
||||
set(SRCS
|
||||
conversions.c
|
||||
cpuload.c
|
||||
crc.c
|
||||
mavlink_log.cpp
|
||||
otp.c
|
||||
)
|
||||
)
|
||||
|
||||
if(${PX4_PLATFORM} STREQUAL "nuttx")
|
||||
list(APPEND SRCS
|
||||
cpuload.c
|
||||
print_load_nuttx.c
|
||||
)
|
||||
otp.c
|
||||
)
|
||||
else()
|
||||
list(APPEND SRCS
|
||||
print_load_posix.c
|
||||
)
|
||||
)
|
||||
endif()
|
||||
|
||||
px4_add_library(systemlib ${SRCS})
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
|
||||
#include "cpuload.h"
|
||||
|
||||
Reference in New Issue
Block a user