Changed device::px4_device_handle_t to device::file_t

This change allowed the _posix.cpp file changes to be merged
back into the original files.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-04-24 17:49:35 -07:00
parent 20d35e33da
commit d913ec8dc9
28 changed files with 600 additions and 1327 deletions
@@ -100,8 +100,8 @@ public:
virtual int init();
virtual ssize_t read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen);
virtual int ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg);
virtual ssize_t read(device::file_t *filp, char *buffer, size_t buflen);
virtual int ioctl(device::file_t *filp, int cmd, unsigned long arg);
/**
* Diagnostics - print some basic information about the driver.
@@ -116,8 +116,8 @@ public:
protected:
friend class ACCELSIM_mag;
virtual ssize_t mag_read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen);
virtual int mag_ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg);
virtual ssize_t mag_read(device::file_t *filp, char *buffer, size_t buflen);
virtual int mag_ioctl(device::file_t *filp, int cmd, unsigned long arg);
int transfer(uint8_t *send, uint8_t *recv, unsigned len);
private:
@@ -325,8 +325,8 @@ public:
ACCELSIM_mag(ACCELSIM *parent);
~ACCELSIM_mag();
virtual ssize_t read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen);
virtual int ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg);
virtual ssize_t read(device::file_t *filp, char *buffer, size_t buflen);
virtual int ioctl(device::file_t *filp, int cmd, unsigned long arg);
virtual int init();
@@ -516,7 +516,7 @@ ACCELSIM::transfer(uint8_t *send, uint8_t *recv, unsigned len)
}
ssize_t
ACCELSIM::read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen)
ACCELSIM::read(device::file_t *filp, char *buffer, size_t buflen)
{
unsigned count = buflen / sizeof(struct accel_report);
accel_report *arb = reinterpret_cast<accel_report *>(buffer);
@@ -553,7 +553,7 @@ ACCELSIM::read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen)
}
ssize_t
ACCELSIM::mag_read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen)
ACCELSIM::mag_read(device::file_t *filp, char *buffer, size_t buflen)
{
unsigned count = buflen / sizeof(struct mag_report);
mag_report *mrb = reinterpret_cast<mag_report *>(buffer);
@@ -592,7 +592,7 @@ ACCELSIM::mag_read(device::px4_dev_handle_t *handlep, char *buffer, size_t bufle
}
int
ACCELSIM::ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg)
ACCELSIM::ioctl(device::file_t *filp, int cmd, unsigned long arg)
{
switch (cmd) {
@@ -614,10 +614,10 @@ ACCELSIM::ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg)
/* set default/max polling rate */
case SENSOR_POLLRATE_MAX:
return ioctl(handlep, SENSORIOCSPOLLRATE, 1600);
return ioctl(filp, SENSORIOCSPOLLRATE, 1600);
case SENSOR_POLLRATE_DEFAULT:
return ioctl(handlep, SENSORIOCSPOLLRATE, ACCELSIM_ACCEL_DEFAULT_RATE);
return ioctl(filp, SENSORIOCSPOLLRATE, ACCELSIM_ACCEL_DEFAULT_RATE);
/* adjust to a legal polling interval in Hz */
default: {
@@ -712,12 +712,12 @@ ACCELSIM::ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg)
default:
/* give it to the superclass */
return VDev::ioctl(handlep, cmd, arg);
return VDev::ioctl(filp, cmd, arg);
}
}
int
ACCELSIM::mag_ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg)
ACCELSIM::mag_ioctl(device::file_t *filp, int cmd, unsigned long arg)
{
switch (cmd) {
@@ -741,7 +741,7 @@ ACCELSIM::mag_ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long ar
case SENSOR_POLLRATE_MAX:
case SENSOR_POLLRATE_DEFAULT:
/* 100 Hz is max for mag */
return mag_ioctl(handlep, SENSORIOCSPOLLRATE, 100);
return mag_ioctl(filp, SENSORIOCSPOLLRATE, 100);
/* adjust to a legal polling interval in Hz */
default: {
@@ -831,7 +831,7 @@ ACCELSIM::mag_ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long ar
return OK;
default:
/* give it to the superclass */
return VDev::ioctl(handlep, cmd, arg);
return VDev::ioctl(filp, cmd, arg);
}
}
@@ -1209,20 +1209,20 @@ ACCELSIM_mag::parent_poll_notify()
}
ssize_t
ACCELSIM_mag::read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen)
ACCELSIM_mag::read(device::file_t *filp, char *buffer, size_t buflen)
{
return _parent->mag_read(handlep, buffer, buflen);
return _parent->mag_read(filp, buffer, buflen);
}
int
ACCELSIM_mag::ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg)
ACCELSIM_mag::ioctl(device::file_t *filp, int cmd, unsigned long arg)
{
switch (cmd) {
case DEVIOCGDEVICEID:
return (int)VDev::ioctl(handlep, cmd, arg);
return (int)VDev::ioctl(filp, cmd, arg);
break;
default:
return _parent->mag_ioctl(handlep, cmd, arg);
return _parent->mag_ioctl(filp, cmd, arg);
}
}
@@ -74,12 +74,12 @@ public:
virtual int init();
virtual int ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg);
virtual ssize_t read(device::px4_dev_handle_t *handlep, char *buffer, size_t len);
virtual int ioctl(device::file_t *filp, int cmd, unsigned long arg);
virtual ssize_t read(device::file_t *filp, char *buffer, size_t len);
protected:
virtual int open_first(device::px4_dev_handle_t *handlep);
virtual int close_last(device::px4_dev_handle_t *handlep);
virtual int open_first(device::file_t *filp);
virtual int close_last(device::file_t *filp);
private:
static const hrt_abstime _tickrate = 10000; /**< 100Hz base rate */
@@ -157,13 +157,13 @@ ADCSIM::init()
}
int
ADCSIM::ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg)
ADCSIM::ioctl(device::file_t *filp, int cmd, unsigned long arg)
{
return -ENOTTY;
}
ssize_t
ADCSIM::read(device::px4_dev_handle_t *handlep, char *buffer, size_t len)
ADCSIM::read(device::file_t *filp, char *buffer, size_t len)
{
const size_t maxsize = sizeof(adc_msg_s) * _channel_count;
@@ -177,7 +177,7 @@ ADCSIM::read(device::px4_dev_handle_t *handlep, char *buffer, size_t len)
}
int
ADCSIM::open_first(device::px4_dev_handle_t *handlep)
ADCSIM::open_first(device::file_t *filp)
{
/* get fresh data */
_tick();
@@ -189,7 +189,7 @@ ADCSIM::open_first(device::px4_dev_handle_t *handlep)
}
int
ADCSIM::close_last(device::px4_dev_handle_t *handlep)
ADCSIM::close_last(device::file_t *filp)
{
hrt_cancel(&_call);
return 0;
+5 -5
View File
@@ -100,8 +100,8 @@ public:
virtual int init();
virtual ssize_t read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen);
virtual int ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg);
virtual ssize_t read(device::file_t *filp, char *buffer, size_t buflen);
virtual int ioctl(device::file_t *filp, int cmd, unsigned long arg);
/**
* Diagnostics - print some basic information about the driver.
@@ -327,7 +327,7 @@ out:
}
ssize_t
BAROSIM::read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen)
BAROSIM::read(device::file_t *filp, char *buffer, size_t buflen)
{
unsigned count = buflen / sizeof(struct baro_report);
struct baro_report *brp = reinterpret_cast<struct baro_report *>(buffer);
@@ -397,7 +397,7 @@ BAROSIM::read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen)
}
int
BAROSIM::ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg)
BAROSIM::ioctl(device::file_t *filp, int cmd, unsigned long arg)
{
switch (cmd) {
@@ -502,7 +502,7 @@ BAROSIM::ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg)
/* give it to the bus-specific superclass */
// return bus_ioctl(filp, cmd, arg);
return VDev::ioctl(handlep, cmd, arg);
return VDev::ioctl(filp, cmd, arg);
}
void
+20 -20
View File
@@ -197,8 +197,8 @@ public:
virtual int init();
virtual ssize_t read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen);
virtual int ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg);
virtual ssize_t read(device::file_t *filp, char *buffer, size_t buflen);
virtual int ioctl(device::file_t *filp, int cmd, unsigned long arg);
int transfer(uint8_t *send, uint8_t *recv, unsigned len);
/**
@@ -211,8 +211,8 @@ public:
protected:
friend class GYROSIM_gyro;
virtual ssize_t gyro_read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen);
virtual int gyro_ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg);
virtual ssize_t gyro_read(device::file_t *filp, char *buffer, size_t buflen);
virtual int gyro_ioctl(device::file_t *filp, int cmd, unsigned long arg);
private:
GYROSIM_gyro *_gyro;
@@ -438,8 +438,8 @@ public:
GYROSIM_gyro(GYROSIM *parent, const char *path);
~GYROSIM_gyro();
virtual ssize_t read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen);
virtual int ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg);
virtual ssize_t read(device::file_t *filp, char *buffer, size_t buflen);
virtual int ioctl(device::file_t *filp, int cmd, unsigned long arg);
virtual int init();
@@ -733,7 +733,7 @@ GYROSIM::_set_dlpf_filter(uint16_t frequency_hz)
}
ssize_t
GYROSIM::read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen)
GYROSIM::read(device::file_t *filp, char *buffer, size_t buflen)
{
unsigned count = buflen / sizeof(accel_report);
@@ -856,7 +856,7 @@ GYROSIM::gyro_self_test()
}
ssize_t
GYROSIM::gyro_read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen)
GYROSIM::gyro_read(device::file_t *filp, char *buffer, size_t buflen)
{
unsigned count = buflen / sizeof(gyro_report);
@@ -891,7 +891,7 @@ GYROSIM::gyro_read(device::px4_dev_handle_t *handlep, char *buffer, size_t bufle
}
int
GYROSIM::ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg)
GYROSIM::ioctl(device::file_t *filp, int cmd, unsigned long arg)
{
switch (cmd) {
@@ -916,10 +916,10 @@ GYROSIM::ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg)
/* set default/max polling rate */
case SENSOR_POLLRATE_MAX:
return ioctl(handlep, SENSORIOCSPOLLRATE, 1000);
return ioctl(filp, SENSORIOCSPOLLRATE, 1000);
case SENSOR_POLLRATE_DEFAULT:
return ioctl(handlep, SENSORIOCSPOLLRATE, GYROSIM_ACCEL_DEFAULT_RATE);
return ioctl(filp, SENSORIOCSPOLLRATE, GYROSIM_ACCEL_DEFAULT_RATE);
/* adjust to a legal polling interval in Hz */
default: {
@@ -1030,12 +1030,12 @@ GYROSIM::ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg)
default:
/* give it to the superclass */
return VDev::ioctl(handlep, cmd, arg);
return VDev::ioctl(filp, cmd, arg);
}
}
int
GYROSIM::gyro_ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg)
GYROSIM::gyro_ioctl(device::file_t *filp, int cmd, unsigned long arg)
{
switch (cmd) {
@@ -1043,7 +1043,7 @@ GYROSIM::gyro_ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long ar
case SENSORIOCSPOLLRATE:
case SENSORIOCGPOLLRATE:
case SENSORIOCRESET:
return ioctl(handlep, cmd, arg);
return ioctl(filp, cmd, arg);
case SENSORIOCSQUEUEDEPTH: {
/* lower bound is mandatory, upper bound is a sanity check */
@@ -1101,7 +1101,7 @@ GYROSIM::gyro_ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long ar
default:
/* give it to the superclass */
return VDev::ioctl(handlep, cmd, arg);
return VDev::ioctl(filp, cmd, arg);
}
}
@@ -1578,21 +1578,21 @@ GYROSIM_gyro::parent_poll_notify()
}
ssize_t
GYROSIM_gyro::read(device::px4_dev_handle_t *handlep, char *buffer, size_t buflen)
GYROSIM_gyro::read(device::file_t *filp, char *buffer, size_t buflen)
{
return _parent->gyro_read(handlep, buffer, buflen);
return _parent->gyro_read(filp, buffer, buflen);
}
int
GYROSIM_gyro::ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg)
GYROSIM_gyro::ioctl(device::file_t *filp, int cmd, unsigned long arg)
{
switch (cmd) {
case DEVIOCGDEVICEID:
return (int)VDev::ioctl(handlep, cmd, arg);
return (int)VDev::ioctl(filp, cmd, arg);
break;
default:
return _parent->gyro_ioctl(handlep, cmd, arg);
return _parent->gyro_ioctl(filp, cmd, arg);
}
}
+23 -14
View File
@@ -46,24 +46,30 @@
#include <poll.h>
#include <semaphore.h>
#define PX4_F_RDONLY 1
#define PX4_F_WRONLY 2
#ifdef __PX4_NUTTX
typedef struct pollfd px4_pollfd_struct_t;
#if defined(__cplusplus)
#define _GLOBAL ::
#else
#define _GLOBAL
#endif
#define px4_open _GLOBAL open
#define px4_close _GLOBAL close
#define px4_ioctl _GLOBAL ioctl
#define px4_write _GLOBAL write
#define px4_read _GLOBAL read
#define px4_poll _GLOBAL poll
#elif defined(__PX4_POSIX)
#define PX4_F_RDONLY 1
#define PX4_F_WRONLY 2
#define PX4_DEBUG(...)
//#define PX4_DEBUG(...) printf(__VA_ARGS__)
#ifdef __PX4_NUTTX
#define px4_pollfd_struct_t struct pollfd
#define px4_open open
#define px4_close close
#define px4_ioctl ioctl
#define px4_write write
#define px4_read read
#define px4_poll poll
#else
typedef short pollevent_t;
typedef struct {
@@ -87,7 +93,10 @@ __EXPORT int px4_ioctl(int fd, int cmd, unsigned long arg);
__EXPORT int px4_poll(px4_pollfd_struct_t *fds, nfds_t nfds, int timeout);
__END_DECLS
#else
#error "No TARGET OS Provided"
#endif
__BEGIN_DECLS
extern int px4_errno;