mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
drivers/rc_input: always provide RC_PORT_CONFIG parameter
- RC_PORT_CONFIG is disabled by default if the board doesn't have CONFIG_BOARD_SERIAL_RC set - allows user facing custom RC configuration that overrides board defaults
This commit is contained in:
@@ -268,10 +268,14 @@ for serial_command in serial_commands:
|
|||||||
default_port_str = port_config['default'][i]
|
default_port_str = port_config['default'][i]
|
||||||
else:
|
else:
|
||||||
default_port_str = port_config['default']
|
default_port_str = port_config['default']
|
||||||
|
|
||||||
if default_port_str != "":
|
if default_port_str != "":
|
||||||
if default_port_str not in serial_ports:
|
if default_port_str not in serial_ports:
|
||||||
raise Exception("Default Port {:} not found for {:}".format(default_port_str, serial_command['label']))
|
raise Exception("Default Port {:} not found for {:}".format(default_port_str, serial_command['label']))
|
||||||
default_port = serial_ports[default_port_str]['index']
|
|
||||||
|
if default_port_str in dict(board_ports).keys():
|
||||||
|
default_port = serial_ports[default_port_str]['index']
|
||||||
|
|
||||||
|
|
||||||
commands.append({
|
commands.append({
|
||||||
'command': serial_command['command'],
|
'command': serial_command['command'],
|
||||||
|
|||||||
@@ -123,15 +123,15 @@ RCInput::task_spawn(int argc, char *argv[])
|
|||||||
int myoptind = 1;
|
int myoptind = 1;
|
||||||
int ch;
|
int ch;
|
||||||
const char *myoptarg = nullptr;
|
const char *myoptarg = nullptr;
|
||||||
const char *device = nullptr;
|
const char *device_name = nullptr;
|
||||||
#if defined(RC_SERIAL_PORT)
|
#if defined(RC_SERIAL_PORT)
|
||||||
device = RC_SERIAL_PORT;
|
device_name = RC_SERIAL_PORT;
|
||||||
#endif // RC_SERIAL_PORT
|
#endif // RC_SERIAL_PORT
|
||||||
|
|
||||||
while ((ch = px4_getopt(argc, argv, "d:", &myoptind, &myoptarg)) != EOF) {
|
while ((ch = px4_getopt(argc, argv, "d:", &myoptind, &myoptarg)) != EOF) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'd':
|
case 'd':
|
||||||
device = myoptarg;
|
device_name = myoptarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
@@ -149,24 +149,31 @@ RCInput::task_spawn(int argc, char *argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device == nullptr) {
|
if (device_name && (access(device_name, R_OK | W_OK) == 0)) {
|
||||||
PX4_ERR("valid device required");
|
RCInput *instance = new RCInput(device_name);
|
||||||
return PX4_ERROR;
|
|
||||||
|
if (instance == nullptr) {
|
||||||
|
PX4_ERR("alloc failed");
|
||||||
|
return PX4_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
_object.store(instance);
|
||||||
|
_task_id = task_id_is_work_queue;
|
||||||
|
|
||||||
|
instance->ScheduleOnInterval(_current_update_interval);
|
||||||
|
|
||||||
|
return PX4_OK;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (device_name) {
|
||||||
|
PX4_ERR("invalid device (-d) %s", device_name);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
PX4_INFO("valid device required");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RCInput *instance = new RCInput(device);
|
return PX4_ERROR;
|
||||||
|
|
||||||
if (instance == nullptr) {
|
|
||||||
PX4_ERR("alloc failed");
|
|
||||||
return PX4_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
_object.store(instance);
|
|
||||||
_task_id = task_id_is_work_queue;
|
|
||||||
|
|
||||||
instance->ScheduleOnInterval(_current_update_interval);
|
|
||||||
|
|
||||||
return PX4_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ serial_config:
|
|||||||
name: RC_PORT_CONFIG
|
name: RC_PORT_CONFIG
|
||||||
group: Serial
|
group: Serial
|
||||||
default: RC
|
default: RC
|
||||||
depends_on_port: RC
|
|
||||||
description_extended: |
|
description_extended: |
|
||||||
Setting this to 'Disabled' will use a board-specific default port
|
Setting this to 'Disabled' will use a board-specific default port
|
||||||
for RC input.
|
for RC input.
|
||||||
|
|||||||
Reference in New Issue
Block a user