Commit 52b20293 authored by lm's avatar lm

Merged

parents 809ac94f f0f05794
......@@ -44,4 +44,7 @@ user_config.pri
*.cproject
*.sln
*.suo
*thirdParty*
thirdParty/qserialport-build-desktop/
thirdParty/qserialport/bin/
thirdParty/qserialport/lib/
[submodule "thirdParty/mavlink"]
path = thirdParty/mavlink
url = https://github.com/pixhawk/mavlink.git
[submodule "thirdParty/qserial"]
path = thirdParty/qserial
url = git://gitorious.org/inbiza-labs/qserialport.git
......@@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 2.6)
project (qgroundcontrol)
# marcos
macro(find_or_build_from_source PACKAGE PACKAGE_PATH IS_GIT_SUBMODULE)
macro(find_or_build_from_source PACKAGE PACKAGE_PATH)
add_custom_target(${PACKAGE})
if (NOT ${PACKAGE}_BUILD_FROM_SOURCE)
find_package(${PACKAGE})
......@@ -14,11 +14,6 @@ macro(find_or_build_from_source PACKAGE PACKAGE_PATH IS_GIT_SUBMODULE)
add_custom_target(${PACKAGE}_BUILD DEPENDS ${PACKAGE}_BUILD.stamp)
add_dependencies(${PACKAGE} ${PACKAGE}_BUILD)
set(${PACKAGE}_FOUND TRUE)
if (${IS_GIT_SUBMODULE})
message(STATUS "${PACKAGE} detected as git submodule, will attempt to initialize it")
list(APPEND GIT_SUBMODULES ${PACKAGE_PATH})
add_dependencies(${PACKAGE}_BUILD GIT)
endif()
endif()
endmacro(find_or_build_from_source)
......@@ -103,18 +98,6 @@ include(CPack)
# add make dist target
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
# git submodules
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/.git)
message(STATUS "git repository detected, will attempt to load submodules")
set(FOUND_GIT_REPO TRUE)
add_custom_command(OUTPUT GIT.stamp
COMMAND cd ${PROJECT_SOURCE_DIR} && git submodule init ${GIT_SUBMODULES}
COMMAND cd ${PROJECT_SOURCE_DIR} && git submodule update ${GIT_SUBMODULES})
add_custom_target(GIT DEPENDS GIT.stamp)
else()
set(FOUND_GIT_REPO FALSE)
endif()
# find libraries with cmake modules
find_package(Qt4 COMPONENTS QtGui QtCore QtNetwork QtOpenGL QtSVG QtXML QtPhonon QtWebKit REQUIRED)
set(PHONON_FIND_QUIETLY FALSE)
......@@ -131,8 +114,8 @@ else()
set(OPENSCENEGRAPH_FOUND TRUE)
endif()
find_or_build_from_source(MAVLINK thirdParty/mavlink FOUND_GIT_REPO)
find_or_build_from_source(QSERIAL thirdParty/qserial FOUND_GIT_REPO)
find_or_build_from_source(MAVLINK thirdParty/mavlink)
find_or_build_from_source(QSERIALPORT thirdParty/qserialport)
# build libraries from source if not found on system
if(MAVLINK_BUILD_FROM_SOURCE)
......@@ -149,15 +132,67 @@ if(MAVLINK_BUILD_FROM_SOURCE)
COMMAND touch MAVLINK_BUILD.stamp)
endif()
if(QSERIAL_BUILD_FROM_SOURCE)
set(QSERIAL_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/thirdParty/qserial/include
${PROJECT_SOURCE_DIR}/thirdParty/qserial/include/QtSerialPort
${PROJECT_SOURCE_DIR}/thirdParty/qserial/src
if(QSERIALPORT_BUILD_FROM_SOURCE)
# qserialport headers without Q_OBJECT
# r !grep -RL Q_OBJECT thirdParty/qserialport/include
set (qserialportHdrs
thirdParty/qserialport/include/QtSerialPort/qserialport_export.h
thirdParty/qserialport/include/QtSerialPort/qserialport
thirdParty/qserialport/include/QtSerialPort/qportsettings.h
)
# qserialport headers with Q_OBJECT
# r !grep -Rl Q_OBJECT thirdParty/qserialport
set (qserialportMocSrc
thirdParty/qserialport/include/QtSerialPort/qserialport.h
thirdParty/qserialport/include/QtSerialPort/qserialportnative.h
)
# qserialport src
set (qserialportSrc
thirdParty/qserialport/src/common/qserialport.cpp
thirdParty/qserialport/src/common/qportsettings.cpp
)
# qserialport native code
if (WIN32)
list(APPEND qserialportHdrs
thirdParty/qserialport/src/win32/commdcbhelper.h
)
list(APPEND qserialportMocSrc
thirdParty/qserialport/src/win32/qwincommevtnotifier.h
thirdParty/qserialport/src/win32/wincommevtbreaker.h
)
set(QSERIAL_LIBRARIES qserial)
add_custom_command(OUTPUT QSERIAL_BUILD.stamp
COMMAND touch QSERIAL_BUILD.stamp)
list(APPEND qserialportSrc
thirdParty/qserialport/src/win32/qserialportnative_win32.cpp
thirdParty/qserialport/src/win32/commdcbhelper.cpp
thirdParty/qserialport/src/win32/qwincommevtnotifier.cpp
#thirdParty/qserialport/src/win32/qserialportnative_wince.cpp
#thirdParty/qserialport/src/win32/wincommevtbreaker.cpp
)
elseif(UNIX OR APPLE)
list(APPEND qserialportHdrs
thirdParty/qserialport/src/posix/termioshelper.h
)
list(APPEND qserialportSrc
thirdParty/qserialport/src/posix/termioshelper.cpp
thirdParty/qserialport/src/posix/qserialportnative_posix.cpp
)
else()
message(FATAL_ERROR "unknown OS")
endif()
# qserialport linking
qt4_wrap_cpp(qserialportMoc ${qserialportMocSrc})
add_library(qserialport ${qserialportMoc} ${qserialportSrc})
target_link_libraries(qserialport ${QT_LIBRARIES})
set(QSERIALPORT_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/thirdParty/qserialport/include
${PROJECT_SOURCE_DIR}/thirdParty/qserialport/include/QtSerialPort
${PROJECT_SOURCE_DIR}/thirdParty/qserialport/src
)
set(QSERIALPORT_LIBRARIES qserialport)
add_custom_command(OUTPUT qserialport_BUILD.stamp
COMMAND touch qserialport_BUILD.stamp)
endif()
# data directory
......@@ -214,10 +249,10 @@ if (MAVLINK_FOUND)
list(APPEND qgroundcontrolIncludes ${MAVLINK_INCLUDE_DIRS})
endif()
message(STATUS "\t\tQSERIAL\t\t${QSERIAL_FOUND}")
if (QSERIAL_FOUND)
list(APPEND qgroundcontrolIncludes ${QSERIAL_INCLUDE_DIRS})
list(APPEND qgroundcontrolLibs ${QSERIAL_LIBRARIES})
message(STATUS "\t\tqserialport\t${QSERIALPORT_FOUND}")
if (QSERIALPORT_FOUND)
list(APPEND qgroundcontrolIncludes ${QSERIALPORT_INCLUDE_DIRS})
list(APPEND qgroundcontrolLibs ${QSERIALPORT_LIBRARIES})
endif()
message(STATUS "\t\tOpenSceneGraph\t${OPENSCENEGRAPH_FOUND}")
......@@ -785,61 +820,6 @@ qt4_wrap_cpp(qextserialportMoc ${qextserialportMocSrc})
add_library(qextserialport ${qextserialportMoc} ${qextserialportSrc})
target_link_libraries(qextserialport ${QT_LIBRARIES})
# qserial library
#----------------------------------------------------------------------------
# qserial headers without Q_OBJECT
# r !grep -RL Q_OBJECT thirdParty/qserial/include
set (qserialHdrs
thirdParty/qserial/include/QtSerialPort/qserialport_export.h
thirdParty/qserial/include/QtSerialPort/QSerialPort
thirdParty/qserial/include/QtSerialPort/qportsettings.h
)
# qserial headers with Q_OBJECT
# r !grep -Rl Q_OBJECT thirdParty/qserial
set (qserialMocSrc
thirdParty/qserial/include/QtSerialPort/qserialport.h
thirdParty/qserial/include/QtSerialPort/qserialportnative.h
)
# qserial src
set (qserialSrc
thirdParty/qserial/src/common/qserialport.cpp
thirdParty/qserial/src/common/qportsettings.cpp
)
# qserial native code
if (WIN32)
list(APPEND qserialHdrs
thirdParty/qserial/src/win32/commdcbhelper.h
)
list(APPEND qserialMocSrc
thirdParty/qserial/src/win32/qwincommevtnotifier.h
thirdParty/qserial/src/win32/wincommevtbreaker.h
)
list(APPEND qserialSrc
thirdParty/qserial/src/win32/qserialportnative_win32.cpp
thirdParty/qserial/src/win32/commdcbhelper.cpp
thirdParty/qserial/src/win32/qwincommevtnotifier.cpp
#thirdParty/qserial/src/win32/qserialportnative_wince.cpp
#thirdParty/qserial/src/win32/wincommevtbreaker.cpp
)
elseif(UNIX OR APPLE)
list(APPEND qserialHdrs
thirdParty/qserial/src/posix/termioshelper.h
)
list(APPEND qserialSrc
thirdParty/qserial/src/posix/termioshelper.cpp
thirdParty/qserial/src/posix/qserialportnative_posix.cpp
)
else()
message(FATAL_ERROR "unknown OS")
endif()
# qserial linking
qt4_wrap_cpp(qserialMoc ${qserialMocSrc})
add_library(qserial ${qserialMoc} ${qserialSrc})
target_link_libraries(qserial ${QT_LIBRARIES})
# qmapcontrol library
#----------------------------------------------------------------------------
......
# - Try to find QSERIAL
# - Try to find QSERIALPORT
# Once done, this will define
#
# QSERIAL_FOUND - system has scicoslab
# QSERIAL_INCLUDE_DIRS - the scicoslab include directories
# QSERIAL_LIBRARIES - libraries to link to
# QSERIALPORT_FOUND - system has scicoslab
# QSERIALPORT_INCLUDE_DIRS - the scicoslab include directories
# QSERIALPORT_LIBRARIES - libraries to link to
include(LibFindMacros)
# Include dir
find_path(QSERIAL_INCLUDE_DIR
find_path(QSERIALPORT_INCLUDE_DIR
NAMES QSerialPort
PATHS
/usr/include/QtSerialPort
......@@ -17,7 +17,7 @@ find_path(QSERIAL_INCLUDE_DIR
)
# Finally the library itself
find_library(QSERIAL_LIBRARY
find_library(QSERIALPORT_LIBRARY
NAMES
QtSerialPort
PATHS
......@@ -28,6 +28,6 @@ find_library(QSERIAL_LIBRARY
# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
set(QSERIAL_PROCESS_INCLUDES QSERIAL_INCLUDE_DIR)
set(QSERIAL_PROCESS_LIBS QSERIAL_LIBRARY QSERIAL_LIBRARIES)
libfind_process(QSERIAL)
set(QSERIALPORT_PROCESS_INCLUDES QSERIALPORT_INCLUDE_DIR)
set(QSERIALPORT_PROCESS_LIBS QSERIALPORT_LIBRARY QSERIALPORT_LIBRARIES)
libfind_process(QSERIALPORT)
......@@ -18,12 +18,12 @@ do
if [ $OPT = "in_source_build" ] &> /dev/null
then
echo you chose in source build
mkdir -p build && cd build && cmake -DIN_SRC_BUILD:bool=TRUE .. && make $MAKEARGS
git submodule init && git submodule update && mkdir -p build && cd build && cmake -DIN_SRC_BUILD:bool=TRUE .. && make $MAKEARGS
exit 0
elif [ $OPT = "install_build" ] &> /dev/null
then
echo you chose install build
mkdir -p build && cd build && cmake .. && make $MAKEARGS
git submodule init && git submodule update mkdir -p build && cd build && cmake .. && make $MAKEARGS
exit 0
elif [ $OPT = "grab_debian_dependencies" ] &> /dev/null
then
......@@ -40,13 +40,13 @@ do
elif [ $OPT = "package_source" ] &> /dev/null
then
echo you chose to package the source
mkdir -p build && cd build && cmake .. && make package_source
git submodule init && git submodule update && mkdir -p build && cd build && cmake .. && make package_source
exit 0
elif [ $OPT = "package" ] &> /dev/null
then
echo you chose to package the binary
mkdir -p build && cd build && cmake .. && make package
git submodule init && git submodule update && mkdir -p build && cd build && cmake .. && make package
exit 0
elif [ $OPT = "clean" ] &> /dev/null
......
......@@ -59,36 +59,47 @@ exists(user_config.pri) {
}
INCLUDEPATH += $$BASEDIR/../mavlink/include/common
INCLUDEPATH += $$BASEDIR/../mavlink/include
INCLUDEPATH += $$BASEDIR/thirdParty/mavlink/include/common
INCLUDEPATH += $$BASEDIR/thirdParty/mavlink/include
contains(MAVLINK_CONF, pixhawk) {
# Remove the default set - it is included anyway
INCLUDEPATH -= $$BASEDIR/../mavlink/include/common
INCLUDEPATH -= $$BASEDIR/thirdParty/mavlink/include/common
# PIXHAWK SPECIAL MESSAGES
INCLUDEPATH += $$BASEDIR/../mavlink/include/pixhawk
INCLUDEPATH += $$BASEDIR/thirdParty/mavlink/include/pixhawk
DEFINES += QGC_USE_PIXHAWK_MESSAGES
}
contains(MAVLINK_CONF, slugs) {
# Remove the default set - it is included anyway
INCLUDEPATH -= $$BASEDIR/../mavlink/include/common
INCLUDEPATH -= $$BASEDIR/thirdParty/mavlink/include/common
# SLUGS SPECIAL MESSAGES
INCLUDEPATH += $$BASEDIR/../mavlink/include/slugs
INCLUDEPATH += $$BASEDIR/thirdParty/mavlink/include/slugs
DEFINES += QGC_USE_SLUGS_MESSAGES
}
contains(MAVLINK_CONF, ualberta) {
# Remove the default set - it is included anyway
INCLUDEPATH -= $$BASEDIR/../mavlink/include/common
INCLUDEPATH -= $$BASEDIR/thirdParty/mavlink/include/common
# UALBERTA SPECIAL MESSAGES
INCLUDEPATH += $$BASEDIR/../mavlink/include/ualberta
INCLUDEPATH += $$BASEDIR/thirdParty/mavlink/include/ualberta
DEFINES += QGC_USE_UALBERTA_MESSAGES
}
contains(MAVLINK_CONF, ardupilotmega) {
# Remove the default set - it is included anyway
INCLUDEPATH -= $$BASEDIR/../mavlink/include/common
INCLUDEPATH -= $$BASEDIR/thirdParty/mavlink/include/common
# UALBERTA SPECIAL MESSAGES
INCLUDEPATH += $$BASEDIR/../mavlink/include/ardupilotmega
INCLUDEPATH += $$BASEDIR/thirdParty/mavlink/include/ardupilotmega
DEFINES += QGC_USE_ARDUPILOTMEGA_MESSAGES
}
......@@ -98,13 +109,6 @@ contains(MAVLINK_CONF, ardupilotmega) {
# done by the plugins above
include(qgroundcontrol.pri)
# QWT plot and QExtSerial depend on paths set by qgroundcontrol.pri
# Include serial port library
include(src/lib/qextserialport/qextserialport.pri)
# include qserial library
include(thirdParty/qserial/qserialport.prf)
# Include QWT plotting library
include(src/lib/qwt/qwt.pri)
DEPENDPATH += . \
......@@ -112,11 +116,22 @@ DEPENDPATH += . \
# lib/QMapControl/src \
lib/opmapcontrol \
lib/opmapcontrol/src \
plugins
plugins \
thirdParty/qserialport/include \
thirdParty/qserialport/include/QtSerialPort \
thirdParty/qserialport
INCLUDEPATH += . \
# lib/QMapControl \
lib/opmapcontrol \
$$BASEDIR/../mavlink/include
thirdParty/qserialport/include \
thirdParty/qserialport/include/QtSerialPort \
thirdParty/qserialport/src
# Include serial port library
include(src/lib/qextserialport/qextserialport.pri)
# include qserial library
include(thirdParty/qserialport/qgroundcontrol-qserialport.pri)
# ../mavlink/include \
# MAVLink/include \
......
......@@ -390,14 +390,14 @@ void MAVLinkProtocol::sendHeartbeat()
mavlink_msg_heartbeat_pack(getSystemId(), getComponentId(),&beat, OCU, MAV_AUTOPILOT_GENERIC);
sendMessage(beat);
}
if (m_authEnabled) {
mavlink_message_t msg;
mavlink_auth_key_t auth;
if (m_authKey.length() != MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN) m_authKey.resize(MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN);
strcpy(auth.key, m_authKey.toStdString().c_str());
mavlink_msg_auth_key_encode(getSystemId(), getComponentId(), &msg, &auth);
sendMessage(msg);
}
//if (m_authEnabled) {
//mavlink_message_t msg;
//mavlink_auth_key_t auth;
//if (m_authKey.length() != MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN) m_authKey.resize(MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN);
//strcpy(auth.key, m_authKey.toStdString().c_str());
//mavlink_msg_auth_key_encode(getSystemId(), getComponentId(), &msg, &auth);
//sendMessage(msg);
//}
}
/** @param enabled true to enable heartbeats emission at heartbeatRate, false to disable */
......
......@@ -49,7 +49,8 @@ signals:
public:
enum baudRateType {
enum baudRateType
{
BAUD50, //POSIX ONLY
BAUD75, //POSIX ONLY
BAUD110,
......@@ -77,14 +78,16 @@ public:
BAUD921600 // WINDOWS ONLY
};
enum dataBitsType {
enum dataBitsType
{
DATA_5,
DATA_6,
DATA_7,
DATA_8
};
enum parityType {
enum parityType
{
PAR_NONE,
PAR_ODD,
PAR_EVEN,
......@@ -92,13 +95,15 @@ public:
PAR_SPACE
};
enum stopBitsType {
enum stopBitsType
{
STOP_1,
STOP_1_5, //WINDOWS ONLY
STOP_2
};
enum flowType {
enum flowType
{
FLOW_OFF,
FLOW_HARDWARE,
FLOW_XONXOFF
......@@ -107,7 +112,8 @@ public:
/**
* structure to contain port settings
*/
struct portSettings {
struct portSettings
{
baudRateType BaudRate;
dataBitsType DataBits;
parityType Parity;
......@@ -186,10 +192,11 @@ public:
}
virtual void setTimeout(qint64 timeout) {
_port->setTimeout(timeout);
};
}
virtual void setFlow(SerialInterface::flowType flow) {
// TODO implement
};
_port->setFlowControl((FlowType)flow);
}
};
using namespace TNX;
......@@ -262,11 +269,11 @@ public:
virtual void setTimeout(qint64 timeout) {
// TODO implement
//_port->setTimeout(timeout);
};
}
virtual void setFlow(SerialInterface::flowType flow) {
// TODO map
settings.setFlowControl(QPortSettings::FLOW_OFF);
};
}
};
#endif // SERIALINTERFACE_H
......
......@@ -48,32 +48,14 @@ SerialLink::SerialLink(QString portname, SerialInterface::baudRateType baudrate,
this->timeout = 1; ///< The timeout controls how long the program flow should wait for new serial bytes. As we're polling, we don't want to wait at all.
// Set the port name
if (porthandle == "") {
// name = tr("serial link ") + QString::number(getId()) + tr(" (unconfigured)");
if (porthandle == "")
{
name = tr("Serial Link ") + QString::number(getId());
} else {
name = portname.trimmed();
}
#ifdef _WIN3232
// Windows 32bit & 64bit serial connection
winPort = CreateFile(porthandle,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
if(winPort==INVALID_HANDLE_VALUE) {
if(GetLastError()==ERROR_FILE_NOT_FOUND) {
//serial port does not exist. Inform user.
}
//some other error occurred. Inform user.
else
{
name = portname.trimmed();
}
#else
#endif
loadSettings();
}
......
......@@ -690,15 +690,15 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
}
break;
case MAVLINK_MSG_ID_SCALED_PRESSURE: {
mavlink_scaled_pressure_t pressure;
mavlink_msg_scaled_pressure_decode(&message, &pressure);
quint64 time = this->getUnixTime(pressure.usec);
emit valueChanged(uasId, "abs pressure", "hPa", pressure.press_abs, time);
emit valueChanged(uasId, "diff pressure", "hPa", pressure.press_diff, time);
emit valueChanged(uasId, "temperature", "C", pressure.temperature/100.0, time);
}
break;
//case MAVLINK_MSG_ID_SCALED_PRESSURE: {
//mavlink_scaled_pressure_t pressure;
//mavlink_msg_scaled_pressure_decode(&message, &pressure);
//quint64 time = this->getUnixTime(pressure.usec);
//emit valueChanged(uasId, "abs pressure", "hPa", pressure.press_abs, time);
//emit valueChanged(uasId, "diff pressure", "hPa", pressure.press_diff, time);
//emit valueChanged(uasId, "temperature", "C", pressure.temperature/100.0, time);
//}
//break;
case MAVLINK_MSG_ID_RC_CHANNELS_RAW: {
mavlink_rc_channels_raw_t channels;
......@@ -1304,10 +1304,10 @@ void UAS::getStatusForCode(int statusCode, QString& uasState, QString& stateDesc
uasState = tr("EMERGENCY");
stateDescription = tr("EMERGENCY: Land Immediately!");
break;
case MAV_STATE_HILSIM:
uasState = tr("HIL SIM");
stateDescription = tr("HIL Simulation, Sensors read from SIM");
break;
//case MAV_STATE_HILSIM:
//uasState = tr("HIL SIM");
//stateDescription = tr("HIL Simulation, Sensors read from SIM");
//break;
case MAV_STATE_POWEROFF:
uasState = tr("SHUTDOWN");
......@@ -1975,24 +1975,24 @@ bool UAS::emergencyKILL()
void UAS::startHil()
{
mavlink_message_t msg;
// TODO Replace MG System ID with static function call and allow to change ID in GUI
mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU,(int)MAV_ACTION_START_HILSIM);
// Send message twice to increase chance of reception
sendMessage(msg);
sendMessage(msg);
//mavlink_message_t msg;
//// TODO Replace MG System ID with static function call and allow to change ID in GUI
//mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU,(int)MAV_ACTION_START_HILSIM);
//// Send message twice to increase chance of reception
//sendMessage(msg);
//sendMessage(msg);
}
void UAS::stopHil()
{
mavlink_message_t msg;
// TODO Replace MG System ID with static function call and allow to change ID in GUI
mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU,(int)MAV_ACTION_STOP_HILSIM);
// Send message twice to increase chance of reception
sendMessage(msg);
sendMessage(msg);
//mavlink_message_t msg;
//// TODO Replace MG System ID with static function call and allow to change ID in GUI
//mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU,(int)MAV_ACTION_STOP_HILSIM);
//// Send message twice to increase chance of reception
//sendMessage(msg);
//sendMessage(msg);
}
......
#!/bin/bash
PS3='Please enter your choice: '
LIST="all mavlink qserialport end"
echo
echo this script grabs upstream releases
echo
function fetch_qserialport
{
echo
rm -rf qserialport
git clone git://gitorious.org/inbiza-labs/qserialport.git
rm -rf qserialport/.git
}
function fetch_mavlink
{
echo
rm -rf mavlink
git clone git@github.com:openmav/mavlink.git
rm -rf mavlink/.git
}
echo
select OPT in $LIST
do
case $OPT in
"qserialport")
fetch_qserialport
exit 0
;;
"mavlink")
fetch_mavlink
exit 0
;;
"all")
fetch_mavlink
fetch_qserialport
exit 0
;;
"exit")
exit 0
;;
*)
echo unknown option
exit 1
esac
done
Subproject commit d2803c5eddbb30a14731c403a96f7a200318e50f
*~
doc/html
doc/*.log
MAVLink Micro Air Vehicle Message Marshalling Library
This is a library for lightweight communication between
Micro Air Vehicles (swarm) and/or ground control stations.
It serializes C-structs for serial channels and can be used with
any type of radio modem.
For help, please visit the mailing list: http://groups.google.com/group/mavlink
MAVLink is licensed under the terms of the Lesser General Public License of the Free Software Foundation (LGPL).
As MAVLink is a header-only library, compiling an application with it is considered "using the libary", not a derived work. MAVLink can therefore be used without limits in any closed-source application without publishing the source code of the closed-source application.
To generate/update packets, select mavlink_standard_message.xml
in the QGroundControl station settings view, select mavlink/include as
the output directory and click on "Save and Generate".
You will find the newly generated/updated message_xx.h files in
the mavlink/include/generated folder.
To use MAVLink, #include the <mavlink.h> file, not the individual
message files. In some cases you will have to add the main folder to the include search path as well. To be safe, we recommend these flags:
gcc -I mavlink/include -I mavlink/include/<your message set, e.g. common>
For more information, please visit:
http://qgroundcontrol.org/mavlink/
(c) 2009-2011 Lorenz Meier <mail@qgroundcontrol.org>
This diff is collapsed.
MAVLink Micro Air Vehicle Message Marshalling Library
The mavlink_to_html_table.xsl file is used to transform the MAVLink XML into a human-readable HTML table for online documentation.
For more information, please visit:
http://pixhawk.ethz.ch/software/mavlink
(c) 2009-2010 Lorenz Meier / PIXHAWK Team
table.sortable {
spacing: 5px;
border: 1px solid #656575;
width: 100%;
}
table.sortable th {
margin: 5px;
}
tr:nth-child(odd) { background-color:#eee; }
tr:nth-child(even) { background-color:#fff; }
table.sortable thead {
background-color:#eee;
color:#666666;
font-weight: bold;
cursor: default;
}
table.sortable td {
margin: 5px 5px 20px 5px;
vertical-align: top;
}
table.sortable td.mavlink_name {
color:#226633;
font-weight: bold;
width: 25%;
vertical-align: top;
}
table.sortable td.mavlink_mission_param {
color:#334455;
font-weight: bold;
width: 25%;
}
table.sortable td.mavlink_type {
color:#323232;
font-weight: normal;
width: 12%;
}
table.sortable td.mavlink_comment {
color:#555555;
font-weight: normal;
width: 60%;
}
p.description {
color:#808080;
font-weight: normal;
}
\ No newline at end of file
<?php>
// Requires the installation of php5-xsl
// e.g. on Debian/Ubuntu: sudo apt-get install php5-xsl
// Load the file from the repository / server.
// Update this URL if the file location changes
$xml_file_name = "http://github.com/pixhawk/mavlink/raw/master/mavlink_standard_message.xml";
// Load the XSL transformation file from the repository / server.
// This file can be updated by any client to adjust the table
$xsl_file_name= "http://github.com/pixhawk/mavlink/raw/master/doc/mavlink_to_html_table.xsl";
// Load data XML file
$xml = file_get_contents($xml_file_name);
$xml_doc = new DomDocument;
$xml_doc->loadXML($xml);
// Load stylesheet XSL file
$xsl = file_get_contents($xsl_file_name);
$xsl_doc = new DomDocument;
$xsl_doc->loadXML($xsl);
$xsltproc = new XsltProcessor();
$xsltproc->importStylesheet($xsl_doc);
// process the files and write the output to $out_file
if ($html = $xsltproc->transformToXML($xml_doc))
{
echo $html;
}
else
{
trigger_error('XSL transformation failed.',E_USER_ERROR);
}
</php>
<h2> Messages XML Definition </h2>
Messages are defined by the <a href="http://github.com/pixhawk/mavlink/blob/master/mavlink_standard_message.xml">mavlink_standard_message.xml</a> file. The C packing/unpacking code is generated from this specification, as well as the HTML documentaiton in the section above.<br />
<br />
<i>The XML displayed here is updated on every commit and therefore up-to-date.</i>
<?php>
//require_once("inc/geshi.php");
//$xml_file_name = "http://github.com/pixhawk/mavlink/raw/master/mavlink_standard_message.xml";
//
//// Load data XML file
//$xml = file_get_contents($xml_file_name);
//
//// Show the current code
//$geshi_xml = new GeSHi($xml, 'xml');
//$display_xml = $geshi_xml->parse_code();
//
//echo $display_xml;
</php>
\ No newline at end of file
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="//include">
<h1>MAVLink Include Files</h1>
<p><strong><em>Including files: </em><xsl:value-of select="." /></strong></p>
</xsl:template>
<xsl:template match="//enums">
<h1>MAVLink Type Enumerations</h1>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="//messages">
<h1>MAVLink Messages</h1>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="//message">
<h3 class="mavlink_message_name"><xsl:value-of select="@name" /> (#<xsl:value-of select="@id" />)</h3>
<p class="description"><xsl:value-of select="description" /></p>
<table class="sortable">
<thead>
<tr>
<th class="mavlink_field_header">Field Name</th>
<th class="mavlink_field_header">Type</th>
<th class="mavlink_field_header">Description</th>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="field" />
</tbody>
</table>
</xsl:template>
<xsl:template match="//field">
<tr class="mavlink_field">
<td class="mavlink_name" valign="top"><xsl:value-of select="@name" /></td>
<td class="mavlink_type" valign="top"><xsl:value-of select="@type" /></td>
<td class="mavlink_comment"><xsl:value-of select="." /></td>
</tr>
</xsl:template>
<xsl:template match="//version">
<h1>MAVLink Protocol Version</h1>
<p>This file has protocol version: <xsl:value-of select="." />. The version numbers range from 1-255.</p>
</xsl:template>
<xsl:template match="//enum">
<h3 class="mavlink_message_name"><xsl:value-of select="@name" /></h3>
<p class="description"><xsl:value-of select="description" /></p>
<table class="sortable">
<thead>
<tr>
<th class="mavlink_field_header">CMD ID</th>
<th class="mavlink_field_header">Field Name</th>
<th class="mavlink_field_header">Description</th>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="entry" />
</tbody>
</table>
</xsl:template>
<xsl:template match="//entry">
<tr class="mavlink_field">
<td class="mavlink_type" valign="top"><xsl:value-of select="@value" /></td>
<td class="mavlink_name" valign="top"><xsl:value-of select="@name" /></td>
<td class="mavlink_comment"><xsl:value-of select="description" /></td>
</tr>
<tr>
<td></td>
<xsl:apply-templates select="param" />
</tr>
<tr>
<td colspan="3"><br /></td>
</tr>
</xsl:template>
<xsl:template match="//param">
<tr>
<td></td>
<td class="mavlink_mission_param" valign="top">Mission Param #<xsl:value-of select="@index" /></td>
<td class="mavlink_comment"><xsl:value-of select="." /></td>
</tr>
</xsl:template>
</xsl:stylesheet>
/** @file
* @brief MAVLink comm protocol.
* @see http://pixhawk.ethz.ch/software/mavlink
* Generated on Thursday, March 31 2011, 22:06 UTC
*/
#ifndef ARDUPILOTMEGA_H
#define ARDUPILOTMEGA_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../protocol.h"
#define MAVLINK_ENABLED_ARDUPILOTMEGA
#include "../common/common.h"
// MAVLINK VERSION
#ifndef MAVLINK_VERSION
#define MAVLINK_VERSION 0
#endif
#if (MAVLINK_VERSION == 0)
#undef MAVLINK_VERSION
#define MAVLINK_VERSION 0
#endif
// ENUM DEFINITIONS
// MESSAGE DEFINITIONS
#ifdef __cplusplus
}
#endif
#endif
/** @file
* @brief MAVLink comm protocol.
* @see http://pixhawk.ethz.ch/software/mavlink
* Generated on Thursday, March 31 2011, 22:06 UTC
*/
#ifndef MAVLINK_H
#define MAVLINK_H
#include "ardupilotmega.h"
#endif
#include <mavlink.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
uint8_t bitfield = 254; // 11111110
uint8_t mask = 128; // 10000000
uint8_t result = (bitfield & mask);
printf("0x%02x\n", bitfield);
// Transform into network order
generic_32bit bin;
bin.i = 1;
printf("First byte in (little endian) 0x%02x\n", bin.b[0]);
generic_32bit bout;
bout.b[0] = bin.b[3];
bout.b[1] = bin.b[2];
bout.b[2] = bin.b[1];
bout.b[3] = bin.b[0];
printf("Last byte out (big endian) 0x%02x\n", bout.b[3]);
uint8_t n = 5;
printf("Mask is 0x%02x\n", ((uint32_t)(1 << n)) - 1); // = 2^n - 1
int32_t encoded = 2;
uint8_t bits = 2;
uint8_t packet[MAVLINK_MAX_PACKET_LEN];
uint8_t packet_index = 0;
uint8_t bit_index = 0;
put_bitfield_n_by_index(encoded, bits, packet_index, bit_index, &bit_index, packet);
}
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _CHECKSUM_H_
#define _CHECKSUM_H_
#include "inttypes.h"
/**
*
* CALCULATE THE CHECKSUM
*
*/
#define X25_INIT_CRC 0xffff
#define X25_VALIDATE_CRC 0xf0b8
/**
* @brief Accumulate the X.25 CRC by adding one char at a time.
*
* The checksum function adds the hash of one char at a time to the
* 16 bit checksum (uint16_t).
*
* @param data new char to hash
* @param crcAccum the already accumulated checksum
**/
static inline void crc_accumulate(uint8_t data, uint16_t *crcAccum)
{
/*Accumulate one byte of data into the CRC*/
uint8_t tmp;
tmp=data ^ (uint8_t)(*crcAccum &0xff);
tmp^= (tmp<<4);
*crcAccum = (*crcAccum>>8) ^ (tmp<<8) ^ (tmp <<3) ^ (tmp>>4);
}
/**
* @brief Initiliaze the buffer for the X.25 CRC
*
* @param crcAccum the 16 bit X.25 CRC
*/
static inline void crc_init(uint16_t* crcAccum)
{
*crcAccum = X25_INIT_CRC;
}
/**
* @brief Calculates the X.25 checksum on a byte buffer
*
* @param pBuffer buffer containing the byte array to hash
* @param length length of the byte array
* @return the checksum over the buffer bytes
**/
static inline uint16_t crc_calculate(uint8_t* pBuffer, int length)
{
// For a "message" of length bytes contained in the unsigned char array
// pointed to by pBuffer, calculate the CRC
// crcCalculate(unsigned char* pBuffer, int length, unsigned short* checkConst) < not needed
uint16_t crcTmp;
//uint16_t tmp;
uint8_t* pTmp;
int i;
pTmp=pBuffer;
/* init crcTmp */
crc_init(&crcTmp);
for (i = 0; i < length; i++){
crc_accumulate(*pTmp++, &crcTmp);
}
/* This is currently not needed, as only the checksum over payload should be computed
tmp = crcTmp;
crcAccumulate((unsigned char)(~crcTmp & 0xff),&tmp);
crcAccumulate((unsigned char)((~crcTmp>>8)&0xff),&tmp);
*checkConst = tmp;
*/
return(crcTmp);
}
#endif /* _CHECKSUM_H_ */
#ifdef __cplusplus
}
#endif
This diff is collapsed.
/** @file
* @brief MAVLink comm protocol.
* @see http://pixhawk.ethz.ch/software/mavlink
* Generated on Thursday, March 31 2011, 22:06 UTC
*/
#ifndef MAVLINK_H
#define MAVLINK_H
#include "common.h"
#endif
// MESSAGE ACTION PACKING
#define MAVLINK_MSG_ID_ACTION 10
typedef struct __mavlink_action_t
{
uint8_t target; ///< The system executing the action
uint8_t target_component; ///< The component executing the action
uint8_t action; ///< The action id
} mavlink_action_t;
/**
* @brief Pack a action message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param target The system executing the action
* @param target_component The component executing the action
* @param action The action id
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_action_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t target, uint8_t target_component, uint8_t action)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_ACTION;
i += put_uint8_t_by_index(target, i, msg->payload); // The system executing the action
i += put_uint8_t_by_index(target_component, i, msg->payload); // The component executing the action
i += put_uint8_t_by_index(action, i, msg->payload); // The action id
return mavlink_finalize_message(msg, system_id, component_id, i);
}
/**
* @brief Pack a action message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message was sent over
* @param msg The MAVLink message to compress the data into
* @param target The system executing the action
* @param target_component The component executing the action
* @param action The action id
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_action_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t target, uint8_t target_component, uint8_t action)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_ACTION;
i += put_uint8_t_by_index(target, i, msg->payload); // The system executing the action
i += put_uint8_t_by_index(target_component, i, msg->payload); // The component executing the action
i += put_uint8_t_by_index(action, i, msg->payload); // The action id
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
}
/**
* @brief Encode a action struct into a message
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param action C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_action_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_action_t* action)
{
return mavlink_msg_action_pack(system_id, component_id, msg, action->target, action->target_component, action->action);
}
/**
* @brief Send a action message
* @param chan MAVLink channel to send the message
*
* @param target The system executing the action
* @param target_component The component executing the action
* @param action The action id
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_action_send(mavlink_channel_t chan, uint8_t target, uint8_t target_component, uint8_t action)
{
mavlink_message_t msg;
mavlink_msg_action_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, target, target_component, action);
mavlink_send_uart(chan, &msg);
}
#endif
// MESSAGE ACTION UNPACKING
/**
* @brief Get field target from action message
*
* @return The system executing the action
*/
static inline uint8_t mavlink_msg_action_get_target(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload)[0];
}
/**
* @brief Get field target_component from action message
*
* @return The component executing the action
*/
static inline uint8_t mavlink_msg_action_get_target_component(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload+sizeof(uint8_t))[0];
}
/**
* @brief Get field action from action message
*
* @return The action id
*/
static inline uint8_t mavlink_msg_action_get_action(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t))[0];
}
/**
* @brief Decode a action message into a struct
*
* @param msg The message to decode
* @param action C-struct to decode the message contents into
*/
static inline void mavlink_msg_action_decode(const mavlink_message_t* msg, mavlink_action_t* action)
{
action->target = mavlink_msg_action_get_target(msg);
action->target_component = mavlink_msg_action_get_target_component(msg);
action->action = mavlink_msg_action_get_action(msg);
}
// MESSAGE ACTION_ACK PACKING
#define MAVLINK_MSG_ID_ACTION_ACK 9
typedef struct __mavlink_action_ack_t
{
uint8_t action; ///< The action id
uint8_t result; ///< 0: Action DENIED, 1: Action executed
} mavlink_action_ack_t;
/**
* @brief Pack a action_ack message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param action The action id
* @param result 0: Action DENIED, 1: Action executed
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_action_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t action, uint8_t result)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_ACTION_ACK;
i += put_uint8_t_by_index(action, i, msg->payload); // The action id
i += put_uint8_t_by_index(result, i, msg->payload); // 0: Action DENIED, 1: Action executed
return mavlink_finalize_message(msg, system_id, component_id, i);
}
/**
* @brief Pack a action_ack message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message was sent over
* @param msg The MAVLink message to compress the data into
* @param action The action id
* @param result 0: Action DENIED, 1: Action executed
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_action_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t action, uint8_t result)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_ACTION_ACK;
i += put_uint8_t_by_index(action, i, msg->payload); // The action id
i += put_uint8_t_by_index(result, i, msg->payload); // 0: Action DENIED, 1: Action executed
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
}
/**
* @brief Encode a action_ack struct into a message
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param action_ack C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_action_ack_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_action_ack_t* action_ack)
{
return mavlink_msg_action_ack_pack(system_id, component_id, msg, action_ack->action, action_ack->result);
}
/**
* @brief Send a action_ack message
* @param chan MAVLink channel to send the message
*
* @param action The action id
* @param result 0: Action DENIED, 1: Action executed
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_action_ack_send(mavlink_channel_t chan, uint8_t action, uint8_t result)
{
mavlink_message_t msg;
mavlink_msg_action_ack_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, action, result);
mavlink_send_uart(chan, &msg);
}
#endif
// MESSAGE ACTION_ACK UNPACKING
/**
* @brief Get field action from action_ack message
*
* @return The action id
*/
static inline uint8_t mavlink_msg_action_ack_get_action(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload)[0];
}
/**
* @brief Get field result from action_ack message
*
* @return 0: Action DENIED, 1: Action executed
*/
static inline uint8_t mavlink_msg_action_ack_get_result(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload+sizeof(uint8_t))[0];
}
/**
* @brief Decode a action_ack message into a struct
*
* @param msg The message to decode
* @param action_ack C-struct to decode the message contents into
*/
static inline void mavlink_msg_action_ack_decode(const mavlink_message_t* msg, mavlink_action_ack_t* action_ack)
{
action_ack->action = mavlink_msg_action_ack_get_action(msg);
action_ack->result = mavlink_msg_action_ack_get_result(msg);
}
// MESSAGE ATTITUDE PACKING
#define MAVLINK_MSG_ID_ATTITUDE 30
typedef struct __mavlink_attitude_t
{
uint64_t usec; ///< Timestamp (microseconds since UNIX epoch or microseconds since system boot)
float roll; ///< Roll angle (rad)
float pitch; ///< Pitch angle (rad)
float yaw; ///< Yaw angle (rad)
float rollspeed; ///< Roll angular speed (rad/s)
float pitchspeed; ///< Pitch angular speed (rad/s)
float yawspeed; ///< Yaw angular speed (rad/s)
} mavlink_attitude_t;
/**
* @brief Pack a attitude message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
* @param roll Roll angle (rad)
* @param pitch Pitch angle (rad)
* @param yaw Yaw angle (rad)
* @param rollspeed Roll angular speed (rad/s)
* @param pitchspeed Pitch angular speed (rad/s)
* @param yawspeed Yaw angular speed (rad/s)
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_attitude_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint64_t usec, float roll, float pitch, float yaw, float rollspeed, float pitchspeed, float yawspeed)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_ATTITUDE;
i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (microseconds since UNIX epoch or microseconds since system boot)
i += put_float_by_index(roll, i, msg->payload); // Roll angle (rad)
i += put_float_by_index(pitch, i, msg->payload); // Pitch angle (rad)
i += put_float_by_index(yaw, i, msg->payload); // Yaw angle (rad)
i += put_float_by_index(rollspeed, i, msg->payload); // Roll angular speed (rad/s)
i += put_float_by_index(pitchspeed, i, msg->payload); // Pitch angular speed (rad/s)
i += put_float_by_index(yawspeed, i, msg->payload); // Yaw angular speed (rad/s)
return mavlink_finalize_message(msg, system_id, component_id, i);
}
/**
* @brief Pack a attitude message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message was sent over
* @param msg The MAVLink message to compress the data into
* @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
* @param roll Roll angle (rad)
* @param pitch Pitch angle (rad)
* @param yaw Yaw angle (rad)
* @param rollspeed Roll angular speed (rad/s)
* @param pitchspeed Pitch angular speed (rad/s)
* @param yawspeed Yaw angular speed (rad/s)
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_attitude_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint64_t usec, float roll, float pitch, float yaw, float rollspeed, float pitchspeed, float yawspeed)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_ATTITUDE;
i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (microseconds since UNIX epoch or microseconds since system boot)
i += put_float_by_index(roll, i, msg->payload); // Roll angle (rad)
i += put_float_by_index(pitch, i, msg->payload); // Pitch angle (rad)
i += put_float_by_index(yaw, i, msg->payload); // Yaw angle (rad)
i += put_float_by_index(rollspeed, i, msg->payload); // Roll angular speed (rad/s)
i += put_float_by_index(pitchspeed, i, msg->payload); // Pitch angular speed (rad/s)
i += put_float_by_index(yawspeed, i, msg->payload); // Yaw angular speed (rad/s)
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
}
/**
* @brief Encode a attitude struct into a message
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param attitude C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_attitude_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_attitude_t* attitude)
{
return mavlink_msg_attitude_pack(system_id, component_id, msg, attitude->usec, attitude->roll, attitude->pitch, attitude->yaw, attitude->rollspeed, attitude->pitchspeed, attitude->yawspeed);
}
/**
* @brief Send a attitude message
* @param chan MAVLink channel to send the message
*
* @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
* @param roll Roll angle (rad)
* @param pitch Pitch angle (rad)
* @param yaw Yaw angle (rad)
* @param rollspeed Roll angular speed (rad/s)
* @param pitchspeed Pitch angular speed (rad/s)
* @param yawspeed Yaw angular speed (rad/s)
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_attitude_send(mavlink_channel_t chan, uint64_t usec, float roll, float pitch, float yaw, float rollspeed, float pitchspeed, float yawspeed)
{
mavlink_message_t msg;
mavlink_msg_attitude_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, usec, roll, pitch, yaw, rollspeed, pitchspeed, yawspeed);
mavlink_send_uart(chan, &msg);
}
#endif
// MESSAGE ATTITUDE UNPACKING
/**
* @brief Get field usec from attitude message
*
* @return Timestamp (microseconds since UNIX epoch or microseconds since system boot)
*/
static inline uint64_t mavlink_msg_attitude_get_usec(const mavlink_message_t* msg)
{
generic_64bit r;
r.b[7] = (msg->payload)[0];
r.b[6] = (msg->payload)[1];
r.b[5] = (msg->payload)[2];
r.b[4] = (msg->payload)[3];
r.b[3] = (msg->payload)[4];
r.b[2] = (msg->payload)[5];
r.b[1] = (msg->payload)[6];
r.b[0] = (msg->payload)[7];
return (uint64_t)r.ll;
}
/**
* @brief Get field roll from attitude message
*
* @return Roll angle (rad)
*/
static inline float mavlink_msg_attitude_get_roll(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload+sizeof(uint64_t))[0];
r.b[2] = (msg->payload+sizeof(uint64_t))[1];
r.b[1] = (msg->payload+sizeof(uint64_t))[2];
r.b[0] = (msg->payload+sizeof(uint64_t))[3];
return (float)r.f;
}
/**
* @brief Get field pitch from attitude message
*
* @return Pitch angle (rad)
*/
static inline float mavlink_msg_attitude_get_pitch(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload+sizeof(uint64_t)+sizeof(float))[0];
r.b[2] = (msg->payload+sizeof(uint64_t)+sizeof(float))[1];
r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float))[2];
r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float))[3];
return (float)r.f;
}
/**
* @brief Get field yaw from attitude message
*
* @return Yaw angle (rad)
*/
static inline float mavlink_msg_attitude_get_yaw(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[0];
r.b[2] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[1];
r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[2];
r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[3];
return (float)r.f;
}
/**
* @brief Get field rollspeed from attitude message
*
* @return Roll angular speed (rad/s)
*/
static inline float mavlink_msg_attitude_get_rollspeed(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float))[0];
r.b[2] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float))[1];
r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float))[2];
r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float))[3];
return (float)r.f;
}
/**
* @brief Get field pitchspeed from attitude message
*
* @return Pitch angular speed (rad/s)
*/
static inline float mavlink_msg_attitude_get_pitchspeed(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[0];
r.b[2] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[1];
r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[2];
r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[3];
return (float)r.f;
}
/**
* @brief Get field yawspeed from attitude message
*
* @return Yaw angular speed (rad/s)
*/
static inline float mavlink_msg_attitude_get_yawspeed(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[0];
r.b[2] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[1];
r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[2];
r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[3];
return (float)r.f;
}
/**
* @brief Decode a attitude message into a struct
*
* @param msg The message to decode
* @param attitude C-struct to decode the message contents into
*/
static inline void mavlink_msg_attitude_decode(const mavlink_message_t* msg, mavlink_attitude_t* attitude)
{
attitude->usec = mavlink_msg_attitude_get_usec(msg);
attitude->roll = mavlink_msg_attitude_get_roll(msg);
attitude->pitch = mavlink_msg_attitude_get_pitch(msg);
attitude->yaw = mavlink_msg_attitude_get_yaw(msg);
attitude->rollspeed = mavlink_msg_attitude_get_rollspeed(msg);
attitude->pitchspeed = mavlink_msg_attitude_get_pitchspeed(msg);
attitude->yawspeed = mavlink_msg_attitude_get_yawspeed(msg);
}
// MESSAGE ATTITUDE_CONTROLLER_OUTPUT PACKING
#define MAVLINK_MSG_ID_ATTITUDE_CONTROLLER_OUTPUT 60
typedef struct __mavlink_attitude_controller_output_t
{
uint8_t enabled; ///< 1: enabled, 0: disabled
int8_t roll; ///< Attitude roll: -128: -100%, 127: +100%
int8_t pitch; ///< Attitude pitch: -128: -100%, 127: +100%
int8_t yaw; ///< Attitude yaw: -128: -100%, 127: +100%
int8_t thrust; ///< Attitude thrust: -128: -100%, 127: +100%
} mavlink_attitude_controller_output_t;
/**
* @brief Pack a attitude_controller_output message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param enabled 1: enabled, 0: disabled
* @param roll Attitude roll: -128: -100%, 127: +100%
* @param pitch Attitude pitch: -128: -100%, 127: +100%
* @param yaw Attitude yaw: -128: -100%, 127: +100%
* @param thrust Attitude thrust: -128: -100%, 127: +100%
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_attitude_controller_output_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t enabled, int8_t roll, int8_t pitch, int8_t yaw, int8_t thrust)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_ATTITUDE_CONTROLLER_OUTPUT;
i += put_uint8_t_by_index(enabled, i, msg->payload); // 1: enabled, 0: disabled
i += put_int8_t_by_index(roll, i, msg->payload); // Attitude roll: -128: -100%, 127: +100%
i += put_int8_t_by_index(pitch, i, msg->payload); // Attitude pitch: -128: -100%, 127: +100%
i += put_int8_t_by_index(yaw, i, msg->payload); // Attitude yaw: -128: -100%, 127: +100%
i += put_int8_t_by_index(thrust, i, msg->payload); // Attitude thrust: -128: -100%, 127: +100%
return mavlink_finalize_message(msg, system_id, component_id, i);
}
/**
* @brief Pack a attitude_controller_output message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message was sent over
* @param msg The MAVLink message to compress the data into
* @param enabled 1: enabled, 0: disabled
* @param roll Attitude roll: -128: -100%, 127: +100%
* @param pitch Attitude pitch: -128: -100%, 127: +100%
* @param yaw Attitude yaw: -128: -100%, 127: +100%
* @param thrust Attitude thrust: -128: -100%, 127: +100%
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_attitude_controller_output_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t enabled, int8_t roll, int8_t pitch, int8_t yaw, int8_t thrust)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_ATTITUDE_CONTROLLER_OUTPUT;
i += put_uint8_t_by_index(enabled, i, msg->payload); // 1: enabled, 0: disabled
i += put_int8_t_by_index(roll, i, msg->payload); // Attitude roll: -128: -100%, 127: +100%
i += put_int8_t_by_index(pitch, i, msg->payload); // Attitude pitch: -128: -100%, 127: +100%
i += put_int8_t_by_index(yaw, i, msg->payload); // Attitude yaw: -128: -100%, 127: +100%
i += put_int8_t_by_index(thrust, i, msg->payload); // Attitude thrust: -128: -100%, 127: +100%
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
}
/**
* @brief Encode a attitude_controller_output struct into a message
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param attitude_controller_output C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_attitude_controller_output_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_attitude_controller_output_t* attitude_controller_output)
{
return mavlink_msg_attitude_controller_output_pack(system_id, component_id, msg, attitude_controller_output->enabled, attitude_controller_output->roll, attitude_controller_output->pitch, attitude_controller_output->yaw, attitude_controller_output->thrust);
}
/**
* @brief Send a attitude_controller_output message
* @param chan MAVLink channel to send the message
*
* @param enabled 1: enabled, 0: disabled
* @param roll Attitude roll: -128: -100%, 127: +100%
* @param pitch Attitude pitch: -128: -100%, 127: +100%
* @param yaw Attitude yaw: -128: -100%, 127: +100%
* @param thrust Attitude thrust: -128: -100%, 127: +100%
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_attitude_controller_output_send(mavlink_channel_t chan, uint8_t enabled, int8_t roll, int8_t pitch, int8_t yaw, int8_t thrust)
{
mavlink_message_t msg;
mavlink_msg_attitude_controller_output_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, enabled, roll, pitch, yaw, thrust);
mavlink_send_uart(chan, &msg);
}
#endif
// MESSAGE ATTITUDE_CONTROLLER_OUTPUT UNPACKING
/**
* @brief Get field enabled from attitude_controller_output message
*
* @return 1: enabled, 0: disabled
*/
static inline uint8_t mavlink_msg_attitude_controller_output_get_enabled(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload)[0];
}
/**
* @brief Get field roll from attitude_controller_output message
*
* @return Attitude roll: -128: -100%, 127: +100%
*/
static inline int8_t mavlink_msg_attitude_controller_output_get_roll(const mavlink_message_t* msg)
{
return (int8_t)(msg->payload+sizeof(uint8_t))[0];
}
/**
* @brief Get field pitch from attitude_controller_output message
*
* @return Attitude pitch: -128: -100%, 127: +100%
*/
static inline int8_t mavlink_msg_attitude_controller_output_get_pitch(const mavlink_message_t* msg)
{
return (int8_t)(msg->payload+sizeof(uint8_t)+sizeof(int8_t))[0];
}
/**
* @brief Get field yaw from attitude_controller_output message
*
* @return Attitude yaw: -128: -100%, 127: +100%
*/
static inline int8_t mavlink_msg_attitude_controller_output_get_yaw(const mavlink_message_t* msg)
{
return (int8_t)(msg->payload+sizeof(uint8_t)+sizeof(int8_t)+sizeof(int8_t))[0];
}
/**
* @brief Get field thrust from attitude_controller_output message
*
* @return Attitude thrust: -128: -100%, 127: +100%
*/
static inline int8_t mavlink_msg_attitude_controller_output_get_thrust(const mavlink_message_t* msg)
{
return (int8_t)(msg->payload+sizeof(uint8_t)+sizeof(int8_t)+sizeof(int8_t)+sizeof(int8_t))[0];
}
/**
* @brief Decode a attitude_controller_output message into a struct
*
* @param msg The message to decode
* @param attitude_controller_output C-struct to decode the message contents into
*/
static inline void mavlink_msg_attitude_controller_output_decode(const mavlink_message_t* msg, mavlink_attitude_controller_output_t* attitude_controller_output)
{
attitude_controller_output->enabled = mavlink_msg_attitude_controller_output_get_enabled(msg);
attitude_controller_output->roll = mavlink_msg_attitude_controller_output_get_roll(msg);
attitude_controller_output->pitch = mavlink_msg_attitude_controller_output_get_pitch(msg);
attitude_controller_output->yaw = mavlink_msg_attitude_controller_output_get_yaw(msg);
attitude_controller_output->thrust = mavlink_msg_attitude_controller_output_get_thrust(msg);
}
// MESSAGE AUTH_KEY PACKING
#define MAVLINK_MSG_ID_AUTH_KEY 7
typedef struct __mavlink_auth_key_t
{
char key[32]; ///< key
} mavlink_auth_key_t;
#define MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN 32
/**
* @brief Pack a auth_key message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param key key
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_auth_key_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const char* key)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
i += put_array_by_index((const int8_t*)key, sizeof(char)*32, i, msg->payload); // key
return mavlink_finalize_message(msg, system_id, component_id, i);
}
/**
* @brief Pack a auth_key message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message was sent over
* @param msg The MAVLink message to compress the data into
* @param key key
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_auth_key_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const char* key)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
i += put_array_by_index((const int8_t*)key, sizeof(char)*32, i, msg->payload); // key
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
}
/**
* @brief Encode a auth_key struct into a message
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param auth_key C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_auth_key_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_auth_key_t* auth_key)
{
return mavlink_msg_auth_key_pack(system_id, component_id, msg, auth_key->key);
}
/**
* @brief Send a auth_key message
* @param chan MAVLink channel to send the message
*
* @param key key
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_auth_key_send(mavlink_channel_t chan, const char* key)
{
mavlink_message_t msg;
mavlink_msg_auth_key_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, key);
mavlink_send_uart(chan, &msg);
}
#endif
// MESSAGE AUTH_KEY UNPACKING
/**
* @brief Get field key from auth_key message
*
* @return key
*/
static inline uint16_t mavlink_msg_auth_key_get_key(const mavlink_message_t* msg, char* r_data)
{
memcpy(r_data, msg->payload, sizeof(char)*32);
return sizeof(char)*32;
}
/**
* @brief Decode a auth_key message into a struct
*
* @param msg The message to decode
* @param auth_key C-struct to decode the message contents into
*/
static inline void mavlink_msg_auth_key_decode(const mavlink_message_t* msg, mavlink_auth_key_t* auth_key)
{
mavlink_msg_auth_key_get_key(msg, auth_key->key);
}
// MESSAGE BOOT PACKING
#define MAVLINK_MSG_ID_BOOT 1
typedef struct __mavlink_boot_t
{
uint32_t version; ///< The onboard software version
} mavlink_boot_t;
/**
* @brief Pack a boot message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param version The onboard software version
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_boot_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint32_t version)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_BOOT;
i += put_uint32_t_by_index(version, i, msg->payload); // The onboard software version
return mavlink_finalize_message(msg, system_id, component_id, i);
}
/**
* @brief Pack a boot message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message was sent over
* @param msg The MAVLink message to compress the data into
* @param version The onboard software version
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_boot_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint32_t version)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_BOOT;
i += put_uint32_t_by_index(version, i, msg->payload); // The onboard software version
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
}
/**
* @brief Encode a boot struct into a message
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param boot C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_boot_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_boot_t* boot)
{
return mavlink_msg_boot_pack(system_id, component_id, msg, boot->version);
}
/**
* @brief Send a boot message
* @param chan MAVLink channel to send the message
*
* @param version The onboard software version
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_boot_send(mavlink_channel_t chan, uint32_t version)
{
mavlink_message_t msg;
mavlink_msg_boot_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, version);
mavlink_send_uart(chan, &msg);
}
#endif
// MESSAGE BOOT UNPACKING
/**
* @brief Get field version from boot message
*
* @return The onboard software version
*/
static inline uint32_t mavlink_msg_boot_get_version(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload)[0];
r.b[2] = (msg->payload)[1];
r.b[1] = (msg->payload)[2];
r.b[0] = (msg->payload)[3];
return (uint32_t)r.i;
}
/**
* @brief Decode a boot message into a struct
*
* @param msg The message to decode
* @param boot C-struct to decode the message contents into
*/
static inline void mavlink_msg_boot_decode(const mavlink_message_t* msg, mavlink_boot_t* boot)
{
boot->version = mavlink_msg_boot_get_version(msg);
}
// MESSAGE CHANGE_OPERATOR_CONTROL PACKING
#define MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL 5
typedef struct __mavlink_change_operator_control_t
{
uint8_t target_system; ///< System the GCS requests control for
uint8_t control_request; ///< 0: request control of this MAV, 1: Release control of this MAV
uint8_t version; ///< 0: key as plaintext, 1-255: future, different hashing/encryption variants. The GCS should in general use the safest mode possible initially and then gradually move down the encryption level if it gets a NACK message indicating an encryption mismatch.
char passkey[25]; ///< Password / Key, depending on version plaintext or encrypted. 25 or less characters, NULL terminated. The characters may involve A-Z, a-z, 0-9, and "!?,.-"
} mavlink_change_operator_control_t;
#define MAVLINK_MSG_CHANGE_OPERATOR_CONTROL_FIELD_PASSKEY_LEN 25
/**
* @brief Pack a change_operator_control message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param target_system System the GCS requests control for
* @param control_request 0: request control of this MAV, 1: Release control of this MAV
* @param version 0: key as plaintext, 1-255: future, different hashing/encryption variants. The GCS should in general use the safest mode possible initially and then gradually move down the encryption level if it gets a NACK message indicating an encryption mismatch.
* @param passkey Password / Key, depending on version plaintext or encrypted. 25 or less characters, NULL terminated. The characters may involve A-Z, a-z, 0-9, and "!?,.-"
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_change_operator_control_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t target_system, uint8_t control_request, uint8_t version, const char* passkey)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL;
i += put_uint8_t_by_index(target_system, i, msg->payload); // System the GCS requests control for
i += put_uint8_t_by_index(control_request, i, msg->payload); // 0: request control of this MAV, 1: Release control of this MAV
i += put_uint8_t_by_index(version, i, msg->payload); // 0: key as plaintext, 1-255: future, different hashing/encryption variants. The GCS should in general use the safest mode possible initially and then gradually move down the encryption level if it gets a NACK message indicating an encryption mismatch.
i += put_array_by_index((const int8_t*)passkey, sizeof(char)*25, i, msg->payload); // Password / Key, depending on version plaintext or encrypted. 25 or less characters, NULL terminated. The characters may involve A-Z, a-z, 0-9, and "!?,.-"
return mavlink_finalize_message(msg, system_id, component_id, i);
}
/**
* @brief Pack a change_operator_control message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message was sent over
* @param msg The MAVLink message to compress the data into
* @param target_system System the GCS requests control for
* @param control_request 0: request control of this MAV, 1: Release control of this MAV
* @param version 0: key as plaintext, 1-255: future, different hashing/encryption variants. The GCS should in general use the safest mode possible initially and then gradually move down the encryption level if it gets a NACK message indicating an encryption mismatch.
* @param passkey Password / Key, depending on version plaintext or encrypted. 25 or less characters, NULL terminated. The characters may involve A-Z, a-z, 0-9, and "!?,.-"
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_change_operator_control_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t target_system, uint8_t control_request, uint8_t version, const char* passkey)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL;
i += put_uint8_t_by_index(target_system, i, msg->payload); // System the GCS requests control for
i += put_uint8_t_by_index(control_request, i, msg->payload); // 0: request control of this MAV, 1: Release control of this MAV
i += put_uint8_t_by_index(version, i, msg->payload); // 0: key as plaintext, 1-255: future, different hashing/encryption variants. The GCS should in general use the safest mode possible initially and then gradually move down the encryption level if it gets a NACK message indicating an encryption mismatch.
i += put_array_by_index((const int8_t*)passkey, sizeof(char)*25, i, msg->payload); // Password / Key, depending on version plaintext or encrypted. 25 or less characters, NULL terminated. The characters may involve A-Z, a-z, 0-9, and "!?,.-"
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
}
/**
* @brief Encode a change_operator_control struct into a message
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param change_operator_control C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_change_operator_control_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_change_operator_control_t* change_operator_control)
{
return mavlink_msg_change_operator_control_pack(system_id, component_id, msg, change_operator_control->target_system, change_operator_control->control_request, change_operator_control->version, change_operator_control->passkey);
}
/**
* @brief Send a change_operator_control message
* @param chan MAVLink channel to send the message
*
* @param target_system System the GCS requests control for
* @param control_request 0: request control of this MAV, 1: Release control of this MAV
* @param version 0: key as plaintext, 1-255: future, different hashing/encryption variants. The GCS should in general use the safest mode possible initially and then gradually move down the encryption level if it gets a NACK message indicating an encryption mismatch.
* @param passkey Password / Key, depending on version plaintext or encrypted. 25 or less characters, NULL terminated. The characters may involve A-Z, a-z, 0-9, and "!?,.-"
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_change_operator_control_send(mavlink_channel_t chan, uint8_t target_system, uint8_t control_request, uint8_t version, const char* passkey)
{
mavlink_message_t msg;
mavlink_msg_change_operator_control_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, target_system, control_request, version, passkey);
mavlink_send_uart(chan, &msg);
}
#endif
// MESSAGE CHANGE_OPERATOR_CONTROL UNPACKING
/**
* @brief Get field target_system from change_operator_control message
*
* @return System the GCS requests control for
*/
static inline uint8_t mavlink_msg_change_operator_control_get_target_system(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload)[0];
}
/**
* @brief Get field control_request from change_operator_control message
*
* @return 0: request control of this MAV, 1: Release control of this MAV
*/
static inline uint8_t mavlink_msg_change_operator_control_get_control_request(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload+sizeof(uint8_t))[0];
}
/**
* @brief Get field version from change_operator_control message
*
* @return 0: key as plaintext, 1-255: future, different hashing/encryption variants. The GCS should in general use the safest mode possible initially and then gradually move down the encryption level if it gets a NACK message indicating an encryption mismatch.
*/
static inline uint8_t mavlink_msg_change_operator_control_get_version(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t))[0];
}
/**
* @brief Get field passkey from change_operator_control message
*
* @return Password / Key, depending on version plaintext or encrypted. 25 or less characters, NULL terminated. The characters may involve A-Z, a-z, 0-9, and "!?,.-"
*/
static inline uint16_t mavlink_msg_change_operator_control_get_passkey(const mavlink_message_t* msg, char* r_data)
{
memcpy(r_data, msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t), sizeof(char)*25);
return sizeof(char)*25;
}
/**
* @brief Decode a change_operator_control message into a struct
*
* @param msg The message to decode
* @param change_operator_control C-struct to decode the message contents into
*/
static inline void mavlink_msg_change_operator_control_decode(const mavlink_message_t* msg, mavlink_change_operator_control_t* change_operator_control)
{
change_operator_control->target_system = mavlink_msg_change_operator_control_get_target_system(msg);
change_operator_control->control_request = mavlink_msg_change_operator_control_get_control_request(msg);
change_operator_control->version = mavlink_msg_change_operator_control_get_version(msg);
mavlink_msg_change_operator_control_get_passkey(msg, change_operator_control->passkey);
}
// MESSAGE CHANGE_OPERATOR_CONTROL_ACK PACKING
#define MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK 6
typedef struct __mavlink_change_operator_control_ack_t
{
uint8_t gcs_system_id; ///< ID of the GCS this message
uint8_t control_request; ///< 0: request control of this MAV, 1: Release control of this MAV
uint8_t ack; ///< 0: ACK, 1: NACK: Wrong passkey, 2: NACK: Unsupported passkey encryption method, 3: NACK: Already under control
} mavlink_change_operator_control_ack_t;
/**
* @brief Pack a change_operator_control_ack message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param gcs_system_id ID of the GCS this message
* @param control_request 0: request control of this MAV, 1: Release control of this MAV
* @param ack 0: ACK, 1: NACK: Wrong passkey, 2: NACK: Unsupported passkey encryption method, 3: NACK: Already under control
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_change_operator_control_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t gcs_system_id, uint8_t control_request, uint8_t ack)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK;
i += put_uint8_t_by_index(gcs_system_id, i, msg->payload); // ID of the GCS this message
i += put_uint8_t_by_index(control_request, i, msg->payload); // 0: request control of this MAV, 1: Release control of this MAV
i += put_uint8_t_by_index(ack, i, msg->payload); // 0: ACK, 1: NACK: Wrong passkey, 2: NACK: Unsupported passkey encryption method, 3: NACK: Already under control
return mavlink_finalize_message(msg, system_id, component_id, i);
}
/**
* @brief Pack a change_operator_control_ack message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message was sent over
* @param msg The MAVLink message to compress the data into
* @param gcs_system_id ID of the GCS this message
* @param control_request 0: request control of this MAV, 1: Release control of this MAV
* @param ack 0: ACK, 1: NACK: Wrong passkey, 2: NACK: Unsupported passkey encryption method, 3: NACK: Already under control
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_change_operator_control_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t gcs_system_id, uint8_t control_request, uint8_t ack)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK;
i += put_uint8_t_by_index(gcs_system_id, i, msg->payload); // ID of the GCS this message
i += put_uint8_t_by_index(control_request, i, msg->payload); // 0: request control of this MAV, 1: Release control of this MAV
i += put_uint8_t_by_index(ack, i, msg->payload); // 0: ACK, 1: NACK: Wrong passkey, 2: NACK: Unsupported passkey encryption method, 3: NACK: Already under control
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
}
/**
* @brief Encode a change_operator_control_ack struct into a message
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param change_operator_control_ack C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_change_operator_control_ack_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_change_operator_control_ack_t* change_operator_control_ack)
{
return mavlink_msg_change_operator_control_ack_pack(system_id, component_id, msg, change_operator_control_ack->gcs_system_id, change_operator_control_ack->control_request, change_operator_control_ack->ack);
}
/**
* @brief Send a change_operator_control_ack message
* @param chan MAVLink channel to send the message
*
* @param gcs_system_id ID of the GCS this message
* @param control_request 0: request control of this MAV, 1: Release control of this MAV
* @param ack 0: ACK, 1: NACK: Wrong passkey, 2: NACK: Unsupported passkey encryption method, 3: NACK: Already under control
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_change_operator_control_ack_send(mavlink_channel_t chan, uint8_t gcs_system_id, uint8_t control_request, uint8_t ack)
{
mavlink_message_t msg;
mavlink_msg_change_operator_control_ack_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, gcs_system_id, control_request, ack);
mavlink_send_uart(chan, &msg);
}
#endif
// MESSAGE CHANGE_OPERATOR_CONTROL_ACK UNPACKING
/**
* @brief Get field gcs_system_id from change_operator_control_ack message
*
* @return ID of the GCS this message
*/
static inline uint8_t mavlink_msg_change_operator_control_ack_get_gcs_system_id(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload)[0];
}
/**
* @brief Get field control_request from change_operator_control_ack message
*
* @return 0: request control of this MAV, 1: Release control of this MAV
*/
static inline uint8_t mavlink_msg_change_operator_control_ack_get_control_request(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload+sizeof(uint8_t))[0];
}
/**
* @brief Get field ack from change_operator_control_ack message
*
* @return 0: ACK, 1: NACK: Wrong passkey, 2: NACK: Unsupported passkey encryption method, 3: NACK: Already under control
*/
static inline uint8_t mavlink_msg_change_operator_control_ack_get_ack(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t))[0];
}
/**
* @brief Decode a change_operator_control_ack message into a struct
*
* @param msg The message to decode
* @param change_operator_control_ack C-struct to decode the message contents into
*/
static inline void mavlink_msg_change_operator_control_ack_decode(const mavlink_message_t* msg, mavlink_change_operator_control_ack_t* change_operator_control_ack)
{
change_operator_control_ack->gcs_system_id = mavlink_msg_change_operator_control_ack_get_gcs_system_id(msg);
change_operator_control_ack->control_request = mavlink_msg_change_operator_control_ack_get_control_request(msg);
change_operator_control_ack->ack = mavlink_msg_change_operator_control_ack_get_ack(msg);
}
This diff is collapsed.
// MESSAGE COMMAND_ACK PACKING
#define MAVLINK_MSG_ID_COMMAND_ACK 76
typedef struct __mavlink_command_ack_t
{
float command; ///< Current airspeed in m/s
float result; ///< 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION
} mavlink_command_ack_t;
/**
* @brief Pack a command_ack message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param command Current airspeed in m/s
* @param result 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_command_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, float command, float result)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
i += put_float_by_index(command, i, msg->payload); // Current airspeed in m/s
i += put_float_by_index(result, i, msg->payload); // 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION
return mavlink_finalize_message(msg, system_id, component_id, i);
}
/**
* @brief Pack a command_ack message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message was sent over
* @param msg The MAVLink message to compress the data into
* @param command Current airspeed in m/s
* @param result 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_command_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, float command, float result)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
i += put_float_by_index(command, i, msg->payload); // Current airspeed in m/s
i += put_float_by_index(result, i, msg->payload); // 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
}
/**
* @brief Encode a command_ack struct into a message
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param command_ack C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_command_ack_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_command_ack_t* command_ack)
{
return mavlink_msg_command_ack_pack(system_id, component_id, msg, command_ack->command, command_ack->result);
}
/**
* @brief Send a command_ack message
* @param chan MAVLink channel to send the message
*
* @param command Current airspeed in m/s
* @param result 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_command_ack_send(mavlink_channel_t chan, float command, float result)
{
mavlink_message_t msg;
mavlink_msg_command_ack_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, command, result);
mavlink_send_uart(chan, &msg);
}
#endif
// MESSAGE COMMAND_ACK UNPACKING
/**
* @brief Get field command from command_ack message
*
* @return Current airspeed in m/s
*/
static inline float mavlink_msg_command_ack_get_command(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload)[0];
r.b[2] = (msg->payload)[1];
r.b[1] = (msg->payload)[2];
r.b[0] = (msg->payload)[3];
return (float)r.f;
}
/**
* @brief Get field result from command_ack message
*
* @return 1: Action ACCEPTED and EXECUTED, 1: Action TEMPORARY REJECTED/DENIED, 2: Action PERMANENTLY DENIED, 3: Action UNKNOWN/UNSUPPORTED, 4: Requesting CONFIRMATION
*/
static inline float mavlink_msg_command_ack_get_result(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload+sizeof(float))[0];
r.b[2] = (msg->payload+sizeof(float))[1];
r.b[1] = (msg->payload+sizeof(float))[2];
r.b[0] = (msg->payload+sizeof(float))[3];
return (float)r.f;
}
/**
* @brief Decode a command_ack message into a struct
*
* @param msg The message to decode
* @param command_ack C-struct to decode the message contents into
*/
static inline void mavlink_msg_command_ack_decode(const mavlink_message_t* msg, mavlink_command_ack_t* command_ack)
{
command_ack->command = mavlink_msg_command_ack_get_command(msg);
command_ack->result = mavlink_msg_command_ack_get_result(msg);
}
This diff is collapsed.
// MESSAGE DEBUG PACKING
#define MAVLINK_MSG_ID_DEBUG 255
typedef struct __mavlink_debug_t
{
uint8_t ind; ///< index of debug variable
float value; ///< DEBUG value
} mavlink_debug_t;
/**
* @brief Pack a debug message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param ind index of debug variable
* @param value DEBUG value
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_debug_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t ind, float value)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_DEBUG;
i += put_uint8_t_by_index(ind, i, msg->payload); // index of debug variable
i += put_float_by_index(value, i, msg->payload); // DEBUG value
return mavlink_finalize_message(msg, system_id, component_id, i);
}
/**
* @brief Pack a debug message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message was sent over
* @param msg The MAVLink message to compress the data into
* @param ind index of debug variable
* @param value DEBUG value
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_debug_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t ind, float value)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_DEBUG;
i += put_uint8_t_by_index(ind, i, msg->payload); // index of debug variable
i += put_float_by_index(value, i, msg->payload); // DEBUG value
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
}
/**
* @brief Encode a debug struct into a message
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param debug C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_debug_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_debug_t* debug)
{
return mavlink_msg_debug_pack(system_id, component_id, msg, debug->ind, debug->value);
}
/**
* @brief Send a debug message
* @param chan MAVLink channel to send the message
*
* @param ind index of debug variable
* @param value DEBUG value
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_debug_send(mavlink_channel_t chan, uint8_t ind, float value)
{
mavlink_message_t msg;
mavlink_msg_debug_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, ind, value);
mavlink_send_uart(chan, &msg);
}
#endif
// MESSAGE DEBUG UNPACKING
/**
* @brief Get field ind from debug message
*
* @return index of debug variable
*/
static inline uint8_t mavlink_msg_debug_get_ind(const mavlink_message_t* msg)
{
return (uint8_t)(msg->payload)[0];
}
/**
* @brief Get field value from debug message
*
* @return DEBUG value
*/
static inline float mavlink_msg_debug_get_value(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload+sizeof(uint8_t))[0];
r.b[2] = (msg->payload+sizeof(uint8_t))[1];
r.b[1] = (msg->payload+sizeof(uint8_t))[2];
r.b[0] = (msg->payload+sizeof(uint8_t))[3];
return (float)r.f;
}
/**
* @brief Decode a debug message into a struct
*
* @param msg The message to decode
* @param debug C-struct to decode the message contents into
*/
static inline void mavlink_msg_debug_decode(const mavlink_message_t* msg, mavlink_debug_t* debug)
{
debug->ind = mavlink_msg_debug_get_ind(msg);
debug->value = mavlink_msg_debug_get_value(msg);
}
// MESSAGE DEBUG_VECT PACKING
#define MAVLINK_MSG_ID_DEBUG_VECT 251
typedef struct __mavlink_debug_vect_t
{
char name[10]; ///< Name
uint64_t usec; ///< Timestamp
float x; ///< x
float y; ///< y
float z; ///< z
} mavlink_debug_vect_t;
#define MAVLINK_MSG_DEBUG_VECT_FIELD_NAME_LEN 10
/**
* @brief Pack a debug_vect message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param name Name
* @param usec Timestamp
* @param x x
* @param y y
* @param z z
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_debug_vect_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const char* name, uint64_t usec, float x, float y, float z)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_DEBUG_VECT;
i += put_array_by_index((const int8_t*)name, sizeof(char)*10, i, msg->payload); // Name
i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp
i += put_float_by_index(x, i, msg->payload); // x
i += put_float_by_index(y, i, msg->payload); // y
i += put_float_by_index(z, i, msg->payload); // z
return mavlink_finalize_message(msg, system_id, component_id, i);
}
/**
* @brief Pack a debug_vect message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message was sent over
* @param msg The MAVLink message to compress the data into
* @param name Name
* @param usec Timestamp
* @param x x
* @param y y
* @param z z
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_debug_vect_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const char* name, uint64_t usec, float x, float y, float z)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_DEBUG_VECT;
i += put_array_by_index((const int8_t*)name, sizeof(char)*10, i, msg->payload); // Name
i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp
i += put_float_by_index(x, i, msg->payload); // x
i += put_float_by_index(y, i, msg->payload); // y
i += put_float_by_index(z, i, msg->payload); // z
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
}
/**
* @brief Encode a debug_vect struct into a message
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param debug_vect C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_debug_vect_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_debug_vect_t* debug_vect)
{
return mavlink_msg_debug_vect_pack(system_id, component_id, msg, debug_vect->name, debug_vect->usec, debug_vect->x, debug_vect->y, debug_vect->z);
}
/**
* @brief Send a debug_vect message
* @param chan MAVLink channel to send the message
*
* @param name Name
* @param usec Timestamp
* @param x x
* @param y y
* @param z z
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_debug_vect_send(mavlink_channel_t chan, const char* name, uint64_t usec, float x, float y, float z)
{
mavlink_message_t msg;
mavlink_msg_debug_vect_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, name, usec, x, y, z);
mavlink_send_uart(chan, &msg);
}
#endif
// MESSAGE DEBUG_VECT UNPACKING
/**
* @brief Get field name from debug_vect message
*
* @return Name
*/
static inline uint16_t mavlink_msg_debug_vect_get_name(const mavlink_message_t* msg, char* r_data)
{
memcpy(r_data, msg->payload, sizeof(char)*10);
return sizeof(char)*10;
}
/**
* @brief Get field usec from debug_vect message
*
* @return Timestamp
*/
static inline uint64_t mavlink_msg_debug_vect_get_usec(const mavlink_message_t* msg)
{
generic_64bit r;
r.b[7] = (msg->payload+sizeof(char)*10)[0];
r.b[6] = (msg->payload+sizeof(char)*10)[1];
r.b[5] = (msg->payload+sizeof(char)*10)[2];
r.b[4] = (msg->payload+sizeof(char)*10)[3];
r.b[3] = (msg->payload+sizeof(char)*10)[4];
r.b[2] = (msg->payload+sizeof(char)*10)[5];
r.b[1] = (msg->payload+sizeof(char)*10)[6];
r.b[0] = (msg->payload+sizeof(char)*10)[7];
return (uint64_t)r.ll;
}
/**
* @brief Get field x from debug_vect message
*
* @return x
*/
static inline float mavlink_msg_debug_vect_get_x(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload+sizeof(char)*10+sizeof(uint64_t))[0];
r.b[2] = (msg->payload+sizeof(char)*10+sizeof(uint64_t))[1];
r.b[1] = (msg->payload+sizeof(char)*10+sizeof(uint64_t))[2];
r.b[0] = (msg->payload+sizeof(char)*10+sizeof(uint64_t))[3];
return (float)r.f;
}
/**
* @brief Get field y from debug_vect message
*
* @return y
*/
static inline float mavlink_msg_debug_vect_get_y(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float))[0];
r.b[2] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float))[1];
r.b[1] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float))[2];
r.b[0] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float))[3];
return (float)r.f;
}
/**
* @brief Get field z from debug_vect message
*
* @return z
*/
static inline float mavlink_msg_debug_vect_get_z(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float)+sizeof(float))[0];
r.b[2] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float)+sizeof(float))[1];
r.b[1] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float)+sizeof(float))[2];
r.b[0] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float)+sizeof(float))[3];
return (float)r.f;
}
/**
* @brief Decode a debug_vect message into a struct
*
* @param msg The message to decode
* @param debug_vect C-struct to decode the message contents into
*/
static inline void mavlink_msg_debug_vect_decode(const mavlink_message_t* msg, mavlink_debug_vect_t* debug_vect)
{
mavlink_msg_debug_vect_get_name(msg, debug_vect->name);
debug_vect->usec = mavlink_msg_debug_vect_get_usec(msg);
debug_vect->x = mavlink_msg_debug_vect_get_x(msg);
debug_vect->y = mavlink_msg_debug_vect_get_y(msg);
debug_vect->z = mavlink_msg_debug_vect_get_z(msg);
}
// MESSAGE GPS_LOCAL_ORIGIN_SET PACKING
#define MAVLINK_MSG_ID_GPS_LOCAL_ORIGIN_SET 49
typedef struct __mavlink_gps_local_origin_set_t
{
int32_t latitude; ///< Latitude (WGS84), expressed as * 1E7
int32_t longitude; ///< Longitude (WGS84), expressed as * 1E7
int32_t altitude; ///< Altitude(WGS84), expressed as * 1000
} mavlink_gps_local_origin_set_t;
/**
* @brief Pack a gps_local_origin_set message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param latitude Latitude (WGS84), expressed as * 1E7
* @param longitude Longitude (WGS84), expressed as * 1E7
* @param altitude Altitude(WGS84), expressed as * 1000
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_gps_local_origin_set_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, int32_t latitude, int32_t longitude, int32_t altitude)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_GPS_LOCAL_ORIGIN_SET;
i += put_int32_t_by_index(latitude, i, msg->payload); // Latitude (WGS84), expressed as * 1E7
i += put_int32_t_by_index(longitude, i, msg->payload); // Longitude (WGS84), expressed as * 1E7
i += put_int32_t_by_index(altitude, i, msg->payload); // Altitude(WGS84), expressed as * 1000
return mavlink_finalize_message(msg, system_id, component_id, i);
}
/**
* @brief Pack a gps_local_origin_set message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message was sent over
* @param msg The MAVLink message to compress the data into
* @param latitude Latitude (WGS84), expressed as * 1E7
* @param longitude Longitude (WGS84), expressed as * 1E7
* @param altitude Altitude(WGS84), expressed as * 1000
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_gps_local_origin_set_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, int32_t latitude, int32_t longitude, int32_t altitude)
{
uint16_t i = 0;
msg->msgid = MAVLINK_MSG_ID_GPS_LOCAL_ORIGIN_SET;
i += put_int32_t_by_index(latitude, i, msg->payload); // Latitude (WGS84), expressed as * 1E7
i += put_int32_t_by_index(longitude, i, msg->payload); // Longitude (WGS84), expressed as * 1E7
i += put_int32_t_by_index(altitude, i, msg->payload); // Altitude(WGS84), expressed as * 1000
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
}
/**
* @brief Encode a gps_local_origin_set struct into a message
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param gps_local_origin_set C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_gps_local_origin_set_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_gps_local_origin_set_t* gps_local_origin_set)
{
return mavlink_msg_gps_local_origin_set_pack(system_id, component_id, msg, gps_local_origin_set->latitude, gps_local_origin_set->longitude, gps_local_origin_set->altitude);
}
/**
* @brief Send a gps_local_origin_set message
* @param chan MAVLink channel to send the message
*
* @param latitude Latitude (WGS84), expressed as * 1E7
* @param longitude Longitude (WGS84), expressed as * 1E7
* @param altitude Altitude(WGS84), expressed as * 1000
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_gps_local_origin_set_send(mavlink_channel_t chan, int32_t latitude, int32_t longitude, int32_t altitude)
{
mavlink_message_t msg;
mavlink_msg_gps_local_origin_set_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, latitude, longitude, altitude);
mavlink_send_uart(chan, &msg);
}
#endif
// MESSAGE GPS_LOCAL_ORIGIN_SET UNPACKING
/**
* @brief Get field latitude from gps_local_origin_set message
*
* @return Latitude (WGS84), expressed as * 1E7
*/
static inline int32_t mavlink_msg_gps_local_origin_set_get_latitude(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload)[0];
r.b[2] = (msg->payload)[1];
r.b[1] = (msg->payload)[2];
r.b[0] = (msg->payload)[3];
return (int32_t)r.i;
}
/**
* @brief Get field longitude from gps_local_origin_set message
*
* @return Longitude (WGS84), expressed as * 1E7
*/
static inline int32_t mavlink_msg_gps_local_origin_set_get_longitude(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload+sizeof(int32_t))[0];
r.b[2] = (msg->payload+sizeof(int32_t))[1];
r.b[1] = (msg->payload+sizeof(int32_t))[2];
r.b[0] = (msg->payload+sizeof(int32_t))[3];
return (int32_t)r.i;
}
/**
* @brief Get field altitude from gps_local_origin_set message
*
* @return Altitude(WGS84), expressed as * 1000
*/
static inline int32_t mavlink_msg_gps_local_origin_set_get_altitude(const mavlink_message_t* msg)
{
generic_32bit r;
r.b[3] = (msg->payload+sizeof(int32_t)+sizeof(int32_t))[0];
r.b[2] = (msg->payload+sizeof(int32_t)+sizeof(int32_t))[1];
r.b[1] = (msg->payload+sizeof(int32_t)+sizeof(int32_t))[2];
r.b[0] = (msg->payload+sizeof(int32_t)+sizeof(int32_t))[3];
return (int32_t)r.i;
}
/**
* @brief Decode a gps_local_origin_set message into a struct
*
* @param msg The message to decode
* @param gps_local_origin_set C-struct to decode the message contents into
*/
static inline void mavlink_msg_gps_local_origin_set_decode(const mavlink_message_t* msg, mavlink_gps_local_origin_set_t* gps_local_origin_set)
{
gps_local_origin_set->latitude = mavlink_msg_gps_local_origin_set_get_latitude(msg);
gps_local_origin_set->longitude = mavlink_msg_gps_local_origin_set_get_longitude(msg);
gps_local_origin_set->altitude = mavlink_msg_gps_local_origin_set_get_altitude(msg);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/** @file
* @brief MAVLink comm protocol.
* @see http://pixhawk.ethz.ch/software/mavlink
* Generated on Thursday, March 31 2011, 22:06 UTC
*/
#ifndef MAVLINK_H
#define MAVLINK_H
#include "pixhawk.h"
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
qserial @ 004e3de5
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment