mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 05:53:33 +08:00
updated to use rc driver from PX4, instead of from FC addons (#7798)
* updated to use rc driver from PX4, instead of from FC addons * fixed format * update per comments * fix format * fix format * remove duplicated __PX4_QURT
This commit is contained in:
committed by
ChristophTobler
parent
8f1355c325
commit
0ae76aff32
@@ -41,6 +41,7 @@
|
||||
|
||||
#include <px4_tasks.h>
|
||||
#include <px4_posix.h>
|
||||
#include <px4_getopt.h>
|
||||
|
||||
#include <lib/rc/dsm.h>
|
||||
#include <drivers/drv_rc_input.h>
|
||||
@@ -76,7 +77,23 @@ void fill_input_rc(uint16_t raw_rc_count, uint16_t raw_rc_values[input_rc_s::RC_
|
||||
|
||||
void task_main(int argc, char *argv[])
|
||||
{
|
||||
int uart_fd = dsm_init(SPEKTRUM_UART_DEVICE_PATH);
|
||||
const char *device_path = SPEKTRUM_UART_DEVICE_PATH;
|
||||
int ch;
|
||||
int myoptind = 1;
|
||||
const char *myoptarg = NULL;
|
||||
|
||||
while ((ch = px4_getopt(argc, argv, "d:", &myoptind, &myoptarg)) != EOF) {
|
||||
switch (ch) {
|
||||
case 'd':
|
||||
device_path = myoptarg;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int uart_fd = dsm_init(device_path);
|
||||
|
||||
if (uart_fd < 1) {
|
||||
PX4_ERR("dsm init failed");
|
||||
@@ -190,7 +207,7 @@ void fill_input_rc(uint16_t raw_rc_count, uint16_t raw_rc_values[input_rc_s::RC_
|
||||
input_rc.rc_total_frame_count = 0;
|
||||
}
|
||||
|
||||
int start()
|
||||
int start(int argc, char *argv[])
|
||||
{
|
||||
if (_is_running) {
|
||||
PX4_WARN("already running");
|
||||
@@ -206,7 +223,7 @@ int start()
|
||||
SCHED_PRIORITY_DEFAULT,
|
||||
2000,
|
||||
(px4_main_t)&task_main,
|
||||
nullptr);
|
||||
(char *const *)argv);
|
||||
|
||||
if (_task_handle < 0) {
|
||||
PX4_ERR("task start failed");
|
||||
@@ -263,7 +280,7 @@ int spektrum_rc_main(int argc, char *argv[])
|
||||
|
||||
|
||||
if (!strcmp(verb, "start")) {
|
||||
return spektrum_rc::start();
|
||||
return spektrum_rc::start(argc - 1, argv + 1);
|
||||
}
|
||||
|
||||
else if (!strcmp(verb, "stop")) {
|
||||
|
||||
Reference in New Issue
Block a user