代码拉取完成,页面将自动刷新
/****************************************************************************
*
* Copyright (c) 2014 MAVlink Development Team. All rights reserved.
* Author: Trent Lukaczyk, <aerialhedgehog@gmail.com>
* Jaycee Lock, <jaycee.lock@gmail.com>
* Lorenz Meier, <lm@inf.ethz.ch>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/**
* @file serial_port.h
*
* @brief Serial interface definition
*
* Functions for opening, closing, reading and writing via serial ports
*
* @author Trent Lukaczyk, <aerialhedgehog@gmail.com>
* @author Jaycee Lock, <jaycee.lock@gmail.com>
* @author Lorenz Meier, <lm@inf.ethz.ch>
*
*/
#ifndef SERIAL_PORT_H_
#define SERIAL_PORT_H_
// ------------------------------------------------------------------------------
// Includes
// ------------------------------------------------------------------------------
#include <cstdlib>
#include <stdio.h> // Standard input/output definitions
#include <unistd.h> // UNIX standard function definitions
#include <fcntl.h> // File control definitions
#include <termios.h> // POSIX terminal control definitions
#include <pthread.h> // This uses POSIX Threads
#include <signal.h>
#include <common/mavlink.h>
// ------------------------------------------------------------------------------
// Defines
// ------------------------------------------------------------------------------
// The following two non-standard baudrates should have been defined by the system
// If not, just fallback to number
#ifndef B460800
#define B460800 460800
#endif
#ifndef B921600
#define B921600 921600
#endif
// Status flags
#define SERIAL_PORT_OPEN 1;
#define SERIAL_PORT_CLOSED 0;
#define SERIAL_PORT_ERROR -1;
// ------------------------------------------------------------------------------
// Prototypes
// ------------------------------------------------------------------------------
//class Serial_Port;
// ----------------------------------------------------------------------------------
// Serial Port Manager Class
// ----------------------------------------------------------------------------------
/*
* Serial Port Class
*
* This object handles the opening and closing of the offboard computer's
* serial port over which we'll communicate. It also has methods to write
* a byte stream buffer. MAVlink is not used in this object yet, it's just
* a serialization interface. To help with read and write pthreading, it
* gaurds any port operation with a pthread mutex.
*/
class Serial_Port
{
public:
Serial_Port();
Serial_Port(const char *uart_name_, int baudrate_);
void initialize_defaults();
~Serial_Port();
bool debug;
const char *uart_name;
int baudrate;
int status;
int read_message(mavlink_message_t &message);
int write_message(const mavlink_message_t &message);
void open_serial();
void close_serial();
void start();
void stop();
void handle_quit( int sig );
private:
int fd;
mavlink_status_t lastStatus;
pthread_mutex_t lock;
int _open_port(const char* port);
bool _setup_port(int baud, int data_bits, int stop_bits, bool parity, bool hardware_control);
int _read_port(uint8_t &cp);
int _write_port(char *buf, unsigned len);
};
#endif // SERIAL_PORT_H_
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。