forked from Archive/PX4-Autopilot
rc_input: add RC_PORT_CONFIG param to configure RC port
The parameter will only be available if the board defines an 'RC' serial port in SERIAL_PORTS (in default.cmake).
This commit is contained in:
parent
b7a0e1ef03
commit
5fe4c61b42
|
@ -52,6 +52,7 @@ set PWM_MAX p:PWM_MAX
|
|||
set PWM_MIN p:PWM_MIN
|
||||
set PWM_OUT none
|
||||
set PWM_RATE p:PWM_RATE
|
||||
set RC_INPUT_ARGS ""
|
||||
set SDCARD_MIXERS_PATH /fs/microsd/etc/mixers
|
||||
set USE_IO no
|
||||
set VEHICLE_TYPE none
|
||||
|
@ -318,11 +319,6 @@ else
|
|||
tune_control play -t 2
|
||||
fi
|
||||
|
||||
if [ $IO_PRESENT = no -o $USE_IO = no ]
|
||||
then
|
||||
rc_input start
|
||||
fi
|
||||
|
||||
#
|
||||
# Sensors System (start before Commander so Preflight checks are properly run).
|
||||
# Commander needs to be this early for in-air-restarts.
|
||||
|
@ -418,6 +414,12 @@ else
|
|||
#
|
||||
sh /etc/init.d/rc.serial
|
||||
|
||||
if [ $IO_PRESENT = no -o $USE_IO = no ]
|
||||
then
|
||||
# Must be started after the serial config is read
|
||||
rc_input start $RC_INPUT_ARGS
|
||||
fi
|
||||
|
||||
#
|
||||
# Configure vehicle type specific parameters.
|
||||
# Note: rc.vehicle_setup is the entry point for rc.interface,
|
||||
|
@ -546,6 +548,7 @@ unset PWM_MAX
|
|||
unset PWM_MIN
|
||||
unset PWM_OUT
|
||||
unset PWM_RATE
|
||||
unset RC_INPUT_ARGS
|
||||
unset SDCARD_MIXERS_PATH
|
||||
unset USE_IO
|
||||
unset VEHICLE_TYPE
|
||||
|
|
|
@ -108,6 +108,13 @@ serial_ports = {
|
|||
"default_baudrate": 0,
|
||||
},
|
||||
|
||||
# RC Port
|
||||
"RC": {
|
||||
"label": "Radio Controller",
|
||||
"index": 300,
|
||||
"default_baudrate": 0,
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
parser = argparse.ArgumentParser(description='Generate Serial params & startup script')
|
||||
|
@ -280,6 +287,15 @@ for serial_command in serial_commands:
|
|||
for i in range(num_instances):
|
||||
port_config = serial_command['port_config_param']
|
||||
port_param_name = port_config['name'].replace('${i}', str(i))
|
||||
|
||||
# check if a port dependency is specified
|
||||
if 'depends_on_port' in port_config:
|
||||
depends_on_port = port_config['depends_on_port']
|
||||
if not any(p['tag'] == depends_on_port for p in serial_devices):
|
||||
if verbose:
|
||||
print("Skipping {:} (missing dependent port)".format(port_param_name))
|
||||
continue
|
||||
|
||||
default_port = 0 # disabled
|
||||
if 'default' in port_config:
|
||||
if type(port_config['default']) == list:
|
||||
|
@ -299,7 +315,8 @@ for serial_command in serial_commands:
|
|||
'multi_instance': num_instances > 1,
|
||||
'port_param_name': port_param_name,
|
||||
'default_port': default_port,
|
||||
'param_group': port_config['group']
|
||||
'param_group': port_config['group'],
|
||||
'description_extended': port_config.get('description_extended', '')
|
||||
})
|
||||
|
||||
if verbose:
|
||||
|
|
|
@ -52,6 +52,8 @@ PARAM_DEFINE_INT32(SER_{{ serial_device.tag }}_BAUD, {{ serial_device.default_ba
|
|||
*
|
||||
* Configure on which serial port to run {{ command.label }}.
|
||||
*
|
||||
* {{ command.description_extended | replace("\n", " ") }}
|
||||
*
|
||||
* @value 0 Disabled
|
||||
{% for serial_device in serial_devices -%}
|
||||
* @value {{ serial_device.index }} {{ serial_device.label }}
|
||||
|
|
|
@ -38,6 +38,8 @@ px4_add_module(
|
|||
SRCS
|
||||
RCInput.cpp
|
||||
crsf_telemetry.cpp
|
||||
MODULE_CONFIG
|
||||
module.yaml
|
||||
DEPENDS
|
||||
rc
|
||||
)
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
module_name: RC Input Driver
|
||||
serial_config:
|
||||
- command: set RC_INPUT_ARGS "-d ${SERIAL_DEV}"
|
||||
port_config_param:
|
||||
name: RC_PORT_CONFIG
|
||||
group: Serial
|
||||
default: RC
|
||||
depends_on_port: RC
|
||||
description_extended: |
|
||||
Setting this to 'Disabled' will use a board-specific default port
|
||||
for RC input.
|
||||
|
|
@ -54,6 +54,15 @@ serial_config:
|
|||
minlength: 1
|
||||
schema:
|
||||
type: string
|
||||
depends_on_port:
|
||||
# Optional serial tag dependency (e.g. GPS1). If a board
|
||||
# does not specify this serial port, the parameter will
|
||||
# not be included in the build (i.e. it's not
|
||||
# configurable)
|
||||
type: string
|
||||
description_extended:
|
||||
# Optional extended description
|
||||
type: string
|
||||
label:
|
||||
# Optional command label (e.g. used in the autostart script).
|
||||
# If omitted, module_name is used.
|
||||
|
|
Loading…
Reference in New Issue