mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-14 06:40:34 +08:00
Linux to posix conversion
Changed "linux" target to "posix". Most of the changes are shared with QuRT and with OSX. The Linux specific parts are in for i2c which uses <linux/i2c.h> and <linux/i2c-dev.h>. There is also a check for __PX4_LINUX in mavlink for a tty ioctl that is not supported. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -40,7 +40,7 @@ MODULE_COMMAND = blinkm
|
||||
ifeq ($(PX4_TARGET_OS),nuttx)
|
||||
SRCS = blinkm_nuttx.cpp
|
||||
else
|
||||
SRCS = blinkm_linux.cpp
|
||||
SRCS = blinkm_posix.cpp
|
||||
endif
|
||||
|
||||
MAXOPTIMIZATION = -Os
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#ifdef __PX4_NUTTX
|
||||
#include "device_nuttx.h"
|
||||
#elif defined (__PX4_LINUX)
|
||||
#elif defined (__PX4_POSIX)
|
||||
#include "vdev.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -35,5 +35,5 @@
|
||||
#ifdef __PX4_NUTTX
|
||||
#include "i2c_nuttx.h"
|
||||
#else
|
||||
#include "i2c_linux.h"
|
||||
#include "i2c_posix.h"
|
||||
#endif
|
||||
|
||||
@@ -41,8 +41,10 @@
|
||||
*/
|
||||
|
||||
#include "i2c.h"
|
||||
#ifdef __PX4_LINUX
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
@@ -43,8 +43,10 @@
|
||||
#include "vdev.h"
|
||||
|
||||
#include <px4_i2c.h>
|
||||
#ifdef __PX4_LINUX
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
#endif
|
||||
#include <string>
|
||||
|
||||
namespace device __EXPORT
|
||||
@@ -44,11 +44,11 @@ SRCS = \
|
||||
spi.cpp \
|
||||
ringbuffer.cpp
|
||||
endif
|
||||
ifeq ($(PX4_TARGET_OS),linux)
|
||||
ifeq ($(PX4_TARGET_OS),posix)
|
||||
SRCS = vdev.cpp \
|
||||
device.cpp \
|
||||
vdev_posix.cpp \
|
||||
i2c_linux.cpp \
|
||||
i2c_posix.cpp \
|
||||
sim.cpp \
|
||||
ringbuffer.cpp
|
||||
endif
|
||||
|
||||
@@ -114,14 +114,14 @@
|
||||
/* no GPIO driver on the PX4_STM32F4DISCOVERY board */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ARCH_BOARD_LINUXTEST
|
||||
/* no GPIO driver on the LINUXTEST board */
|
||||
#ifdef CONFIG_ARCH_BOARD_POSIXTEST
|
||||
/* no GPIO driver on the POSIXTEST board */
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_ARCH_BOARD_PX4IO_V1) && !defined(CONFIG_ARCH_BOARD_PX4IO_V2) && \
|
||||
!defined(CONFIG_ARCH_BOARD_PX4FMU_V1) && !defined(CONFIG_ARCH_BOARD_PX4FMU_V2) && \
|
||||
!defined(CONFIG_ARCH_BOARD_AEROCORE) && !defined(CONFIG_ARCH_BOARD_PX4_STM32F4DISCOVERY) && \
|
||||
!defined(CONFIG_ARCH_BOARD_LINUXTEST)
|
||||
!defined(CONFIG_ARCH_BOARD_POSIXTEST)
|
||||
# error No CONFIG_ARCH_BOARD_xxxx set
|
||||
#endif
|
||||
/*
|
||||
|
||||
@@ -41,6 +41,6 @@ ifeq ($(PX4_TARGET_OS),nuttx)
|
||||
SRCS = hil.cpp
|
||||
MAXOPTIMIZATION = -Os
|
||||
else
|
||||
SRCS = hil_linux.cpp
|
||||
SRCS = hil_posix.cpp
|
||||
endif
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ MODULE_COMMAND = ms5611
|
||||
ifeq ($(PX4_TARGET_OS),nuttx)
|
||||
SRCS = ms5611_nuttx.cpp ms5611_spi.cpp ms5611_i2c.cpp
|
||||
else
|
||||
SRCS = ms5611_linux.cpp ms5611_spi.cpp ms5611_i2c.cpp ms5611_sim.cpp
|
||||
SRCS = ms5611_posix.cpp ms5611_spi.cpp ms5611_i2c.cpp ms5611_sim.cpp
|
||||
endif
|
||||
|
||||
MAXOPTIMIZATION = -Os
|
||||
|
||||
@@ -7,7 +7,7 @@ MODULE_COMMAND = rgbled
|
||||
ifeq ($(PX4_TARGET_OS),nuttx)
|
||||
SRCS = rgbled.cpp
|
||||
else
|
||||
SRCS = rgbled_linux.cpp
|
||||
SRCS = rgbled_posix.cpp
|
||||
endif
|
||||
|
||||
MAXOPTIMIZATION = -Os
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
namespace math
|
||||
{
|
||||
|
||||
#if !defined(CONFIG_ARCH_ARM) && !defined(__PX4_LINUX)
|
||||
#if !defined(CONFIG_ARCH_ARM) && !defined(__PX4_POSIX)
|
||||
#define M_PI_F 3.14159265358979323846f
|
||||
#endif
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
#define HW_ARCH "PX4_STM32F4DISCOVERY"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ARCH_BOARD_LINUXTEST
|
||||
#ifdef CONFIG_ARCH_BOARD_POSIXTEST
|
||||
#define HW_ARCH "LINUXTEST"
|
||||
#endif
|
||||
#endif /* VERSION_H_ */
|
||||
|
||||
@@ -52,7 +52,7 @@ ifdef ($(PX4_TARGET_OS),nuttx)
|
||||
SRCS +=
|
||||
state_machine_helper.cpp
|
||||
else
|
||||
SRCS += state_machine_helper_linux.cpp
|
||||
SRCS += state_machine_helper_posix.cpp
|
||||
endif
|
||||
|
||||
MODULE_STACKSIZE = 5000
|
||||
|
||||
@@ -35,5 +35,5 @@
|
||||
#ifdef __PX4_NUTTX
|
||||
#include "mavlink_main_nuttx.h"
|
||||
#else
|
||||
#include "mavlink_main_linux.h"
|
||||
#include "mavlink_main_posix.h"
|
||||
#endif
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file mavlink_main_linux.h
|
||||
* @file mavlink_main_posix.h
|
||||
* MAVLink 1.0 protocol interface definition.
|
||||
*
|
||||
* @author Lorenz Meier <lm@inf.ethz.ch>
|
||||
@@ -41,7 +41,7 @@
|
||||
*/
|
||||
|
||||
/* XXX trim includes */
|
||||
#include <px4_config.h>
|
||||
#include <nuttx/config.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -42,7 +42,7 @@ SRCS = mavlink_tests.cpp \
|
||||
ifeq ($(PX4_TARGET_NUTTX),nuttx)
|
||||
SRCS += ../mavlink_ftp_nuttx.cpp
|
||||
else
|
||||
SRCS += ../mavlink_ftp_linux.cpp
|
||||
SRCS += ../mavlink_ftp_posix.cpp
|
||||
endif
|
||||
|
||||
INCLUDE_DIRS += $(MAVLINK_SRC)/include/mavlink
|
||||
|
||||
@@ -41,9 +41,9 @@ SRCS += mavlink_main_nuttx.cpp \
|
||||
mavlink_ftp_nuttx.cpp \
|
||||
mavlink_receiver_nuttx.cpp
|
||||
else
|
||||
SRCS += mavlink_main_linux.cpp \
|
||||
mavlink_ftp_linux.cpp \
|
||||
mavlink_receiver_linux.cpp
|
||||
SRCS += mavlink_main_posix.cpp \
|
||||
mavlink_ftp_posix.cpp \
|
||||
mavlink_receiver_posix.cpp
|
||||
endif
|
||||
|
||||
SRCS += mavlink.c \
|
||||
|
||||
@@ -41,7 +41,7 @@ MODULE_PRIORITY = "SCHED_PRIORITY_MAX-5"
|
||||
ifeq ($(PX$_TARGET_OS),nuttx)
|
||||
SRCS = sensors_nuttx.cpp
|
||||
else
|
||||
SRCS = sensors_linux.cpp
|
||||
SRCS = sensors_posix.cpp
|
||||
endif
|
||||
SRCS += sensor_params.c
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
* @author Anton Babushkin <anton@px4.io>
|
||||
*/
|
||||
|
||||
#include <px4_config.h>
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
|
||||
@@ -396,7 +396,7 @@ struct param_info_s {
|
||||
// See https://llvm.org/bugs/show_bug.cgi?format=multiple&id=18006
|
||||
// The following hack is for GCC >=4.8 only. Clang works fine without
|
||||
// this.
|
||||
#ifdef __PX4_LINUX
|
||||
#ifdef __PX4_POSIX
|
||||
__attribute__((aligned(16)));
|
||||
#else
|
||||
;
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
#
|
||||
|
||||
SRCS = \
|
||||
px4_linux_impl.cpp \
|
||||
px4_linux_tasks.cpp \
|
||||
px4_posix_impl.cpp \
|
||||
px4_posix_tasks.cpp \
|
||||
work_thread.c \
|
||||
work_queue.c \
|
||||
work_cancel.c \
|
||||
+1
-1
@@ -32,7 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file px4_linux_impl.cpp
|
||||
* @file px4_posix_impl.cpp
|
||||
*
|
||||
* PX4 Middleware Wrapper Linux Implementation
|
||||
*/
|
||||
+1
-1
@@ -33,7 +33,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file px4_linux_tasks.c
|
||||
* @file px4_posix_tasks.c
|
||||
* Implementation of existing task API for Linux
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
************************************************************************/
|
||||
|
||||
// FIXME - need px4_queue
|
||||
#include <platforms/linux/include/queue.h>
|
||||
#include <platforms/posix/include/queue.h>
|
||||
#include <stddef.h>
|
||||
|
||||
__EXPORT void sq_rem(sq_entry_t *node, sq_queue_t *queue);
|
||||
+1
-1
@@ -32,7 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file hello_start_linux.cpp
|
||||
* @file hello_start_posix.cpp
|
||||
*
|
||||
* @author Thomas Gubler <thomasgubler@gmail.com>
|
||||
* @author Mark Charlebois <mcharleb@gmail.com>
|
||||
+1
-1
@@ -38,6 +38,6 @@
|
||||
MODULE_COMMAND = hello
|
||||
|
||||
SRCS = hello_main.cpp \
|
||||
hello_start_linux.cpp \
|
||||
hello_start_posix.cpp \
|
||||
hello_example.cpp
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file hrt_test_start_linux.cpp
|
||||
* @file hrt_test_start_posix.cpp
|
||||
*
|
||||
* @author Mark Charlebois <mcharleb@gmail.com>
|
||||
*/
|
||||
+1
-1
@@ -38,6 +38,6 @@
|
||||
MODULE_COMMAND = hrttest
|
||||
|
||||
SRCS = hrt_test_main.cpp \
|
||||
hrt_test_start_linux.cpp \
|
||||
hrt_test_start_posix.cpp \
|
||||
hrt_test.cpp
|
||||
|
||||
+1
-1
@@ -38,6 +38,6 @@
|
||||
MODULE_COMMAND = vcdevtest
|
||||
|
||||
SRCS = vcdevtest_main.cpp \
|
||||
vcdevtest_start_linux.cpp \
|
||||
vcdevtest_start_posix.cpp \
|
||||
vcdevtest_example.cpp
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file vcdevtest_start_linux.cpp
|
||||
* @file vcdevtest_start_posix.cpp
|
||||
*
|
||||
* @author Thomas Gubler <thomasgubler@gmail.com>
|
||||
* @author Mark Charlebois <mcharleb@gmail.com>
|
||||
+1
-1
@@ -38,6 +38,6 @@
|
||||
MODULE_COMMAND = wqueue_test
|
||||
|
||||
SRCS = wqueue_main.cpp \
|
||||
wqueue_start_linux.cpp \
|
||||
wqueue_start_posix.cpp \
|
||||
wqueue_test.cpp
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file wqueue_start_linux.cpp
|
||||
* @file wqueue_start_posix.cpp
|
||||
*
|
||||
* @author Thomas Gubler <thomasgubler@gmail.com>
|
||||
* @author Mark Charlebois <mcharleb@gmail.com>
|
||||
@@ -48,7 +48,7 @@
|
||||
* Building for NuttX
|
||||
*/
|
||||
#include <nuttx/analog/adc.h>
|
||||
#elif defined(__PX4_LINUX)
|
||||
#elif defined(__PX4_POSIX)
|
||||
|
||||
// FIXME - this needs to be a px4_adc_msg_s type
|
||||
// Curently copied from NuttX
|
||||
|
||||
@@ -42,12 +42,12 @@
|
||||
|
||||
#if defined(__PX4_NUTTX)
|
||||
#include <px4_config.h>
|
||||
#elif defined (__PX4_LINUX) || defined (__PX4_QURT)
|
||||
#elif defined (__PX4_POSIX) || defined (__PX4_QURT)
|
||||
#define CONFIG_NFILE_STREAMS 1
|
||||
#define CONFIG_SCHED_WORKQUEUE 1
|
||||
#define CONFIG_SCHED_HPWORK 1
|
||||
#define CONFIG_SCHED_LPWORK 1
|
||||
#define CONFIG_ARCH_BOARD_LINUXTEST 1
|
||||
#define CONFIG_ARCH_BOARD_POSIXTEST 1
|
||||
|
||||
/** time in ms between checks for work in work queues **/
|
||||
#define CONFIG_SCHED_WORKPERIOD 10
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
/* Get value of parameter by name, which is equal to the handle for ros */
|
||||
#define PX4_PARAM_GET_BYNAME(_name, _destpt) ros::param::get(_name, *_destpt)
|
||||
|
||||
#elif defined(__PX4_NUTTX) || defined(__PX4_LINUX) || defined(__PX4_QURT)
|
||||
#elif defined(__PX4_NUTTX) || defined(__PX4_POSIX) || defined(__PX4_QURT)
|
||||
/*
|
||||
* Building for NuttX or Linux
|
||||
*/
|
||||
@@ -107,7 +107,7 @@ typedef param_t px4_param_t;
|
||||
#define PX4_ISFINITE(x) isfinite(x)
|
||||
|
||||
/* Linux Specific defines */
|
||||
#elif defined(__PX4_LINUX)
|
||||
#elif defined(__PX4_POSIX)
|
||||
|
||||
// Flag is meaningless on Linux
|
||||
#define O_BINARY 0
|
||||
@@ -134,7 +134,7 @@ __END_DECLS
|
||||
|
||||
|
||||
/* Defines for ROS and Linux */
|
||||
#if defined(__PX4_ROS) || defined(__PX4_LINUX) || defined(__PX4_QURT)
|
||||
#if defined(__PX4_ROS) || defined(__PX4_POSIX) || defined(__PX4_QURT)
|
||||
#define OK 0
|
||||
#define ERROR -1
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ typedef struct i2c_dev_s px4_i2c_dev_t;
|
||||
|
||||
#define px4_interrupt_context() up_interrupt_context()
|
||||
|
||||
#elif defined(__PX4_LINUX)
|
||||
#elif defined(__PX4_POSIX)
|
||||
#include <stdint.h>
|
||||
|
||||
#define I2C_M_READ 0x0001 /* read data, from slave to master */
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
#include <systemlib/param/param.h>
|
||||
#include <systemlib/systemlib.h>
|
||||
|
||||
#elif defined(__PX4_LINUX)
|
||||
#elif defined(__PX4_POSIX)
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <uORB/uORB.h>
|
||||
@@ -110,24 +110,24 @@
|
||||
#define ASSERT(x) assert(x)
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <platforms/linux/px4_messages/px4_rc_channels.h>
|
||||
#include <platforms/linux/px4_messages/px4_vehicle_attitude_setpoint.h>
|
||||
#include <platforms/linux/px4_messages/px4_manual_control_setpoint.h>
|
||||
#include <platforms/linux/px4_messages/px4_actuator_controls.h>
|
||||
#include <platforms/linux/px4_messages/px4_actuator_controls_0.h>
|
||||
#include <platforms/linux/px4_messages/px4_actuator_controls_1.h>
|
||||
#include <platforms/linux/px4_messages/px4_actuator_controls_2.h>
|
||||
#include <platforms/linux/px4_messages/px4_actuator_controls_3.h>
|
||||
#include <platforms/linux/px4_messages/px4_vehicle_rates_setpoint.h>
|
||||
#include <platforms/linux/px4_messages/px4_vehicle_attitude.h>
|
||||
#include <platforms/linux/px4_messages/px4_vehicle_control_mode.h>
|
||||
#include <platforms/linux/px4_messages/px4_actuator_armed.h>
|
||||
#include <platforms/linux/px4_messages/px4_parameter_update.h>
|
||||
#include <platforms/linux/px4_messages/px4_vehicle_status.h>
|
||||
#include <platforms/linux/px4_messages/px4_vehicle_local_position_setpoint.h>
|
||||
#include <platforms/linux/px4_messages/px4_vehicle_global_velocity_setpoint.h>
|
||||
#include <platforms/linux/px4_messages/px4_vehicle_local_position.h>
|
||||
#include <platforms/linux/px4_messages/px4_position_setpoint_triplet.h>
|
||||
#include <platforms/posix/px4_messages/px4_rc_channels.h>
|
||||
#include <platforms/posix/px4_messages/px4_vehicle_attitude_setpoint.h>
|
||||
#include <platforms/posix/px4_messages/px4_manual_control_setpoint.h>
|
||||
#include <platforms/posix/px4_messages/px4_actuator_controls.h>
|
||||
#include <platforms/posix/px4_messages/px4_actuator_controls_0.h>
|
||||
#include <platforms/posix/px4_messages/px4_actuator_controls_1.h>
|
||||
#include <platforms/posix/px4_messages/px4_actuator_controls_2.h>
|
||||
#include <platforms/posix/px4_messages/px4_actuator_controls_3.h>
|
||||
#include <platforms/posix/px4_messages/px4_vehicle_rates_setpoint.h>
|
||||
#include <platforms/posix/px4_messages/px4_vehicle_attitude.h>
|
||||
#include <platforms/posix/px4_messages/px4_vehicle_control_mode.h>
|
||||
#include <platforms/posix/px4_messages/px4_actuator_armed.h>
|
||||
#include <platforms/posix/px4_messages/px4_parameter_update.h>
|
||||
#include <platforms/posix/px4_messages/px4_vehicle_status.h>
|
||||
#include <platforms/posix/px4_messages/px4_vehicle_local_position_setpoint.h>
|
||||
#include <platforms/posix/px4_messages/px4_vehicle_global_velocity_setpoint.h>
|
||||
#include <platforms/posix/px4_messages/px4_vehicle_local_position.h>
|
||||
#include <platforms/posix/px4_messages/px4_position_setpoint_triplet.h>
|
||||
#endif
|
||||
#include <systemlib/err.h>
|
||||
#include <systemlib/param/param.h>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#ifdef __PX4_NUTTX
|
||||
#include <nuttx/spi.h>
|
||||
#elif defined(__PX4_LINUX)
|
||||
#elif defined(__PX4_POSIX)
|
||||
enum spi_dev_e
|
||||
{
|
||||
SPIDEV_NONE = 0, /* Not a valid value */
|
||||
|
||||
@@ -49,7 +49,7 @@ typedef int px4_task_t;
|
||||
|
||||
#define px4_task_exit(x) _exit(x)
|
||||
|
||||
#elif defined(__PX4_LINUX) || defined(__PX4_QURT)
|
||||
#elif defined(__PX4_POSIX) || defined(__PX4_QURT)
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/clock.h>
|
||||
#elif defined(__PX4_LINUX) || defined(__PX4_QURT)
|
||||
#elif defined(__PX4_POSIX) || defined(__PX4_QURT)
|
||||
|
||||
#include <stdint.h>
|
||||
#include <queue.h>
|
||||
|
||||
@@ -38,6 +38,6 @@
|
||||
MODULE_COMMAND = hello
|
||||
|
||||
SRCS = hello_main.cpp \
|
||||
hello_start_linux.cpp \
|
||||
hello_start_qurt.cpp \
|
||||
hello_example.cpp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user