mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 18:37:27 +08:00
Snapdragon: rename uart_esc to pwm_out_rc_in
The name uart_esc was initially taken by Qualcomm's UART ESC driver but then got changed into the current mavlink ESC/RC helper. Since the uart_esc is still around, we should prevent the names clashing.
This commit is contained in:
@@ -64,7 +64,7 @@ set(config_module_list
|
|||||||
# PX4 drivers
|
# PX4 drivers
|
||||||
#
|
#
|
||||||
drivers/gps
|
drivers/gps
|
||||||
drivers/uart_esc
|
drivers/pwm_out_rc_in
|
||||||
drivers/qshell/qurt
|
drivers/qshell/qurt
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ set(config_module_list
|
|||||||
# PX4 drivers
|
# PX4 drivers
|
||||||
#
|
#
|
||||||
drivers/gps
|
drivers/gps
|
||||||
drivers/uart_esc
|
drivers/pwm_out_rc_in
|
||||||
drivers/qshell/qurt
|
drivers/qshell/qurt
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ ekf2 start
|
|||||||
land_detector start multicopter
|
land_detector start multicopter
|
||||||
mc_pos_control start
|
mc_pos_control start
|
||||||
mc_att_control start
|
mc_att_control start
|
||||||
uart_esc start -d /dev/tty-2
|
pwm_out_rc_in start -d /dev/tty-2
|
||||||
sleep 1
|
sleep 1
|
||||||
list_devices
|
list_devices
|
||||||
list_files
|
list_files
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015 PX4 Development Team. All rights reserved.
|
# Copyright (c) 2015-2016 PX4 Development Team. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@@ -31,12 +31,12 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
px4_add_module(
|
px4_add_module(
|
||||||
MODULE drivers__uart_esc
|
MODULE drivers__pwm_out_rc_in
|
||||||
MAIN uart_esc
|
MAIN pwm_out_rc_in
|
||||||
COMPILE_FLAGS
|
COMPILE_FLAGS
|
||||||
-Os
|
-Os
|
||||||
SRCS
|
SRCS
|
||||||
uart_esc.cpp
|
pwm_out_rc_in.cpp
|
||||||
DEPENDS
|
DEPENDS
|
||||||
platforms__common
|
platforms__common
|
||||||
)
|
)
|
||||||
@@ -56,15 +56,20 @@
|
|||||||
#include <v1.0/common/mavlink.h>
|
#include <v1.0/common/mavlink.h>
|
||||||
|
|
||||||
|
|
||||||
namespace uart_esc
|
/*
|
||||||
|
* This driver is supposed to run on Snapdragon. It sends actuator_controls (PWM)
|
||||||
|
* to a Pixhawk/Pixfalcon/Pixracer over UART (mavlink) and receives RC input.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pwm_out_rc_in
|
||||||
{
|
{
|
||||||
|
|
||||||
static const uint8_t mavlink_message_lengths[256] = MAVLINK_MESSAGE_LENGTHS;
|
static const uint8_t mavlink_message_lengths[256] = MAVLINK_MESSAGE_LENGTHS;
|
||||||
static const uint8_t mavlink_message_crcs[256] = MAVLINK_MESSAGE_CRCS;
|
static const uint8_t mavlink_message_crcs[256] = MAVLINK_MESSAGE_CRCS;
|
||||||
|
|
||||||
volatile bool _task_should_exit = false; // flag indicating if uart_esc task should exit
|
volatile bool _task_should_exit = false; // flag indicating if pwm_out_rc_in task should exit
|
||||||
static char _device[32] = {};
|
static char _device[32] = {};
|
||||||
static bool _is_running = false; // flag indicating if uart_esc app is running
|
static bool _is_running = false; // flag indicating if pwm_out_rc_in app is running
|
||||||
static px4_task_t _task_handle = -1; // handle to the task main thread
|
static px4_task_t _task_handle = -1; // handle to the task main thread
|
||||||
|
|
||||||
// subscriptions
|
// subscriptions
|
||||||
@@ -473,7 +478,7 @@ void start()
|
|||||||
_task_should_exit = false;
|
_task_should_exit = false;
|
||||||
|
|
||||||
/* start the task */
|
/* start the task */
|
||||||
_task_handle = px4_task_spawn_cmd("uart_esc_main",
|
_task_handle = px4_task_spawn_cmd("pwm_out_rc_in_main",
|
||||||
SCHED_DEFAULT,
|
SCHED_DEFAULT,
|
||||||
SCHED_PRIORITY_MAX,
|
SCHED_PRIORITY_MAX,
|
||||||
1500,
|
1500,
|
||||||
@@ -501,17 +506,17 @@ void stop()
|
|||||||
|
|
||||||
void usage()
|
void usage()
|
||||||
{
|
{
|
||||||
PX4_INFO("usage: uart_esc start -d /dev/tty-3");
|
PX4_INFO("usage: pwm_out_rc_in start -d /dev/tty-3");
|
||||||
PX4_INFO(" uart_esc stop");
|
PX4_INFO(" pwm_out_rc_in stop");
|
||||||
PX4_INFO(" uart_esc status");
|
PX4_INFO(" pwm_out_rc_in status");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace uart_esc
|
} // namespace pwm_out_rc_in
|
||||||
|
|
||||||
/* driver 'main' command */
|
/* driver 'main' command */
|
||||||
extern "C" __EXPORT int uart_esc_main(int argc, char *argv[]);
|
extern "C" __EXPORT int pwm_out_rc_in_main(int argc, char *argv[]);
|
||||||
|
|
||||||
int uart_esc_main(int argc, char *argv[])
|
int pwm_out_rc_in_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const char *device = nullptr;
|
const char *device = nullptr;
|
||||||
int ch;
|
int ch;
|
||||||
@@ -528,49 +533,49 @@ int uart_esc_main(int argc, char *argv[])
|
|||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'd':
|
case 'd':
|
||||||
device = myoptarg;
|
device = myoptarg;
|
||||||
strncpy(uart_esc::_device, device, strlen(device));
|
strncpy(pwm_out_rc_in::_device, device, strlen(device));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// gets the parameters for the esc's pwm
|
// gets the parameters for the esc's pwm
|
||||||
param_get(param_find("PWM_DISARMED"), &uart_esc::_pwm_disarmed);
|
param_get(param_find("PWM_DISARMED"), &pwm_out_rc_in::_pwm_disarmed);
|
||||||
param_get(param_find("PWM_MIN"), &uart_esc::_pwm_min);
|
param_get(param_find("PWM_MIN"), &pwm_out_rc_in::_pwm_min);
|
||||||
param_get(param_find("PWM_MAX"), &uart_esc::_pwm_max);
|
param_get(param_find("PWM_MAX"), &pwm_out_rc_in::_pwm_max);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start/load the driver.
|
* Start/load the driver.
|
||||||
*/
|
*/
|
||||||
if (!strcmp(verb, "start")) {
|
if (!strcmp(verb, "start")) {
|
||||||
if (uart_esc::_is_running) {
|
if (pwm_out_rc_in::_is_running) {
|
||||||
PX4_WARN("uart_esc already running");
|
PX4_WARN("pwm_out_rc_in already running");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check on required arguments
|
// Check on required arguments
|
||||||
if (device == nullptr || strlen(device) == 0) {
|
if (device == nullptr || strlen(device) == 0) {
|
||||||
uart_esc::usage();
|
pwm_out_rc_in::usage();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uart_esc::start();
|
pwm_out_rc_in::start();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strcmp(verb, "stop")) {
|
else if (!strcmp(verb, "stop")) {
|
||||||
if (!uart_esc::_is_running) {
|
if (!pwm_out_rc_in::_is_running) {
|
||||||
PX4_WARN("uart_esc is not running");
|
PX4_WARN("pwm_out_rc_in is not running");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uart_esc::stop();
|
pwm_out_rc_in::stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strcmp(verb, "status")) {
|
else if (!strcmp(verb, "status")) {
|
||||||
PX4_WARN("uart_esc is %s", uart_esc::_is_running ? "running" : "not running");
|
PX4_WARN("pwm_out_rc_in is %s", pwm_out_rc_in::_is_running ? "running" : "not running");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
uart_esc::usage();
|
pwm_out_rc_in::usage();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user