mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-25 16:56:25 +08:00
detect px4io conflicts, don't set sbus as default
This commit is contained in:
committed by
Silvan Fuhrer
parent
2ecc7226e6
commit
c0d1717897
@@ -264,8 +264,10 @@
|
||||
*/
|
||||
#if defined(CONFIG_BOARD_SERIAL_RC)
|
||||
# define RC_SERIAL CONFIG_BOARD_SERIAL_RC
|
||||
#else
|
||||
#elif defined(RC_SERIAL_PORT)
|
||||
# define RC_SERIAL RC_SERIAL_PORT
|
||||
#else
|
||||
# error Board needs to define either CONFIG_BOARD_SERIAL_RC or RC_SERIAL_PORT
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -511,6 +513,35 @@ static inline bool board_rc_swap_rxtx(const char *device) { return strcmp(device
|
||||
static inline bool board_rc_swap_rxtx(const char *device) { return false; }
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: board_rc_conflicting
|
||||
*
|
||||
* Description:
|
||||
* A board may define its serial RC to be the same as PX4IO_SERIAL_DEVICE,
|
||||
* especially when using PX4IO.
|
||||
*
|
||||
* This is problematic when trying to open the serial device used for PX4IO
|
||||
* for RC.
|
||||
*
|
||||
* Input Parameters:
|
||||
* device: serial device, e.g. "/dev/ttyS0"
|
||||
*
|
||||
* Returned Value:
|
||||
* true if the given serial device does conflict with the PX4IO.
|
||||
* false if not.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#if defined(RC_SERIAL) && defined(PX4IO_SERIAL_DEVICE)
|
||||
static inline bool board_rc_conflicting(const char *device)
|
||||
{
|
||||
return strcmp(device, RC_SERIAL) == 0 && strcmp(RC_SERIAL, PX4IO_SERIAL_DEVICE) == 0
|
||||
&& (access("/dev/px4io", R_OK) == 0);
|
||||
}
|
||||
#else
|
||||
static inline bool board_rc_conflicting(const char *device) { return false; }
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: board_rc_invert_input
|
||||
*
|
||||
|
||||
@@ -97,6 +97,11 @@ int CrsfRc::task_spawn(int argc, char *argv[])
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
if (board_rc_conflicting(device_name)) {
|
||||
PX4_INFO("unable to start, conflict with PX4IO on %s", device_name);
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
CrsfRc *instance = new CrsfRc(device_name);
|
||||
|
||||
if (instance == nullptr) {
|
||||
|
||||
@@ -93,6 +93,11 @@ int DsmRc::task_spawn(int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (board_rc_conflicting(device_name)) {
|
||||
PX4_INFO("unable to start, conflict with PX4IO on %s", device_name);
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
if (device_name && (access(device_name, R_OK | W_OK) == 0)) {
|
||||
DsmRc *instance = new DsmRc(device_name);
|
||||
|
||||
|
||||
@@ -88,6 +88,11 @@ int GhstRc::task_spawn(int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (board_rc_conflicting(device_name)) {
|
||||
PX4_INFO("unable to start, conflict with PX4IO on %s", device_name);
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
if (device_name && (access(device_name, R_OK | W_OK) == 0)) {
|
||||
GhstRc *instance = new GhstRc(device_name);
|
||||
|
||||
|
||||
@@ -85,6 +85,11 @@ int SbusRc::task_spawn(int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (board_rc_conflicting(device_name)) {
|
||||
PX4_INFO("unable to start, conflict with PX4IO on %s", device_name);
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
if (device_name && (access(device_name, R_OK | W_OK) == 0)) {
|
||||
SbusRc *instance = new SbusRc(device_name);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ serial_config:
|
||||
port_config_param:
|
||||
name: RC_SBUS_PRT_CFG
|
||||
group: Serial
|
||||
default: RC
|
||||
#default: RC
|
||||
#depends_on_port: RC
|
||||
description_extended: |
|
||||
SBUS RC driver.
|
||||
|
||||
Reference in New Issue
Block a user