资源简介
自定义uart的数据并发送到pixhawk,pixhawk能够传到qgc上
代码片段和文件信息
/*
* read_uart_sensor.c
*
* read sensor through uart
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
// #include
#include
#include nk_log.h>
#include
#include
__EXPORT int read_uart_sensor_main(int argc char *argv[]);
static bool thread_should_exit = false; /*Ddemon exit flag*/
static bool thread_running = false; /*Daemon status flag*/
static int daemon_task;
struct uart_pos_s uart_data;
orb_advert_t mavlink_uart_pub ;
orb_advert_t uart_pub;
/**
* Main loop
*/
int read_uart_thread_main(int argc char *argv[]);
int read_uart(char data);
static int uart_init(const char * uart_name);
static int set_uart_baudrate(const int fd unsigned int baud);
static void usage(const char *reason);
int set_uart_baudrate(const int fd unsigned int baud)
{
int speed;
switch (baud) {
case 9600: speed = B9600; break;
case 19200: speed = B19200; break;
case 38400: speed = B38400; break;
case 57600: speed = B57600; break;
case 115200: speed = B115200; break;
default:
warnx(“ERR: baudrate: %d\n“ baud);
return -EINVAL;
}
struct termios uart_config;
int termios_state;
/* fill the struct for the new configuration */
tcgetattr(fd &uart_config);
/* clear ONLCR flag (which appends a CR for every LF) */
uart_config.c_oflag &= ~ONLCR;
/* no parity one stop bit */
uart_config.c_cflag &= ~(CSTOPB | PARENB);
/* set baud rate */
if ((termios_state = cfsetispeed(&uart_config speed)) < 0) {
warnx(“ERR: %d (cfsetispeed)\n“ termios_state);
return false;
}
if ((termios_state = cfsetospeed(&uart_config speed)) < 0) {
warnx(“ERR: %d (cfsetospeed)\n“ termios_state);
return false;
}
if ((termios_state = tcsetattr(fd TCSANOW &uart_config)) < 0) {
warnx(“ERR: %d (tcsetattr)\n“ termios_state);
return false;
}
return true;
}
int uart_init(const char * uart_name)
{
int serial_fd = open(uart_name O_RDWR | O_NOCTTY);
if (serial_fd < 0) {
err(1 “failed to open port: %s“ uart_name);
return false;
}
return serial_fd;
}
static void usage(const char *reason)
{
if (reason) {
fprintf(stderr “%s\n“ reason);
}
fprintf(stderr “usage: read_uart_sensor {start|stop|status} [param]\n\n“);
exit(1);
}
int read_uart_sensor_main(int argc char *argv[])
{
if (argc < 2) {
usage(“missing command“);
}
if (!strcmp(argv[1] “start“)) {
if (thread_running) {
warnx(“already running\n“);
return 0;
}
thread_should_exit = false;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-03-19 11:57 uart\
文件 3493 2018-03-19 11:22 uart\nuttx_px4fmu-v2_default.cmake
文件 276 2018-03-19 11:15 uart\uart_pos.msg
目录 0 2018-03-19 11:21 uart\read_uart\
文件 1920 2018-03-19 11:21 uart\read_uart\CMakeLists.txt
文件 5657 2018-03-19 11:45 uart\read_uart\read_uart.c
相关资源
- 基于VHDL的交通灯已在quartus2 9.0下仿真
- 8位总线画法ALU 用Quartus II 软件绘制
- 已知最全 Quartus IP核license
- UART 做文件传输采用 Xmodem协议
- USB转串口驱动源代码及单片机程序
- Quartus_II_11.0_x64破解器(内部版).zi
- QuartusII 9.0全版本破解含64位破解文件
- Quartus_18.1链接和破解器.rar
- Quartz2.x官方文档中文版.chm
- QuartusII_13.0_Windows6432.zip
- springboot 集成quartz
- quartusⅡ的基本使用方法组成原理实验
-
Quartus17.1_Model10.5_Crack_Downloadli
nk.tx - ca码生成(verilog)
- D和JK触发器的Verilog程序Quartus II工程,
- zw_quartus9.064位完美破解.zip
- zw_quartz定时任务.zip
- 基于FPGA的UART通信接口电路设计
- FT232 FT230X驱动USB-UART驱动
- quartz各种数据库的建表语句
- Altera开发工具Quartus软件万能License
- quartusii9.1的破解器 找了很久终于找到
- Crack_Quartus_Prime_Standard_Pro_16.1
- QuartusII13.1破解,亲测可用
- quartus ii 13.0(64位)破解器
- quartus ii 13.0软件及devices地址
- 自开发实现Quartz Web管理工具
- SpringBoot集成Quartz分布式定时任务
- verilog —串口通信 包括仿真
- 新唐NUC970 UART转以太网开发板硬件资料
评论
共有 条评论