mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 19:51:35 +08:00
Clean up the FMU communications init.
This commit is contained in:
+11
-1
@@ -47,6 +47,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
|
|
||||||
@@ -69,7 +70,7 @@ static struct px4io_report report;
|
|||||||
|
|
||||||
static void comms_handle_frame(void *arg, const void *buffer, size_t length);
|
static void comms_handle_frame(void *arg, const void *buffer, size_t length);
|
||||||
|
|
||||||
void
|
static void
|
||||||
comms_init(void)
|
comms_init(void)
|
||||||
{
|
{
|
||||||
/* initialise the FMU interface */
|
/* initialise the FMU interface */
|
||||||
@@ -78,11 +79,20 @@ comms_init(void)
|
|||||||
|
|
||||||
/* default state in the report to FMU */
|
/* default state in the report to FMU */
|
||||||
report.i2f_magic = I2F_MAGIC;
|
report.i2f_magic = I2F_MAGIC;
|
||||||
|
|
||||||
|
struct termios t;
|
||||||
|
|
||||||
|
/* 115200bps, no parity, one stop bit */
|
||||||
|
tcgetattr(fmu_fd, &t);
|
||||||
|
cfsetspeed(&t, 115200);
|
||||||
|
t.c_cflag &= ~(CSTOPB | PARENB);
|
||||||
|
tcsetattr(fmu_fd, TCSANOW, &t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
comms_main(void)
|
comms_main(void)
|
||||||
{
|
{
|
||||||
|
comms_init();
|
||||||
|
|
||||||
struct pollfd fds;
|
struct pollfd fds;
|
||||||
fds.fd = fmu_fd;
|
fds.fd = fmu_fd;
|
||||||
|
|||||||
+3
-7
@@ -76,6 +76,9 @@ int user_start(int argc, char *argv[])
|
|||||||
/* start the safety switch handler */
|
/* start the safety switch handler */
|
||||||
safety_init();
|
safety_init();
|
||||||
|
|
||||||
|
/* configure the first 8 PWM outputs (i.e. all of them) */
|
||||||
|
up_pwm_servo_init(0xff);
|
||||||
|
|
||||||
/* start the flight control signal handler */
|
/* start the flight control signal handler */
|
||||||
task_create("FCon",
|
task_create("FCon",
|
||||||
SCHED_PRIORITY_DEFAULT,
|
SCHED_PRIORITY_DEFAULT,
|
||||||
@@ -84,13 +87,6 @@ int user_start(int argc, char *argv[])
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
||||||
/* initialise the FMU communications interface */
|
|
||||||
comms_init();
|
|
||||||
|
|
||||||
/* configure the first 8 PWM outputs (i.e. all of them) */
|
|
||||||
/* note, must do this after comms init to steal back PA0, which is CTS otherwise */
|
|
||||||
up_pwm_servo_init(0xff);
|
|
||||||
|
|
||||||
struct mallinfo minfo = mallinfo();
|
struct mallinfo minfo = mallinfo();
|
||||||
lib_lowprintf("free %u largest %u\n", minfo.mxordblk, minfo.fordblks);
|
lib_lowprintf("free %u largest %u\n", minfo.mxordblk, minfo.fordblks);
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,6 @@ extern void safety_init(void);
|
|||||||
/*
|
/*
|
||||||
* FMU communications
|
* FMU communications
|
||||||
*/
|
*/
|
||||||
extern void comms_init(void);
|
|
||||||
extern void comms_main(void) __attribute__((noreturn));
|
extern void comms_main(void) __attribute__((noreturn));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user