├── Libraries
├── AP_Math
│ ├── examples
│ │ ├── polygon
│ │ │ ├── Makefile
│ │ │ └── polygon.pde
│ │ ├── eulers
│ │ │ └── Makefile
│ │ └── rotations
│ │ │ └── Makefile
│ ├── vector2.h
│ ├── vector3.h
│ ├── keywords.txt
│ ├── polygon.h
│ ├── AP_Math.h
│ ├── quaternion.h
│ ├── rotations.h
│ ├── AP_Math.cpp
│ ├── quaternion.cpp
│ ├── polygon.cpp
│ ├── vector3.cpp
│ └── matrix3.h
├── FastSerial
│ ├── examples
│ │ └── FastSerial
│ │ │ ├── Makefile
│ │ │ └── FastSerial.pde
│ ├── keywords.txt
│ ├── BetterStream.h
│ ├── BetterStream.cpp
│ ├── ftoa_engine.h
│ ├── xtoa_fast.h
│ ├── ntz.h
│ └── ultoa_invert.S
├── AP_Common
│ ├── keywords.txt
│ ├── c++.h
│ ├── AP_Var_menufuncs.cpp
│ ├── AP_Common.cpp
│ ├── examples
│ │ └── menu
│ │ │ └── menu.pde
│ ├── tools
│ │ ├── eedump.pl
│ │ ├── eedump_apparam.pl
│ │ ├── eedump.c
│ │ └── eedump_apparam.c
│ ├── AP_MetaClass.cpp
│ ├── AP_Loop.cpp
│ ├── AP_Loop.h
│ ├── c++.cpp
│ ├── AP_Test.h
│ ├── menu.cpp
│ └── include
│ │ └── menu.h
├── flexitimer2
│ ├── keywords.txt
│ ├── FlexiTimer2.h
│ └── examples
│ │ └── FlashLed
│ │ └── FlashLed.pde
└── GCS_MAVLink
│ ├── include
│ └── mavlink
│ │ ├── v0.9
│ │ ├── common
│ │ │ ├── version.h
│ │ │ ├── mavlink.h
│ │ │ ├── mavlink_msg_boot.h
│ │ │ ├── mavlink_msg_auth_key.h
│ │ │ ├── mavlink_msg_waypoint_current.h
│ │ │ ├── mavlink_msg_waypoint_reached.h
│ │ │ ├── mavlink_msg_system_time.h
│ │ │ ├── mavlink_msg_debug.h
│ │ │ ├── mavlink_msg_set_mode.h
│ │ │ ├── mavlink_msg_action_ack.h
│ │ │ ├── mavlink_msg_set_altitude.h
│ │ │ ├── mavlink_msg_set_nav_mode.h
│ │ │ └── mavlink_msg_system_time_utc.h
│ │ ├── ardupilotmega
│ │ │ ├── version.h
│ │ │ ├── mavlink.h
│ │ │ ├── mavlink_msg_meminfo.h
│ │ │ └── mavlink_msg_hwstatus.h
│ │ └── checksum.h
│ │ └── v1.0
│ │ ├── common
│ │ ├── version.h
│ │ ├── mavlink.h
│ │ ├── mavlink_msg_auth_key.h
│ │ ├── mavlink_msg_mission_current.h
│ │ ├── mavlink_msg_mission_item_reached.h
│ │ └── mavlink_msg_command_ack.h
│ │ ├── ardupilotmega
│ │ ├── version.h
│ │ ├── mavlink.h
│ │ ├── mavlink_msg_meminfo.h
│ │ └── mavlink_msg_hwstatus.h
│ │ └── checksum.h
│ ├── message_definitions
│ ├── matrixpilot.xml
│ ├── test.xml
│ ├── ualberta.xml
│ └── sensesoar.xml
│ ├── generate.sh
│ ├── GCS_MAVLink.cpp
│ └── GCS_MAVLink.h
├── APM_UART0_to_D4R.jpg
├── APM_UART2_to_D4R.jpg
├── APM_Mavlink_to_FrSky
├── FrSky.h
├── FrSky.cpp
├── Mavlink.h
├── defines.h
├── Mavlink.cpp
├── SimpleTelemetry.h
├── IFrSkyDataProvider.h
├── SimpleTelemetry.cpp
├── APM_Mavlink_to_FrSky.ino
├── FrSkySPort.h
├── Aserial.h
├── FrSkySPort.cpp
└── SimpleFIFO.h
├── protocol_sensor_hub_2_185500178.pdf
├── README.md
└── Protocol.txt
/Libraries/AP_Math/examples/polygon/Makefile:
--------------------------------------------------------------------------------
1 | include ../../../AP_Common/Arduino.mk
2 |
--------------------------------------------------------------------------------
/APM_UART0_to_D4R.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/APM_UART0_to_D4R.jpg
--------------------------------------------------------------------------------
/APM_UART2_to_D4R.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/APM_UART2_to_D4R.jpg
--------------------------------------------------------------------------------
/Libraries/FastSerial/examples/FastSerial/Makefile:
--------------------------------------------------------------------------------
1 | BOARD = mega
2 | include ../../../AP_Common/Arduino.mk
3 |
--------------------------------------------------------------------------------
/Libraries/AP_Common/keywords.txt:
--------------------------------------------------------------------------------
1 | Menu KEYWORD1
2 | run KEYWORD2
3 | Location KEYWORD2
4 |
5 |
--------------------------------------------------------------------------------
/Libraries/flexitimer2/keywords.txt:
--------------------------------------------------------------------------------
1 | FlexiTimer2 KEYWORD1
2 | set KEYWORD2
3 | start KEYWORD2
4 | stop KEYWORD2
5 |
--------------------------------------------------------------------------------
/APM_Mavlink_to_FrSky/FrSky.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/APM_Mavlink_to_FrSky/FrSky.h
--------------------------------------------------------------------------------
/Libraries/AP_Math/vector2.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/Libraries/AP_Math/vector2.h
--------------------------------------------------------------------------------
/Libraries/AP_Math/vector3.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/Libraries/AP_Math/vector3.h
--------------------------------------------------------------------------------
/APM_Mavlink_to_FrSky/FrSky.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/APM_Mavlink_to_FrSky/FrSky.cpp
--------------------------------------------------------------------------------
/APM_Mavlink_to_FrSky/Mavlink.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/APM_Mavlink_to_FrSky/Mavlink.h
--------------------------------------------------------------------------------
/APM_Mavlink_to_FrSky/defines.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/APM_Mavlink_to_FrSky/defines.h
--------------------------------------------------------------------------------
/APM_Mavlink_to_FrSky/Mavlink.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/APM_Mavlink_to_FrSky/Mavlink.cpp
--------------------------------------------------------------------------------
/Libraries/AP_Common/c++.h:
--------------------------------------------------------------------------------
1 | #ifndef CPP_H
2 | #define CPP_H
3 |
4 | void displayMemory();
5 | int freeMemory();
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/protocol_sensor_hub_2_185500178.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/protocol_sensor_hub_2_185500178.pdf
--------------------------------------------------------------------------------
/APM_Mavlink_to_FrSky/SimpleTelemetry.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/APM_Mavlink_to_FrSky/SimpleTelemetry.h
--------------------------------------------------------------------------------
/APM_Mavlink_to_FrSky/IFrSkyDataProvider.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/APM_Mavlink_to_FrSky/IFrSkyDataProvider.h
--------------------------------------------------------------------------------
/APM_Mavlink_to_FrSky/SimpleTelemetry.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/APM_Mavlink_to_FrSky/SimpleTelemetry.cpp
--------------------------------------------------------------------------------
/Libraries/AP_Math/examples/eulers/Makefile:
--------------------------------------------------------------------------------
1 | include ../../../AP_Common/Arduino.mk
2 |
3 | sitl:
4 | make -f ../../../../libraries/Desktop/Desktop.mk
5 |
--------------------------------------------------------------------------------
/APM_Mavlink_to_FrSky/APM_Mavlink_to_FrSky.ino:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vizual54/APM-Mavlink-to-FrSky/HEAD/APM_Mavlink_to_FrSky/APM_Mavlink_to_FrSky.ino
--------------------------------------------------------------------------------
/Libraries/AP_Math/examples/rotations/Makefile:
--------------------------------------------------------------------------------
1 | include ../../../AP_Common/Arduino.mk
2 |
3 | sitl:
4 | make -f ../../../../libraries/Desktop/Desktop.mk
5 |
--------------------------------------------------------------------------------
/Libraries/FastSerial/keywords.txt:
--------------------------------------------------------------------------------
1 | FastSerial KEYWORD1
2 | begin KEYWORD2
3 | end KEYWORD2
4 | available KEYWORD2
5 | read KEYWORD2
6 | flush KEYWORD2
7 | write KEYWORD2
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | APM-Mavlink-to-FrSky
2 | =============================
3 | Code for reading Mavlink data from the uart2 serial port of the APM2+ with a Arduino pro mini
4 | and convert to FrSky telemetry protocol.
5 |
6 | See project homepage http://vizual54.github.io/APM-Mavlink-to-FrSky/ for information on how to connect the arduino to the APM and to the FrSky RX.
7 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/common/version.h:
--------------------------------------------------------------------------------
1 | /** @file
2 | * @brief MAVLink comm protocol built from common.xml
3 | * @see http://pixhawk.ethz.ch/software/mavlink
4 | */
5 | #ifndef MAVLINK_VERSION_H
6 | #define MAVLINK_VERSION_H
7 |
8 | #define MAVLINK_BUILD_DATE "Fri Jul 20 11:32:17 2012"
9 | #define MAVLINK_WIRE_PROTOCOL_VERSION "0.9"
10 | #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 101
11 |
12 | #endif // MAVLINK_VERSION_H
13 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v1.0/common/version.h:
--------------------------------------------------------------------------------
1 | /** @file
2 | * @brief MAVLink comm protocol built from common.xml
3 | * @see http://pixhawk.ethz.ch/software/mavlink
4 | */
5 | #ifndef MAVLINK_VERSION_H
6 | #define MAVLINK_VERSION_H
7 |
8 | #define MAVLINK_BUILD_DATE "Sat Aug 11 14:26:42 2012"
9 | #define MAVLINK_WIRE_PROTOCOL_VERSION "1.0"
10 | #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 101
11 |
12 | #endif // MAVLINK_VERSION_H
13 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/ardupilotmega/version.h:
--------------------------------------------------------------------------------
1 | /** @file
2 | * @brief MAVLink comm protocol built from ardupilotmega.xml
3 | * @see http://pixhawk.ethz.ch/software/mavlink
4 | */
5 | #ifndef MAVLINK_VERSION_H
6 | #define MAVLINK_VERSION_H
7 |
8 | #define MAVLINK_BUILD_DATE "Fri Jul 20 11:32:17 2012"
9 | #define MAVLINK_WIRE_PROTOCOL_VERSION "0.9"
10 | #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 101
11 |
12 | #endif // MAVLINK_VERSION_H
13 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v1.0/ardupilotmega/version.h:
--------------------------------------------------------------------------------
1 | /** @file
2 | * @brief MAVLink comm protocol built from ardupilotmega.xml
3 | * @see http://pixhawk.ethz.ch/software/mavlink
4 | */
5 | #ifndef MAVLINK_VERSION_H
6 | #define MAVLINK_VERSION_H
7 |
8 | #define MAVLINK_BUILD_DATE "Sat Aug 11 14:26:42 2012"
9 | #define MAVLINK_WIRE_PROTOCOL_VERSION "1.0"
10 | #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 101
11 |
12 | #endif // MAVLINK_VERSION_H
13 |
--------------------------------------------------------------------------------
/APM_Mavlink_to_FrSky/FrSkySPort.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef FRSKYSPORT_h
3 | #define FRSKYSPORT_h
4 |
5 | #include "Arduino.h"
6 | #include "IFrSkyDataProvider.h"
7 |
8 | class FrSkySPort
9 | {
10 | public:
11 | FrSkySPort(uint8_t pinTx);
12 | void setup();
13 | bool timeToSend();
14 | void sendData(IFrSkyDataProvider* dataProvider);
15 |
16 | private:
17 | uint8_t _pinTx;
18 | void sendValue(uint16_t id, uint32_t value) ;
19 | };
20 |
21 | #endif
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/message_definitions/matrixpilot.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | common.xml
4 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Libraries/AP_Common/AP_Var_menufuncs.cpp:
--------------------------------------------------------------------------------
1 | // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
2 | //
3 | // This is free software; you can redistribute it and/or modify it under
4 | // the terms of the GNU Lesser General Public License as published by the
5 | // Free Software Foundation; either version 2.1 of the License, or (at
6 | // your option) any later version.
7 | //
8 |
9 | /// @file AP_Var_menufuncs.cpp
10 | /// @brief Useful functions compatible with the menu system for
11 | /// managing AP_Var variables.
12 |
13 | #include
14 | #include
15 |
16 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/common/mavlink.h:
--------------------------------------------------------------------------------
1 | /** @file
2 | * @brief MAVLink comm protocol built from common.xml
3 | * @see http://pixhawk.ethz.ch/software/mavlink
4 | */
5 | #ifndef MAVLINK_H
6 | #define MAVLINK_H
7 |
8 | #ifndef MAVLINK_STX
9 | #define MAVLINK_STX 85
10 | #endif
11 |
12 | #ifndef MAVLINK_ENDIAN
13 | #define MAVLINK_ENDIAN MAVLINK_BIG_ENDIAN
14 | #endif
15 |
16 | #ifndef MAVLINK_ALIGNED_FIELDS
17 | #define MAVLINK_ALIGNED_FIELDS 0
18 | #endif
19 |
20 | #ifndef MAVLINK_CRC_EXTRA
21 | #define MAVLINK_CRC_EXTRA 0
22 | #endif
23 |
24 | #include "version.h"
25 | #include "common.h"
26 |
27 | #endif // MAVLINK_H
28 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v1.0/common/mavlink.h:
--------------------------------------------------------------------------------
1 | /** @file
2 | * @brief MAVLink comm protocol built from common.xml
3 | * @see http://pixhawk.ethz.ch/software/mavlink
4 | */
5 | #ifndef MAVLINK_H
6 | #define MAVLINK_H
7 |
8 | #ifndef MAVLINK_STX
9 | #define MAVLINK_STX 254
10 | #endif
11 |
12 | #ifndef MAVLINK_ENDIAN
13 | #define MAVLINK_ENDIAN MAVLINK_LITTLE_ENDIAN
14 | #endif
15 |
16 | #ifndef MAVLINK_ALIGNED_FIELDS
17 | #define MAVLINK_ALIGNED_FIELDS 1
18 | #endif
19 |
20 | #ifndef MAVLINK_CRC_EXTRA
21 | #define MAVLINK_CRC_EXTRA 1
22 | #endif
23 |
24 | #include "version.h"
25 | #include "common.h"
26 |
27 | #endif // MAVLINK_H
28 |
--------------------------------------------------------------------------------
/Libraries/flexitimer2/FlexiTimer2.h:
--------------------------------------------------------------------------------
1 | #ifndef FlexiTimer2_h
2 | #define FlexiTimer2_h
3 |
4 | #ifdef __AVR__
5 | #include
6 | #else
7 | #error FlexiTimer2 library only works on AVR architecture
8 | #endif
9 |
10 |
11 | namespace FlexiTimer2 {
12 | extern unsigned long time_units;
13 | extern void (*func)();
14 | extern volatile unsigned long count;
15 | extern volatile char overflowing;
16 | extern volatile unsigned int tcnt2;
17 |
18 | void set(unsigned long ms, void (*f)());
19 | void set(unsigned long units, double resolution, void (*f)());
20 | void start();
21 | void stop();
22 | void _overflow();
23 | }
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/ardupilotmega/mavlink.h:
--------------------------------------------------------------------------------
1 | /** @file
2 | * @brief MAVLink comm protocol built from ardupilotmega.xml
3 | * @see http://pixhawk.ethz.ch/software/mavlink
4 | */
5 | #ifndef MAVLINK_H
6 | #define MAVLINK_H
7 |
8 | #ifndef MAVLINK_STX
9 | #define MAVLINK_STX 85
10 | #endif
11 |
12 | #ifndef MAVLINK_ENDIAN
13 | #define MAVLINK_ENDIAN MAVLINK_BIG_ENDIAN
14 | #endif
15 |
16 | #ifndef MAVLINK_ALIGNED_FIELDS
17 | #define MAVLINK_ALIGNED_FIELDS 0
18 | #endif
19 |
20 | #ifndef MAVLINK_CRC_EXTRA
21 | #define MAVLINK_CRC_EXTRA 0
22 | #endif
23 |
24 | #include "version.h"
25 | #include "ardupilotmega.h"
26 |
27 | #endif // MAVLINK_H
28 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v1.0/ardupilotmega/mavlink.h:
--------------------------------------------------------------------------------
1 | /** @file
2 | * @brief MAVLink comm protocol built from ardupilotmega.xml
3 | * @see http://pixhawk.ethz.ch/software/mavlink
4 | */
5 | #ifndef MAVLINK_H
6 | #define MAVLINK_H
7 |
8 | #ifndef MAVLINK_STX
9 | #define MAVLINK_STX 254
10 | #endif
11 |
12 | #ifndef MAVLINK_ENDIAN
13 | #define MAVLINK_ENDIAN MAVLINK_LITTLE_ENDIAN
14 | #endif
15 |
16 | #ifndef MAVLINK_ALIGNED_FIELDS
17 | #define MAVLINK_ALIGNED_FIELDS 1
18 | #endif
19 |
20 | #ifndef MAVLINK_CRC_EXTRA
21 | #define MAVLINK_CRC_EXTRA 1
22 | #endif
23 |
24 | #include "version.h"
25 | #include "ardupilotmega.h"
26 |
27 | #endif // MAVLINK_H
28 |
--------------------------------------------------------------------------------
/Libraries/AP_Common/AP_Common.cpp:
--------------------------------------------------------------------------------
1 | // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
2 | //
3 | // This is free software; you can redistribute it and/or modify it under
4 | // the terms of the GNU Lesser General Public License as published by the
5 | // Free Software Foundation; either version 2.1 of the License, or (at
6 | // your option) any later version.
7 | //
8 |
9 | /// @file AP_Common.cpp
10 | /// @brief Common utility routines for the ArduPilot libraries.
11 | ///
12 | /// @note Exercise restraint adding code here; everything in this
13 | /// library will be linked with any sketch using it.
14 | ///
15 |
16 | #include "AP_Common.h"
17 |
18 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/generate.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # script to re-generate mavlink C code for APM
3 |
4 | mavdir="$(dirname $0)"
5 | dname="$(basename $mavdir)"
6 | [ "$dname" = "GCS_MAVLink" ] || {
7 | echo "This script should be run from the libraries/GCS_MAVLink directory"
8 | exit 1
9 | }
10 |
11 | if ! which mavgen.py > /dev/null; then
12 | echo "mavgen.py must be in your PATH. Get it from http://github.com/mavlink/mavlink in the pymavlink/generator directory"
13 | exit 1
14 | fi
15 |
16 | echo "Removing old includes"
17 | rm -rf "$mavdir/include/*"
18 |
19 | echo "Generating C code"
20 | mavgen.py --lang=C --wire-protocol=1.0 --output=$mavdir/include/mavlink/v1.0 $mavdir/message_definitions/ardupilotmega.xml
21 |
--------------------------------------------------------------------------------
/Libraries/AP_Math/keywords.txt:
--------------------------------------------------------------------------------
1 | Vector2 KEYWORD1
2 | Vector2i KEYWORD1
3 | Vector2ui KEYWORD1
4 | Vector2l KEYWORD1
5 | Vector2ul KEYWORD1
6 | Vector2f KEYWORD1
7 | Vector3 KEYWORD1
8 | Vector3i KEYWORD1
9 | Vector3ui KEYWORD1
10 | Vector3l KEYWORD1
11 | Vector3ul KEYWORD1
12 | Vector3f KEYWORD1
13 | Matrix3 KEYWORD1
14 | Matrix3i KEYWORD1
15 | Matrix3ui KEYWORD1
16 | Matrix3l KEYWORD1
17 | Matrix3ul KEYWORD1
18 | Matrix3f KEYWORD1
19 | length_squared KEYWORD2
20 | length KEYWORD2
21 | normalize KEYWORD2
22 | normalized KEYWORD2
23 | reflect KEYWORD2
24 | project KEYWORD2
25 | projected KEYWORD2
26 | angle KEYWORD2
27 | angle_normalized KEYWORD2
28 | rotate KEYWORD2
29 | rotated KEYWORD2
30 |
--------------------------------------------------------------------------------
/Libraries/AP_Common/examples/menu/menu.pde:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 |
5 | FastSerialPort0(Serial);
6 |
7 | int8_t
8 | menu_test(uint8_t argc, const Menu::arg *argv)
9 | {
10 | int i;
11 |
12 | Serial.printf("This is a test with %d arguments\n", argc);
13 | for (i = 1; i < argc; i++) {
14 | Serial.printf("%d: int %ld float ", i, argv[i].i);
15 | Serial.println(argv[i].f, 6); // gross
16 | }
17 | }
18 |
19 | int8_t
20 | menu_auto(uint8_t argc, const Menu::arg *argv)
21 | {
22 | Serial.println("auto text");
23 | }
24 |
25 | const struct Menu::command top_menu_commands[] PROGMEM = {
26 | {"*", menu_auto},
27 | {"test", menu_test},
28 | };
29 |
30 | MENU(top, "menu", top_menu_commands);
31 |
32 | void
33 | setup(void)
34 | {
35 | Serial.begin(38400);
36 | top.run();
37 | }
38 |
39 | void
40 | loop(void)
41 | {
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/Libraries/AP_Common/tools/eedump.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 |
3 |
4 | $file = $ARGV[0];
5 |
6 |
7 | open(IN,$file) || die print "Failed to open file: $file : $!";
8 |
9 | read(IN,$buffer,1);
10 | read(IN,$buffer2,1);
11 | if (ord($buffer) != 0x41 && ord($buffer2) != 0x50) {
12 | print "bad header ". $buffer ." ".$buffer2. "\n";
13 | exit;
14 | }
15 | read(IN,$buffer,1);
16 | if (ord($buffer) != 2) {
17 | print "bad version";
18 | exit;
19 | }
20 |
21 | # spare
22 | read(IN,$buffer,1);
23 |
24 | $a = 0;
25 |
26 | while (read(IN,$buffer,1)) {
27 | $pos = (tell(IN) - 1);
28 |
29 | $size = ((ord($buffer) & 63));
30 |
31 | read(IN,$buffer,1);
32 |
33 | if (ord($buffer) == 0xff) {
34 | printf("end sentinel at %u\n", $pos);
35 | last;
36 | }
37 |
38 | printf("%04x: key %u size %d\n ", $pos, ord($buffer), $size + 1);
39 |
40 | for ($i = 0; $i <= ($size); $i++) {
41 | read(IN,$buffer,1);
42 | printf(" %02x", ord($buffer));
43 | }
44 | print "\n";
45 | }
46 |
47 | close IN;
--------------------------------------------------------------------------------
/APM_Mavlink_to_FrSky/Aserial.h:
--------------------------------------------------------------------------------
1 | /* ============================================================
2 | * This program is free software; you can redistribute it and/or modify
3 | * it under the terms of the GNU General Public License version 2 as
4 | * published by the Free Software Foundation.
5 | *
6 | * This program is distributed in the hope that it will be useful,
7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 | * GNU General Public License for more details.
10 | *
11 | * ============================================================*/
12 |
13 | // Author: Mike Blandford
14 |
15 | struct t_sportData
16 | {
17 | struct t_sportData *next ;
18 | uint8_t data[7] ;
19 | uint8_t dataLock ;
20 | uint8_t serialSent ;
21 | } ;
22 |
23 | void setNewData( struct t_sportData *pdata, uint16_t id, uint32_t value ) ;
24 | void initSportUart( struct t_sportData *pdata ) ;
25 |
26 | extern uint8_t DataSent;
--------------------------------------------------------------------------------
/Libraries/AP_Math/polygon.h:
--------------------------------------------------------------------------------
1 | /// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
2 | /*
3 | * polygon.h
4 | * Copyright (C) Andrew Tridgell 2011
5 | *
6 | * This file is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by the
8 | * Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This file is distributed in the hope that it will be useful, but
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 | * See the GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along
17 | * with this program. If not, see .
18 | */
19 |
20 | bool Polygon_outside(const Vector2l &P, const Vector2l *V, unsigned n);
21 | bool Polygon_complete(const Vector2l *V, unsigned n);
22 |
23 |
--------------------------------------------------------------------------------
/Libraries/AP_Math/AP_Math.h:
--------------------------------------------------------------------------------
1 | // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
2 |
3 | #ifndef AP_MATH_H
4 | #define AP_MATH_H
5 |
6 | // Assorted useful math operations for ArduPilot(Mega)
7 |
8 | #include
9 | #include
10 | #include "rotations.h"
11 | #include "vector2.h"
12 | #include "vector3.h"
13 | #include "matrix3.h"
14 | #include "quaternion.h"
15 | #include "polygon.h"
16 |
17 | // define AP_Param types AP_Vector3f and Ap_Matrix3f
18 | AP_PARAMDEFV(Matrix3f, Matrix3f, AP_PARAM_MATRIX3F);
19 | AP_PARAMDEFV(Vector3f, Vector3f, AP_PARAM_VECTOR3F);
20 |
21 | // a varient of asin() that always gives a valid answer.
22 | float safe_asin(float v);
23 |
24 | // a varient of sqrt() that always gives a valid answer.
25 | float safe_sqrt(float v);
26 |
27 | // find a rotation that is the combination of two other
28 | // rotations. This is used to allow us to add an overall board
29 | // rotation to an existing rotation of a sensor such as the compass
30 | enum Rotation rotation_combination(enum Rotation r1, enum Rotation r2, bool *found = NULL);
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/APM_Mavlink_to_FrSky/FrSkySPort.cpp:
--------------------------------------------------------------------------------
1 | #include "FrSkySPort.h"
2 | #include "Arduino.h"
3 | #include "HardwareSerial.h"
4 | #include "Aserial.h"
5 |
6 |
7 | struct t_sportData MyData[2] ;
8 |
9 |
10 | FrSkySPort::FrSkySPort(uint8_t pinTx)
11 | {
12 |
13 | }
14 |
15 | // **************** Setup the FRSky OutputLib *********************
16 | void FrSkySPort::setup()
17 | {
18 | MyData[0].next = &MyData[1] ;
19 | initSportUart( &MyData[0] ) ;
20 | }
21 |
22 | #define ALT_ID 0x0100
23 | #define VARIO_ID 0x0110
24 |
25 | void FrSkySPort::sendValue(uint16_t id, uint32_t value)
26 | {
27 | if ( id == ALT_ID )
28 | {
29 | setNewData( &MyData[0], id, value ) ;
30 | }
31 | else
32 | {
33 | setNewData( &MyData[1], id, value ) ;
34 | }
35 | }
36 |
37 | void FrSkySPort::sendData(IFrSkyDataProvider* dataProvider)
38 | {
39 | static uint8_t counter ;
40 | switch ( counter)
41 | {
42 | case 0 :
43 | sendValue(VARIO_ID, dataProvider->getTemp1());
44 | break;
45 |
46 | case 1 :
47 | sendValue(ALT_ID, dataProvider->getAltitude());
48 | break;
49 | }
50 | counter = (counter + 1) & 1 ;
51 | }
--------------------------------------------------------------------------------
/Libraries/AP_Common/AP_MetaClass.cpp:
--------------------------------------------------------------------------------
1 | // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
2 | //
3 | // This is free software; you can redistribute it and/or modify it under
4 | // the terms of the GNU Lesser General Public License as published by the
5 | // Free Software Foundation; either version 2.1 of the License, or (at
6 | // your option) any later version.
7 | //
8 |
9 | /// @file AP_MetaClass.cpp
10 | /// Abstract meta-class from which other AP classes may inherit.
11 | /// Provides type introspection and some basic protocols that can
12 | /// be implemented by subclasses.
13 |
14 | #include "AP_MetaClass.h"
15 |
16 | // Default ctor, currently does nothing
17 | AP_Meta_class::AP_Meta_class(void)
18 | {
19 | }
20 |
21 | // Default dtor, currently does nothing but must be defined in order to ensure that
22 | // subclasses not overloading the default virtual dtor still have something in their
23 | // vtable.
24 | AP_Meta_class::~AP_Meta_class()
25 | {
26 | }
27 |
28 | size_t AP_Meta_class::serialize(void *buf, size_t bufSize) const
29 | {
30 | return 0;
31 | }
32 |
33 | size_t AP_Meta_class::unserialize(void *buf, size_t bufSize)
34 | {
35 | return 0;
36 | }
37 |
--------------------------------------------------------------------------------
/Libraries/FastSerial/BetterStream.h:
--------------------------------------------------------------------------------
1 | // -*- Mode: C++; c-basic-offset: 8; indent-tabs-mode: nil -*-
2 | //
3 | // Copyright (c) 2010 Michael Smith. All rights reserved.
4 | //
5 | // This is free software; you can redistribute it and/or modify it under
6 | // the terms of the GNU Lesser General Public License as published by the
7 | // Free Software Foundation; either version 2.1 of the License, or (at
8 | // your option) any later version.
9 | //
10 |
11 | #ifndef __BETTERSTREAM_H
12 | #define __BETTERSTREAM_H
13 |
14 | #include
15 | #include
16 | #include "../AP_Common/AP_Common.h"
17 |
18 | class BetterStream : public Stream {
19 | public:
20 | BetterStream(void) {
21 | }
22 |
23 | // Stream extensions
24 | void print_P(const prog_char_t *);
25 | void println_P(const prog_char_t *);
26 | void printf(const char *, ...)
27 | __attribute__ ((format(__printf__, 2, 3)));
28 | void _printf_P(const prog_char *, ...);
29 | __attribute__ ((format(__printf__, 2, 3)));
30 |
31 | virtual int txspace(void);
32 |
33 | #define printf_P(fmt, ...) _printf_P((const prog_char *)fmt, ## __VA_ARGS__)
34 |
35 | private:
36 | void _vprintf(unsigned char, const char *, va_list)
37 | __attribute__ ((format(__printf__, 3, 0)));
38 | };
39 |
40 | #endif // __BETTERSTREAM_H
41 |
42 |
--------------------------------------------------------------------------------
/Libraries/flexitimer2/examples/FlashLed/FlashLed.pde:
--------------------------------------------------------------------------------
1 | char dummyvar; // to get Arduinoi IDE to include core headers properly
2 |
3 | /*
4 | FlexiTimer2:
5 | Arduino library to use timer 2 with a configurable resolution.
6 | Based on MsTimer2 by Javier Valencia. It is called FlexiTimer2 because it
7 | is based on MsTimer2, but offers more flexibility,
8 | since it has a configurable timer resolution.
9 | MsTimer2 library: http://www.arduino.cc/playground/Main/MsTimer2
10 |
11 | For more details on FlexiTimer2 see:
12 | http://www.arduino.cc/playground/Main/FlexiTimer2
13 | https://github.com/wimleers/flexitimer2
14 |
15 | */
16 |
17 | #include
18 |
19 | // Switch on LED on and off each half second
20 |
21 | #if defined(ARDUINO) && ARDUINO >= 100
22 | const int led_pin = LED_BUILTIN; // 1.0 built in LED pin var
23 | #else
24 | #if defined(CORE_LED0_PIN)
25 | const int led_pin = CORE_LED0_PIN; // 3rd party LED pin define
26 | #else
27 | const int led_pin = 13; // default to pin 13
28 | #endif
29 | #endif
30 |
31 | void flash()
32 | {
33 | static boolean output = HIGH;
34 |
35 | digitalWrite(led_pin, output);
36 | output = !output;
37 | }
38 |
39 | void setup()
40 | {
41 | pinMode(led_pin, OUTPUT);
42 |
43 | FlexiTimer2::set(500, 1.0/1000, flash); // call every 500 1ms "ticks"
44 | // FlexiTimer2::set(500, flash); // MsTimer2 style is also supported
45 | FlexiTimer2::start();
46 | }
47 |
48 | void loop()
49 | {
50 | }
51 |
--------------------------------------------------------------------------------
/Libraries/FastSerial/BetterStream.cpp:
--------------------------------------------------------------------------------
1 | // -*- Mode: C++; c-basic-offset: 8; indent-tabs-mode: nil -*-
2 | //
3 | // Copyright (c) 2010 Michael Smith. All rights reserved.
4 | //
5 | // This is free software; you can redistribute it and/or modify it under
6 | // the terms of the GNU Lesser General Public License as published by the
7 | // Free Software Foundation; either version 2.1 of the License, or (at
8 | // your option) any later version.
9 | //
10 |
11 | //
12 | // Enhancements to the Arduino Stream class.
13 | //
14 |
15 | #include
16 | #include "BetterStream.h"
17 |
18 | // Stream extensions////////////////////////////////////////////////////////////
19 |
20 | void
21 | BetterStream::print_P(const prog_char_t *s)
22 | {
23 | char c;
24 |
25 | while ('\0' != (c = pgm_read_byte((const prog_char *)s++)))
26 | write(c);
27 | }
28 |
29 | void
30 | BetterStream::println_P(const prog_char_t *s)
31 | {
32 | print_P(s);
33 | println();
34 | }
35 |
36 | void
37 | BetterStream::printf(const char *fmt, ...)
38 | {
39 | va_list ap;
40 |
41 | va_start(ap, fmt);
42 | _vprintf(0, fmt, ap);
43 | va_end(ap);
44 | }
45 |
46 | void
47 | BetterStream::_printf_P(const prog_char *fmt, ...)
48 | {
49 | va_list ap;
50 |
51 | va_start(ap, fmt);
52 | _vprintf(1, fmt, ap);
53 | va_end(ap);
54 | }
55 |
56 | int
57 | BetterStream::txspace(void)
58 | {
59 | // by default claim that there is always space in transmit buffer
60 | return(INT_MAX);
61 | }
62 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/GCS_MAVLink.cpp:
--------------------------------------------------------------------------------
1 | // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
2 |
3 | /// @file GCS_MAVLink.cpp
4 |
5 | /*
6 | This provides some support code and variables for MAVLink enabled sketches
7 |
8 | This firmware is free software; you can redistribute it and/or
9 | modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation; either
11 | version 2.1 of the License, or (at your option) any later version.
12 | */
13 |
14 | #include
15 | #include
16 | #include
17 |
18 |
19 | BetterStream *mavlink_comm_0_port;
20 | BetterStream *mavlink_comm_1_port;
21 |
22 | mavlink_system_t mavlink_system = {12,1,0,0}; //modified
23 |
24 | uint8_t mavlink_check_target(uint8_t sysid, uint8_t compid)
25 | {
26 | if (sysid != mavlink_system.sysid)
27 | return 1;
28 | // Currently we are not checking for correct compid since APM is not passing mavlink info to any subsystem
29 | // If it is addressed to our system ID we assume it is for us
30 | return 0; // no error
31 | }
32 |
33 | // return a MAVLink variable type given a AP_Param type
34 | uint8_t mav_var_type(enum ap_var_type t)
35 | {
36 | if (t == AP_PARAM_INT8) {
37 | return MAVLINK_TYPE_INT8_T;
38 | }
39 | if (t == AP_PARAM_INT16) {
40 | return MAVLINK_TYPE_INT16_T;
41 | }
42 | if (t == AP_PARAM_INT32) {
43 | return MAVLINK_TYPE_INT32_T;
44 | }
45 | // treat any others as float
46 | return MAVLINK_TYPE_FLOAT;
47 | }
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Libraries/AP_Math/quaternion.h:
--------------------------------------------------------------------------------
1 | // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
2 |
3 | // Copyright 2012 Andrew Tridgell, all rights reserved.
4 |
5 | // This library is free software; you can redistribute it and / or
6 | // modify it under the terms of the GNU Lesser General Public
7 | // License as published by the Free Software Foundation; either
8 | // version 2.1 of the License, or (at your option) any later version.
9 |
10 | #ifndef QUATERNION_H
11 | #define QUATERNION_H
12 |
13 | #include
14 |
15 | class Quaternion
16 | {
17 | public:
18 | float q1, q2, q3, q4;
19 |
20 | // constructor creates a quaternion equivalent
21 | // to roll=0, pitch=0, yaw=0
22 | Quaternion() { q1 = 1; q2 = q3 = q4 = 0; }
23 |
24 | // setting constructor
25 | Quaternion(const float _q1, const float _q2, const float _q3, const float _q4):
26 | q1(_q1), q2(_q2), q3(_q3), q4(_q4) {}
27 |
28 | // function call operator
29 | void operator ()(const float _q1, const float _q2, const float _q3, const float _q4)
30 | { q1 = _q1; q2 = _q2; q3 = _q3; q4 = _q4; }
31 |
32 | // check if any elements are NAN
33 | bool is_nan(void)
34 | { return isnan(q1) || isnan(q2) || isnan(q3) || isnan(q4); }
35 |
36 | // return the rotation matrix equivalent for this quaternion
37 | void rotation_matrix(Matrix3f &m);
38 |
39 | // convert a vector from earth to body frame
40 | void earth_to_body(Vector3f &v);
41 |
42 | // create a quaternion from Euler angles
43 | void from_euler(float roll, float pitch, float yaw);
44 |
45 | // create eulers from a quaternion
46 | void to_euler(float *roll, float *pitch, float *yaw);
47 | };
48 | #endif // QUATERNION_H
49 |
--------------------------------------------------------------------------------
/Libraries/AP_Common/AP_Loop.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * AP_Loop.pde
3 | * Copyright (C) James Goppert 2010
4 | *
5 | * This file is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the
7 | * Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This file is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along
16 | * with this program. If not, see .
17 | */
18 |
19 | #include "AP_Loop.h"
20 |
21 | Loop::Loop(float _frequency, void (*fptr)(void *), void * data) :
22 | _fptr(fptr),
23 | _data(data),
24 | _period(1.0e6/_frequency),
25 | _subLoops(),
26 | _timeStamp(micros()),
27 | _load(0),
28 | _dt(0)
29 | {
30 | }
31 |
32 | void Loop::update()
33 | {
34 | // quick exit if not ready
35 | if (micros() - _timeStamp < _period) return;
36 |
37 | // update time stamp
38 | uint32_t timeStamp0 = _timeStamp;
39 | _timeStamp = micros();
40 | _dt = (_timeStamp - timeStamp0)/1.0e6;
41 |
42 | // update sub loops
43 | for (uint8_t i=0; i<_subLoops.getSize(); i++) _subLoops[i]->update();
44 |
45 | // callback function
46 | if (_fptr) _fptr(_data);
47 |
48 | // calculated load with a low pass filter
49 | _load = 0.9*_load + 10*(float(micros()-_timeStamp)/(_timeStamp-timeStamp0));
50 | }
51 |
52 | // vim:ts=4:sw=4:expandtab
53 |
--------------------------------------------------------------------------------
/Libraries/AP_Math/rotations.h:
--------------------------------------------------------------------------------
1 | /// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
2 | /*
3 | * rotations.h
4 | * Copyright (C) Andrew Tridgell 2012
5 | *
6 | * This file is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by the
8 | * Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This file is distributed in the hope that it will be useful, but
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 | * See the GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along
17 | * with this program. If not, see .
18 | */
19 |
20 |
21 | // these rotations form a full set - every rotation in the following
22 | // list when combined with another in the list forms an entry which is
23 | // also in the list. This is an important property. Please run the
24 | // rotations test suite if you add to the list.
25 |
26 | // these rotation values are stored to EEPROM, so be careful not to
27 | // change the numbering of any existing entry when adding a new entry.
28 | enum Rotation {
29 | ROTATION_NONE = 0,
30 | ROTATION_YAW_45,
31 | ROTATION_YAW_90,
32 | ROTATION_YAW_135,
33 | ROTATION_YAW_180,
34 | ROTATION_YAW_225,
35 | ROTATION_YAW_270,
36 | ROTATION_YAW_315,
37 | ROTATION_ROLL_180,
38 | ROTATION_ROLL_180_YAW_45,
39 | ROTATION_ROLL_180_YAW_90,
40 | ROTATION_ROLL_180_YAW_135,
41 | ROTATION_PITCH_180,
42 | ROTATION_ROLL_180_YAW_225,
43 | ROTATION_ROLL_180_YAW_270,
44 | ROTATION_ROLL_180_YAW_315,
45 | ROTATION_MAX
46 | };
47 |
--------------------------------------------------------------------------------
/Libraries/AP_Common/AP_Loop.h:
--------------------------------------------------------------------------------
1 | /*
2 | * AP_Loop.h
3 | * Copyright (C) James Goppert 2010
4 | *
5 | * This file is free software: you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License as published by the
7 | * Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This file is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License along
16 | * with this program. If not, see .
17 | */
18 |
19 | #ifndef AP_Loop_H
20 | #define AP_Loop_H
21 |
22 | #include "AP_Vector.h"
23 |
24 | class Loop
25 | {
26 | public:
27 | Loop() : _fptr(), _data(), _period(), _subLoops(), _timeStamp(), _load(), _dt() {};
28 | Loop(float frequency, void (*fptr)(void *) = NULL, void * data = NULL);
29 | void update();
30 | Vector & subLoops() {
31 | return _subLoops;
32 | }
33 | float frequency() {
34 | return 1.0e6/_period;
35 | }
36 | void frequency(float _frequency) {
37 | _period = 1e6/_frequency;
38 | }
39 | uint32_t timeStamp() {
40 | return _timeStamp;
41 | }
42 | float dt() {
43 | return _dt;
44 | }
45 | uint8_t load() {
46 | return _load;
47 | }
48 | protected:
49 | void (*_fptr)(void *);
50 | void * _data;
51 | uint32_t _period;
52 | Vector _subLoops;
53 | uint32_t _timeStamp;
54 | uint8_t _load;
55 | float _dt;
56 | };
57 |
58 | #endif
59 |
60 | // vim:ts=4:sw=4:expandtab
61 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/message_definitions/test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 3
4 |
5 |
6 | Test all field types
7 | char
8 | string
9 | uint8_t
10 | uint16_t
11 | uint32_t
12 | uint64_t
13 | int8_t
14 | int16_t
15 | int32_t
16 | int64_t
17 | float
18 | double
19 | uint8_t_array
20 | uint16_t_array
21 | uint32_t_array
22 | uint64_t_array
23 | int8_t_array
24 | int16_t_array
25 | int32_t_array
26 | int64_t_array
27 | float_array
28 | double_array
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Libraries/FastSerial/examples/FastSerial/FastSerial.pde:
--------------------------------------------------------------------------------
1 | // -*- Mode: C++; c-basic-offset: 8; indent-tabs-mode: nil -*-
2 |
3 | //
4 | // Example code for the FastSerial driver.
5 | //
6 | // This code is placed into the public domain.
7 | //
8 |
9 | //
10 | // Include the FastSerial library header.
11 | //
12 | // Note that this causes the standard Arduino Serial* driver to be
13 | // disabled.
14 | //
15 | #include
16 |
17 | #undef PROGMEM
18 | #define PROGMEM __attribute__(( section(".progmem.data") ))
19 |
20 | # undef PSTR
21 | # define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); \
22 | (prog_char_t *)&__c[0];}))
23 |
24 | //
25 | // Create a FastSerial driver that looks just like the stock Arduino
26 | // driver.
27 | //
28 | FastSerialPort0(Serial);
29 |
30 | //
31 | // To create a driver for a different serial port, on a board that
32 | // supports more than one, use the appropriate macro:
33 | //
34 | //FastSerialPort2(Serial2);
35 |
36 |
37 | void setup(void)
38 | {
39 | //
40 | // Set the speed for our replacement serial port.
41 | //
42 | Serial.begin(115200);
43 |
44 | //
45 | // Test printing things
46 | //
47 | Serial.print("test");
48 | Serial.println(" begin");
49 | Serial.println(1000);
50 | Serial.println(1000, 8);
51 | Serial.println(1000, 10);
52 | Serial.println(1000, 16);
53 | Serial.println_P(PSTR("progmem"));
54 | Serial.printf("printf %d %u %#x %p %f %S\n", -1000, 1000, 1000, 1000, 1.2345, PSTR("progmem"));
55 | Serial.printf_P(PSTR("printf_P %d %u %#x %p %f %S\n"), -1000, 1000, 1000, 1000, 1.2345, PSTR("progmem"));
56 | Serial.println("done");
57 | }
58 |
59 | void
60 | loop(void)
61 | {
62 | int c;
63 |
64 | //
65 | // Perform a simple loopback operation.
66 | //
67 | c = Serial.read();
68 | if (-1 != c)
69 | Serial.write(c);
70 | }
71 |
72 |
--------------------------------------------------------------------------------
/Libraries/AP_Math/AP_Math.cpp:
--------------------------------------------------------------------------------
1 | #include "AP_Math.h"
2 |
3 | // a varient of asin() that checks the input ranges and ensures a
4 | // valid angle as output. If nan is given as input then zero is
5 | // returned.
6 | float safe_asin(float v)
7 | {
8 | if (isnan(v)) {
9 | return 0.0;
10 | }
11 | if (v >= 1.0) {
12 | return PI/2;
13 | }
14 | if (v <= -1.0) {
15 | return -PI/2;
16 | }
17 | return asin(v);
18 | }
19 |
20 | // a varient of sqrt() that checks the input ranges and ensures a
21 | // valid value as output. If a negative number is given then 0 is
22 | // returned. The reasoning is that a negative number for sqrt() in our
23 | // code is usually caused by small numerical rounding errors, so the
24 | // real input should have been zero
25 | float safe_sqrt(float v)
26 | {
27 | float ret = sqrt(v);
28 | if (isnan(ret)) {
29 | return 0;
30 | }
31 | return ret;
32 | }
33 |
34 |
35 | // find a rotation that is the combination of two other
36 | // rotations. This is used to allow us to add an overall board
37 | // rotation to an existing rotation of a sensor such as the compass
38 | // Note that this relies the set of rotations being complete. The
39 | // optional 'found' parameter is for the test suite to ensure that it is.
40 | enum Rotation rotation_combination(enum Rotation r1, enum Rotation r2, bool *found)
41 | {
42 | Vector3f tv1, tv2;
43 | enum Rotation r;
44 | tv1(1,2,3);
45 | tv1.rotate(r1);
46 | tv1.rotate(r2);
47 |
48 | for (r=ROTATION_NONE; r
11 | #include "c++.h"
12 | #if defined(ARDUINO) && ARDUINO >= 100
13 | #include "Arduino.h"
14 | #else
15 | #include "WProgram.h"
16 | #endif
17 |
18 | void * operator new(size_t size)
19 | {
20 | #ifdef AP_DISPLAYMEM
21 | displayMemory();
22 | #endif
23 | return(calloc(size, 1));
24 | }
25 |
26 | void operator delete(void *p)
27 | {
28 | if (p) free(p);
29 | }
30 |
31 | extern "C" void __cxa_pure_virtual()
32 | {
33 | while (1)
34 | {
35 | Serial.println("Error: pure virtual call");
36 | delay(1000);
37 | }
38 | }
39 |
40 | void * operator new[](size_t size)
41 | {
42 | #ifdef AP_DISPLAYMEM
43 | displayMemory();
44 | #endif
45 | return(calloc(size, 1));
46 | }
47 |
48 | void operator delete[](void * ptr)
49 | {
50 | if (ptr) free(ptr);
51 | }
52 |
53 | __extension__ typedef int __guard __attribute__((mode (__DI__)));
54 |
55 | int __cxa_guard_acquire(__guard *g)
56 | {
57 | return !*(char *)(g);
58 | };
59 |
60 | void __cxa_guard_release (__guard *g)
61 | {
62 | *(char *)g = 1;
63 | };
64 |
65 | void __cxa_guard_abort (__guard *) {};
66 |
67 | // free memory
68 | extern unsigned int __bss_end;
69 | extern void *__brkval;
70 |
71 | void displayMemory()
72 | {
73 | static int minMemFree=0;
74 | if (minMemFree<=0 || freeMemory()
5 | #include
6 | #include
7 |
8 | uint8_t eeprom[0x1000];
9 |
10 | #pragma pack(1)
11 |
12 | struct EEPROM_header {
13 | uint16_t magic;
14 | uint8_t revision;
15 | uint8_t spare;
16 | };
17 |
18 | static const uint16_t k_EEPROM_magic = 0x5041;
19 | static const uint16_t k_EEPROM_revision = 2;
20 |
21 | struct Var_header {
22 | uint8_t size:6;
23 | uint8_t spare:2;
24 | uint8_t key;
25 | };
26 |
27 | static const uint8_t k_key_sentinel = 0xff;
28 |
29 | void
30 | fail(const char *why)
31 | {
32 | fprintf(stderr, "ERROR: %s\n", why);
33 | exit(1);
34 | }
35 |
36 | int
37 | main(int argc, char *argv[])
38 | {
39 | FILE *fp;
40 | struct EEPROM_header *header;
41 | struct Var_header *var;
42 | unsigned index;
43 | unsigned i;
44 |
45 | if (argc != 2) {
46 | fail("missing EEPROM file name");
47 | }
48 | if (NULL == (fp = fopen(argv[1], "rb"))) {
49 | fail("can't open EEPROM file");
50 | }
51 | if (1 != fread(eeprom, sizeof(eeprom), 1, fp)) {
52 | fail("can't read EEPROM file");
53 | }
54 | fclose(fp);
55 |
56 | header = (struct EEPROM_header *)&eeprom[0];
57 | if (header->magic != k_EEPROM_magic) {
58 | fail("bad magic in EEPROM file");
59 | }
60 | if (header->revision != 2) {
61 | fail("unsupported EEPROM format revision");
62 | }
63 | printf("Header OK\n");
64 |
65 | index = sizeof(*header);
66 | for (;;) {
67 | var = (struct Var_header *)&eeprom[index];
68 | if (var->key == k_key_sentinel) {
69 | printf("end sentinel at %u\n", index);
70 | break;
71 | }
72 | printf("%04x: key %u size %d\n ", index, var->key, var->size + 1);
73 | index += sizeof(*var);
74 | for (i = 0; i <= var->size; i++) {
75 | printf(" %02x", eeprom[index + i]);
76 | }
77 | printf("\n");
78 | index += var->size + 1;
79 | if (index >= sizeof(eeprom)) {
80 | fflush(stdout);
81 | fail("missing end sentinel");
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/Libraries/FastSerial/ftoa_engine.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2005, Dmitry Xmelkov
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in
11 | the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of the copyright holders nor the names of
14 | contributors may be used to endorse or promote products derived
15 | from this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 | POSSIBILITY OF SUCH DAMAGE. */
28 |
29 | /* $Id: ftoa_engine.h 1218 2007-02-18 13:18:41Z dmix $ */
30 |
31 | #ifndef _FTOA_ENGINE_H
32 | #define _FTOA_ENGINE_H
33 |
34 | #ifndef __ASSEMBLER__
35 |
36 | int __ftoa_engine (double val, char *buf,
37 | unsigned char prec, unsigned char maxdgs);
38 |
39 | #endif
40 |
41 | /* '__ftoa_engine' return next flags (in buf[0]): */
42 | #define FTOA_MINUS 1
43 | #define FTOA_ZERO 2
44 | #define FTOA_INF 4
45 | #define FTOA_NAN 8
46 | #define FTOA_CARRY 16 /* Carry was to master position. */
47 |
48 | #endif /* !_FTOA_ENGINE_H */
49 |
--------------------------------------------------------------------------------
/Libraries/FastSerial/xtoa_fast.h:
--------------------------------------------------------------------------------
1 | /*
2 | Adapted from avr-libc:
3 |
4 | Copyright (c) 2005, Dmitry Xmelkov
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are met:
9 |
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in
14 | the documentation and/or other materials provided with the
15 | distribution.
16 | * Neither the name of the copyright holders nor the names of
17 | contributors may be used to endorse or promote products derived
18 | from this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 | POSSIBILITY OF SUCH DAMAGE. */
31 |
32 | /* $Id: xtoa_fast.h 1223 2007-02-18 13:33:09Z dmix $ */
33 |
34 | #ifndef _XTOA_FAST_H_
35 | #define _XTOA_FAST_H_
36 |
37 | #ifndef __ASSEMBLER__
38 |
39 | /* Internal function for use from `printf'. */
40 | char * __ultoa_invert (unsigned long val, char *s, int base);
41 |
42 | #endif /* ifndef __ASSEMBLER__ */
43 |
44 | /* Next flags are to use with `base'. Unused fields are reserved. */
45 | #define XTOA_PREFIX 0x0100 /* put prefix for octal or hex */
46 | #define XTOA_UPPER 0x0200 /* use upper case letters */
47 |
48 | #endif /* _XTOA_FAST_H_ */
49 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/checksum.h:
--------------------------------------------------------------------------------
1 | #ifdef __cplusplus
2 | extern "C" {
3 | #endif
4 |
5 | #ifndef _CHECKSUM_H_
6 | #define _CHECKSUM_H_
7 |
8 |
9 | /**
10 | *
11 | * CALCULATE THE CHECKSUM
12 | *
13 | */
14 |
15 | #define X25_INIT_CRC 0xffff
16 | #define X25_VALIDATE_CRC 0xf0b8
17 |
18 | /**
19 | * @brief Accumulate the X.25 CRC by adding one char at a time.
20 | *
21 | * The checksum function adds the hash of one char at a time to the
22 | * 16 bit checksum (uint16_t).
23 | *
24 | * @param data new char to hash
25 | * @param crcAccum the already accumulated checksum
26 | **/
27 | static inline void crc_accumulate(uint8_t data, uint16_t *crcAccum)
28 | {
29 | /*Accumulate one byte of data into the CRC*/
30 | uint8_t tmp;
31 |
32 | tmp = data ^ (uint8_t)(*crcAccum &0xff);
33 | tmp ^= (tmp<<4);
34 | *crcAccum = (*crcAccum>>8) ^ (tmp<<8) ^ (tmp <<3) ^ (tmp>>4);
35 | }
36 |
37 | /**
38 | * @brief Initiliaze the buffer for the X.25 CRC
39 | *
40 | * @param crcAccum the 16 bit X.25 CRC
41 | */
42 | static inline void crc_init(uint16_t* crcAccum)
43 | {
44 | *crcAccum = X25_INIT_CRC;
45 | }
46 |
47 |
48 | /**
49 | * @brief Calculates the X.25 checksum on a byte buffer
50 | *
51 | * @param pBuffer buffer containing the byte array to hash
52 | * @param length length of the byte array
53 | * @return the checksum over the buffer bytes
54 | **/
55 | static inline uint16_t crc_calculate(const uint8_t* pBuffer, uint16_t length)
56 | {
57 | uint16_t crcTmp;
58 | crc_init(&crcTmp);
59 | while (length--) {
60 | crc_accumulate(*pBuffer++, &crcTmp);
61 | }
62 | return crcTmp;
63 | }
64 |
65 | /**
66 | * @brief Accumulate the X.25 CRC by adding an array of bytes
67 | *
68 | * The checksum function adds the hash of one char at a time to the
69 | * 16 bit checksum (uint16_t).
70 | *
71 | * @param data new bytes to hash
72 | * @param crcAccum the already accumulated checksum
73 | **/
74 | static inline void crc_accumulate_buffer(uint16_t *crcAccum, const char *pBuffer, uint8_t length)
75 | {
76 | const uint8_t *p = (const uint8_t *)pBuffer;
77 | while (length--) {
78 | crc_accumulate(*p++, crcAccum);
79 | }
80 | }
81 |
82 |
83 |
84 |
85 | #endif /* _CHECKSUM_H_ */
86 |
87 | #ifdef __cplusplus
88 | }
89 | #endif
90 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v1.0/checksum.h:
--------------------------------------------------------------------------------
1 | #ifdef __cplusplus
2 | extern "C" {
3 | #endif
4 |
5 | #ifndef _CHECKSUM_H_
6 | #define _CHECKSUM_H_
7 |
8 |
9 | /**
10 | *
11 | * CALCULATE THE CHECKSUM
12 | *
13 | */
14 |
15 | #define X25_INIT_CRC 0xffff
16 | #define X25_VALIDATE_CRC 0xf0b8
17 |
18 | /**
19 | * @brief Accumulate the X.25 CRC by adding one char at a time.
20 | *
21 | * The checksum function adds the hash of one char at a time to the
22 | * 16 bit checksum (uint16_t).
23 | *
24 | * @param data new char to hash
25 | * @param crcAccum the already accumulated checksum
26 | **/
27 | static inline void crc_accumulate(uint8_t data, uint16_t *crcAccum)
28 | {
29 | /*Accumulate one byte of data into the CRC*/
30 | uint8_t tmp;
31 |
32 | tmp = data ^ (uint8_t)(*crcAccum &0xff);
33 | tmp ^= (tmp<<4);
34 | *crcAccum = (*crcAccum>>8) ^ (tmp<<8) ^ (tmp <<3) ^ (tmp>>4);
35 | }
36 |
37 | /**
38 | * @brief Initiliaze the buffer for the X.25 CRC
39 | *
40 | * @param crcAccum the 16 bit X.25 CRC
41 | */
42 | static inline void crc_init(uint16_t* crcAccum)
43 | {
44 | *crcAccum = X25_INIT_CRC;
45 | }
46 |
47 |
48 | /**
49 | * @brief Calculates the X.25 checksum on a byte buffer
50 | *
51 | * @param pBuffer buffer containing the byte array to hash
52 | * @param length length of the byte array
53 | * @return the checksum over the buffer bytes
54 | **/
55 | static inline uint16_t crc_calculate(const uint8_t* pBuffer, uint16_t length)
56 | {
57 | uint16_t crcTmp;
58 | crc_init(&crcTmp);
59 | while (length--) {
60 | crc_accumulate(*pBuffer++, &crcTmp);
61 | }
62 | return crcTmp;
63 | }
64 |
65 | /**
66 | * @brief Accumulate the X.25 CRC by adding an array of bytes
67 | *
68 | * The checksum function adds the hash of one char at a time to the
69 | * 16 bit checksum (uint16_t).
70 | *
71 | * @param data new bytes to hash
72 | * @param crcAccum the already accumulated checksum
73 | **/
74 | static inline void crc_accumulate_buffer(uint16_t *crcAccum, const char *pBuffer, uint8_t length)
75 | {
76 | const uint8_t *p = (const uint8_t *)pBuffer;
77 | while (length--) {
78 | crc_accumulate(*p++, crcAccum);
79 | }
80 | }
81 |
82 |
83 |
84 |
85 | #endif /* _CHECKSUM_H_ */
86 |
87 | #ifdef __cplusplus
88 | }
89 | #endif
90 |
--------------------------------------------------------------------------------
/Protocol.txt:
--------------------------------------------------------------------------------
1 | We need to decide what data should be transmitted from the APM to the arduino.
2 |
3 | The taranis can display the following telemetry values:
4 | Taranis APM FrSky protocol
5 | A1 Analog ports on D receivers
6 | A2
7 | Alt Barometric altitude sensor barometer 0x10,0x21 int16 Altitude M
8 | Rpm Engine speed throttle% 0x03 uint16 Engine speed RPM
9 | Fuel Fuel level Battery remaining 0x04 uint16 Fuel Level %
10 | T1 Temperature sensor 1 sat count and fix 0x02 int16 Temperature1 C
11 | T2 Temperature sensor 2 ?APM mode 0x05 int16 Temperature2 C
12 | Spd GPS Speed GPS speed over ground 0x11,0x11+8 uint16 GPS Speed Knots
13 | Dist Distance from starting point distance to last arm ?
14 | GAlt GPS Alt GPS altitude 0x01,0x01+8 int16 GPS Altitude M
15 | Cell Lowest cell on FLVS-01 0x06
16 | Cels Sum of all cells on FLVS-01 Battery voltage in V 0x3A,0x3B uint16 Voltage V
17 | Vfas FAS-40/100 voltage measurement
18 | Curr Current Battery current in mA 0x28 uint16 Current A
19 | Cnsp mAh used totalizer (calculated?)
20 | Powr Power (calculated?)
21 | AccX AccelX 0x24 int16 Acc-x g
22 | AccY AccelY 0x25 int16 Acc-y g
23 | AccZ AccelZ 0x26 int16 Acc-z g
24 | Hdg Heading Compass heading 0x14,0x14+8 uint16 Course degree
25 | Vspd Vertical speed
26 | 0x13,0x13+8 uint16 Latitude ddmm.mmmm
27 | 0x1B+8 uint16 N/S
28 | 0x12,0x12+8 uint16 Longitude ddmm.mmmm
29 | 0x1A+8 uint16 E/W
30 | 0x15 ? Date/Month
31 | 0x16 ? Year
32 | 0x17 ? Hour/minute
33 | 0x18 ? Second
34 |
--------------------------------------------------------------------------------
/Libraries/FastSerial/ntz.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2007, Dmitry Xmelkov
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in
11 | the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of the copyright holders nor the names of
14 | contributors may be used to endorse or promote products derived
15 | from this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 | POSSIBILITY OF SUCH DAMAGE. */
28 |
29 | /* $Id: ntz.h 1217 2007-02-18 13:18:05Z dmix $ */
30 |
31 | #ifndef _NTZ_H
32 | #define _NTZ_H
33 |
34 | /* Number of Tail Zeros: ntz(x)= (ffs(x) ? ffs(x)-1 : 16)
35 | It works with all: cpp, gcc and gas expressions. */
36 | #define ntz(x) \
37 | ( (1 & (((x) & 1) == 0)) \
38 | + (1 & (((x) & 3) == 0)) \
39 | + (1 & (((x) & 7) == 0)) \
40 | + (1 & (((x) & 017) == 0)) \
41 | + (1 & (((x) & 037) == 0)) \
42 | + (1 & (((x) & 077) == 0)) \
43 | + (1 & (((x) & 0177) == 0)) \
44 | + (1 & (((x) & 0377) == 0)) \
45 | + (1 & (((x) & 0777) == 0)) \
46 | + (1 & (((x) & 01777) == 0)) \
47 | + (1 & (((x) & 03777) == 0)) \
48 | + (1 & (((x) & 07777) == 0)) \
49 | + (1 & (((x) & 017777) == 0)) \
50 | + (1 & (((x) & 037777) == 0)) \
51 | + (1 & (((x) & 077777) == 0)) \
52 | + (1 & (((x) & 0177777) == 0)) )
53 |
54 | #endif /* !_NTZ_H */
55 |
--------------------------------------------------------------------------------
/APM_Mavlink_to_FrSky/SimpleFIFO.h:
--------------------------------------------------------------------------------
1 | #ifndef SimpleFIFO_h
2 | #define SimpleFIFO_h
3 | /*
4 | ||
5 | || @file SimpleFIFO.h
6 | || @version 1.2
7 | || @author Alexander Brevig
8 | || @contact alexanderbrevig@gmail.com
9 | ||
10 | || @description
11 | || | A simple FIFO class, mostly for primitive types but can be used with classes if assignment to int is allowed
12 | || | This FIFO is not dynamic, so be sure to choose an appropriate size for it
13 | || #
14 | ||
15 | || @license
16 | || | Copyright (c) 2010 Alexander Brevig
17 | || | This library is free software; you can redistribute it and/or
18 | || | modify it under the terms of the GNU Lesser General Public
19 | || | License as published by the Free Software Foundation; version
20 | || | 2.1 of the License.
21 | || |
22 | || | This library is distributed in the hope that it will be useful,
23 | || | but WITHOUT ANY WARRANTY; without even the implied warranty of
24 | || | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 | || | Lesser General Public License for more details.
26 | || |
27 | || | You should have received a copy of the GNU Lesser General Public
28 | || | License along with this library; if not, write to the Free Software
29 | || | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 | || #
31 | ||
32 | */
33 | template
34 | class SimpleFIFO {
35 | public:
36 | const char size; //speculative feature, in case it's needed
37 |
38 | SimpleFIFO();
39 |
40 | T dequeue(); //get next element
41 | bool enqueue( T element ); //add an element
42 | T peek() const; //get the next element without releasing it from the FIFO
43 | void flush(); //[1.1] reset to default state
44 |
45 | //how many elements are currently in the FIFO?
46 | char count() { return numberOfElements; }
47 |
48 | private:
49 | #ifndef SimpleFIFO_NONVOLATILE
50 | volatile char numberOfElements;
51 | volatile char nextIn;
52 | volatile char nextOut;
53 | volatile T raw[rawSize];
54 | #else
55 | char numberOfElements;
56 | char nextIn;
57 | char nextOut;
58 | T raw[rawSize];
59 | #endif
60 | };
61 |
62 | template
63 | SimpleFIFO::SimpleFIFO() : size(rawSize) {
64 | flush();
65 | }
66 | template
67 | bool SimpleFIFO::enqueue( T element ) {
68 | if ( count() >= rawSize ) { return false; }
69 | numberOfElements++;
70 | nextIn %= size;
71 | raw[nextIn] = element;
72 | nextIn++; //advance to next index
73 | return true;
74 | }
75 | template
76 | T SimpleFIFO::dequeue() {
77 | numberOfElements--;
78 | nextOut %= size;
79 | return raw[ nextOut++];
80 | }
81 | template
82 | T SimpleFIFO::peek() const {
83 | return raw[ nextOut % size];
84 | }
85 | template
86 | void SimpleFIFO::flush() {
87 | nextIn = nextOut = numberOfElements = 0;
88 | }
89 | #endif
--------------------------------------------------------------------------------
/Libraries/AP_Math/quaternion.cpp:
--------------------------------------------------------------------------------
1 | /// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
2 | /*
3 | * quaternion.cpp
4 | * Copyright (C) Andrew Tridgell 2012
5 | *
6 | * This file is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by the
8 | * Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This file is distributed in the hope that it will be useful, but
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 | * See the GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along
17 | * with this program. If not, see .
18 | */
19 |
20 | #include "AP_Math.h"
21 |
22 | // return the rotation matrix equivalent for this quaternion
23 | void Quaternion::rotation_matrix(Matrix3f &m)
24 | {
25 | float q3q3 = q3 * q3;
26 | float q3q4 = q3 * q4;
27 | float q2q2 = q2 * q2;
28 | float q2q3 = q2 * q3;
29 | float q2q4 = q2 * q4;
30 | float q1q2 = q1 * q2;
31 | float q1q3 = q1 * q3;
32 | float q1q4 = q1 * q4;
33 | float q4q4 = q4 * q4;
34 |
35 | m.a.x = 1-2*(q3q3 + q4q4);
36 | m.a.y = 2*(q2q3 - q1q4);
37 | m.a.z = 2*(q2q4 + q1q3);
38 | m.b.x = 2*(q2q3 + q1q4);
39 | m.b.y = 1-2*(q2q2 + q4q4);
40 | m.b.z = 2*(q3q4 - q1q2);
41 | m.c.x = 2*(q2q4 - q1q3);
42 | m.c.y = 2*(q3q4 + q1q2);
43 | m.c.z = 1-2*(q2q2 + q3q3);
44 | }
45 |
46 | // convert a vector from earth to body frame
47 | void Quaternion::earth_to_body(Vector3f &v)
48 | {
49 | Matrix3f m;
50 | // we reverse z before and afterwards because of the differing
51 | // quaternion conventions from APM conventions.
52 | v.z = -v.z;
53 | rotation_matrix(m);
54 | v = m * v;
55 | v.z = -v.z;
56 | }
57 |
58 | // create a quaternion from Euler angles
59 | void Quaternion::from_euler(float roll, float pitch, float yaw)
60 | {
61 | float cr2 = cos(roll*0.5);
62 | float cp2 = cos(pitch*0.5);
63 | float cy2 = cos(yaw*0.5);
64 | float sr2 = sin(roll*0.5);
65 | float sp2 = sin(pitch*0.5);
66 | float sy2 = sin(yaw*0.5);
67 |
68 | q1 = cr2*cp2*cy2 + sr2*sp2*sy2;
69 | q2 = sr2*cp2*cy2 - cr2*sp2*sy2;
70 | q3 = cr2*sp2*cy2 + sr2*cp2*sy2;
71 | q4 = cr2*cp2*sy2 - sr2*sp2*cy2;
72 | }
73 |
74 | // create eulers from a quaternion
75 | void Quaternion::to_euler(float *roll, float *pitch, float *yaw)
76 | {
77 | if (roll) {
78 | *roll = (atan2(2.0*(q1*q2 + q3*q4),
79 | 1 - 2.0*(q2*q2 + q3*q3)));
80 | }
81 | if (pitch) {
82 | // we let safe_asin() handle the singularities near 90/-90 in pitch
83 | *pitch = safe_asin(2.0*(q1*q3 - q4*q2));
84 | }
85 | if (yaw) {
86 | *yaw = atan2(2.0*(q1*q4 + q2*q3),
87 | 1 - 2.0*(q3*q3 + q4*q4));
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/Libraries/AP_Math/polygon.cpp:
--------------------------------------------------------------------------------
1 | /// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
2 | /*
3 | * polygon.cpp
4 | * Copyright (C) Andrew Tridgell 2011
5 | *
6 | * This file is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by the
8 | * Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This file is distributed in the hope that it will be useful, but
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 | * See the GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along
17 | * with this program. If not, see .
18 | */
19 |
20 | #include "AP_Math.h"
21 |
22 | /*
23 | The point in polygon algorithm is based on:
24 | http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
25 | */
26 |
27 |
28 | /*
29 | Polygon_outside(): test for a point in a polygon
30 | Input: P = a point,
31 | V[] = vertex points of a polygon V[n+1] with V[n]=V[0]
32 | Return: true if P is outside the polygon
33 |
34 | This does not take account of the curvature of the earth, but we
35 | expect that to be very small over the distances involved in the
36 | fence boundary
37 | */
38 | bool Polygon_outside(const Vector2l &P, const Vector2l *V, unsigned n)
39 | {
40 | unsigned i, j;
41 | bool outside = true;
42 | for (i = 0, j = n-1; i < n; j = i++) {
43 | if ((V[i].y > P.y) == (V[j].y > P.y)) {
44 | continue;
45 | }
46 | int32_t dx1, dx2, dy1, dy2;
47 | dx1 = P.x - V[i].x;
48 | dx2 = V[j].x - V[i].x;
49 | dy1 = P.y - V[i].y;
50 | dy2 = V[j].y - V[i].y;
51 | int8_t dx1s, dx2s, dy1s, dy2s, m1, m2;
52 | #define sign(x) ((x)<0?-1:1)
53 | dx1s = sign(dx1);
54 | dx2s = sign(dx2);
55 | dy1s = sign(dy1);
56 | dy2s = sign(dy2);
57 | m1 = dx1s * dy2s;
58 | m2 = dx2s * dy1s;
59 | // we avoid the 64 bit multiplies if we can based on sign checks.
60 | if (dy2 < 0) {
61 | if (m1 > m2) {
62 | outside = !outside;
63 | } else if (m1 < m2) {
64 | continue;
65 | } else if ( dx1 * (int64_t)dy2 > dx2 * (int64_t)dy1 ) {
66 | outside = !outside;
67 | }
68 | } else {
69 | if (m1 < m2) {
70 | outside = !outside;
71 | } else if (m1 > m2) {
72 | continue;
73 | } else if ( dx1 * (int64_t)dy2 < dx2 * (int64_t)dy1 ) {
74 | outside = !outside;
75 | }
76 | }
77 | }
78 | return outside;
79 | }
80 |
81 | /*
82 | check if a polygon is complete.
83 |
84 | We consider a polygon to be complete if we have at least 4 points,
85 | and the first point is the same as the last point. That is the
86 | minimum requirement for the Polygon_outside function to work
87 | */
88 | bool Polygon_complete(const Vector2l *V, unsigned n)
89 | {
90 | return (n >= 4 && V[n-1].x == V[0].x && V[n-1].y == V[0].y);
91 | }
92 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/message_definitions/ualberta.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | common.xml
4 |
5 |
6 | Available autopilot modes for ualberta uav
7 | Raw input pulse widts sent to output
8 | Inputs are normalized using calibration, the converted back to raw pulse widths for output
9 | dfsdfs
10 | dfsfds
11 | dfsdfsdfs
12 |
13 |
14 | Navigation filter mode
15 |
16 | AHRS mode
17 | INS/GPS initialization mode
18 | INS/GPS mode
19 |
20 |
21 | Mode currently commanded by pilot
22 | sdf
23 | dfs
24 | Rotomotion mode
25 |
26 |
27 |
28 |
29 | Accelerometer and Gyro biases from the navigation filter
30 | Timestamp (microseconds)
31 | b_f[0]
32 | b_f[1]
33 | b_f[2]
34 | b_f[0]
35 | b_f[1]
36 | b_f[2]
37 |
38 |
39 | Complete set of calibration parameters for the radio
40 | Aileron setpoints: left, center, right
41 | Elevator setpoints: nose down, center, nose up
42 | Rudder setpoints: nose left, center, nose right
43 | Tail gyro mode/gain setpoints: heading hold, rate mode
44 | Pitch curve setpoints (every 25%)
45 | Throttle curve setpoints (every 25%)
46 |
47 |
48 | System status specific to ualberta uav
49 | System mode, see UALBERTA_AUTOPILOT_MODE ENUM
50 | Navigation mode, see UALBERTA_NAV_MODE ENUM
51 | Pilot mode, see UALBERTA_PILOT_MODE
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/GCS_MAVLink.h:
--------------------------------------------------------------------------------
1 | // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
2 |
3 | /// @file GCS_MAVLink.h
4 | /// @brief One size fits all header for MAVLink integration.
5 |
6 | #ifndef GCS_MAVLink_h
7 | #define GCS_MAVLink_h
8 |
9 | #include
10 |
11 | // we have separate helpers disabled to make it possible
12 | // to select MAVLink 1.0 in the arduino GUI build
13 | //#define MAVLINK_SEPARATE_HELPERS
14 |
15 | #include "include/mavlink/v1.0/ardupilotmega/version.h"
16 |
17 | // this allows us to make mavlink_message_t much smaller
18 | #define MAVLINK_MAX_PAYLOAD_LEN MAVLINK_MAX_DIALECT_PAYLOAD_SIZE
19 |
20 | #define MAVLINK_COMM_NUM_BUFFERS 1
21 | #include "include/mavlink/v1.0/mavlink_types.h"
22 |
23 | /// MAVLink stream used for HIL interaction
24 | extern BetterStream *mavlink_comm_0_port;
25 |
26 | /// MAVLink stream used for ground control communication
27 | extern BetterStream *mavlink_comm_1_port;
28 |
29 | /// MAVLink system definition
30 | extern mavlink_system_t mavlink_system;
31 |
32 | /// Send a byte to the nominated MAVLink channel
33 | ///
34 | /// @param chan Channel to send to
35 | /// @param ch Byte to send
36 | ///
37 | static inline void comm_send_ch(mavlink_channel_t chan, uint8_t ch)
38 | {
39 | switch(chan) {
40 | case MAVLINK_COMM_0:
41 | mavlink_comm_0_port->write(ch);
42 | break;
43 | case MAVLINK_COMM_1:
44 | mavlink_comm_1_port->write(ch);
45 | break;
46 | default:
47 | break;
48 | }
49 | }
50 |
51 | /// Read a byte from the nominated MAVLink channel
52 | ///
53 | /// @param chan Channel to receive on
54 | /// @returns Byte read
55 | ///
56 | static inline uint8_t comm_receive_ch(mavlink_channel_t chan)
57 | {
58 | uint8_t data = 0;
59 |
60 | switch(chan) {
61 | case MAVLINK_COMM_0:
62 | data = mavlink_comm_0_port->read();
63 | break;
64 | case MAVLINK_COMM_1:
65 | data = mavlink_comm_1_port->read();
66 | break;
67 | default:
68 | break;
69 | }
70 | return data;
71 | }
72 |
73 | /// Check for available data on the nominated MAVLink channel
74 | ///
75 | /// @param chan Channel to check
76 | /// @returns Number of bytes available
77 | static inline uint16_t comm_get_available(mavlink_channel_t chan)
78 | {
79 | uint16_t bytes = 0;
80 | switch(chan) {
81 | case MAVLINK_COMM_0:
82 | bytes = mavlink_comm_0_port->available();
83 | break;
84 | case MAVLINK_COMM_1:
85 | bytes = mavlink_comm_1_port->available();
86 | break;
87 | default:
88 | break;
89 | }
90 | return bytes;
91 | }
92 |
93 |
94 | /// Check for available transmit space on the nominated MAVLink channel
95 | ///
96 | /// @param chan Channel to check
97 | /// @returns Number of bytes available, -1 for error
98 | static inline int comm_get_txspace(mavlink_channel_t chan)
99 | {
100 | switch(chan) {
101 | case MAVLINK_COMM_0:
102 | return mavlink_comm_0_port->txspace();
103 | break;
104 | case MAVLINK_COMM_1:
105 | return mavlink_comm_1_port->txspace();
106 | break;
107 | default:
108 | break;
109 | }
110 | return -1;
111 | }
112 |
113 | #define MAVLINK_USE_CONVENIENCE_FUNCTIONS
114 | #include "include/mavlink/v1.0/ardupilotmega/mavlink.h"
115 |
116 | uint8_t mavlink_check_target(uint8_t sysid, uint8_t compid);
117 |
118 | // return a MAVLink variable type given a AP_Param type
119 | uint8_t mav_var_type(enum ap_var_type t);
120 |
121 | #endif // GCS_MAVLink_h
122 |
--------------------------------------------------------------------------------
/Libraries/AP_Math/vector3.cpp:
--------------------------------------------------------------------------------
1 | /// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
2 | /*
3 | * vector3.cpp
4 | * Copyright (C) Andrew Tridgell 2012
5 | *
6 | * This file is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by the
8 | * Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This file is distributed in the hope that it will be useful, but
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 | * See the GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along
17 | * with this program. If not, see .
18 | */
19 |
20 | #include "AP_Math.h"
21 |
22 | #define HALF_SQRT_2 0.70710678118654757
23 |
24 | // rotate a vector by a standard rotation, attempting
25 | // to use the minimum number of floating point operations
26 | template
27 | void Vector3::rotate(enum Rotation rotation)
28 | {
29 | T tmp;
30 | switch (rotation) {
31 | case ROTATION_NONE:
32 | case ROTATION_MAX:
33 | return;
34 | case ROTATION_YAW_45: {
35 | tmp = HALF_SQRT_2*(x - y);
36 | y = HALF_SQRT_2*(x + y);
37 | x = tmp;
38 | return;
39 | }
40 | case ROTATION_YAW_90: {
41 | tmp = x; x = -y; y = tmp;
42 | return;
43 | }
44 | case ROTATION_YAW_135: {
45 | tmp = -HALF_SQRT_2*(x + y);
46 | y = HALF_SQRT_2*(x - y);
47 | x = tmp;
48 | return;
49 | }
50 | case ROTATION_YAW_180:
51 | x = -x; y = -y;
52 | return;
53 | case ROTATION_YAW_225: {
54 | tmp = HALF_SQRT_2*(y - x);
55 | y = -HALF_SQRT_2*(x + y);
56 | x = tmp;
57 | return;
58 | }
59 | case ROTATION_YAW_270: {
60 | tmp = x; x = y; y = -tmp;
61 | return;
62 | }
63 | case ROTATION_YAW_315: {
64 | tmp = HALF_SQRT_2*(x + y);
65 | y = HALF_SQRT_2*(y - x);
66 | x = tmp;
67 | return;
68 | }
69 | case ROTATION_ROLL_180: {
70 | y = -y; z = -z;
71 | return;
72 | }
73 | case ROTATION_ROLL_180_YAW_45: {
74 | tmp = HALF_SQRT_2*(x + y);
75 | y = HALF_SQRT_2*(x - y);
76 | x = tmp; z = -z;
77 | return;
78 | }
79 | case ROTATION_ROLL_180_YAW_90: {
80 | tmp = x; x = y; y = tmp; z = -z;
81 | return;
82 | }
83 | case ROTATION_ROLL_180_YAW_135: {
84 | tmp = HALF_SQRT_2*(y - x);
85 | y = HALF_SQRT_2*(y + x);
86 | x = tmp; z = -z;
87 | return;
88 | }
89 | case ROTATION_PITCH_180: {
90 | x = -x; z = -z;
91 | return;
92 | }
93 | case ROTATION_ROLL_180_YAW_225: {
94 | tmp = -HALF_SQRT_2*(x + y);
95 | y = HALF_SQRT_2*(y - x);
96 | x = tmp; z = -z;
97 | return;
98 | }
99 | case ROTATION_ROLL_180_YAW_270: {
100 | tmp = x; x = -y; y = -tmp; z = -z;
101 | return;
102 | }
103 | case ROTATION_ROLL_180_YAW_315: {
104 | tmp = HALF_SQRT_2*(x - y);
105 | y = -HALF_SQRT_2*(x + y);
106 | x = tmp; z = -z;
107 | return;
108 | }
109 | }
110 | }
111 |
112 | // only define for signed numbers
113 | template void Vector3::rotate(enum Rotation);
114 | template void Vector3::rotate(enum Rotation);
115 | template void Vector3::rotate(enum Rotation);
116 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/message_definitions/sensesoar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | common.xml
4 |
5 |
6 | Different flight modes
7 | Gliding mode with motors off
8 | Autonomous flight
9 | RC controlled
10 |
11 |
12 |
13 |
14 | Position estimate of the observer in global frame
15 | Longitude expressed in 1E7
16 | Latitude expressed in 1E7
17 | Altitude expressed in milimeters
18 |
19 |
20 | velocity estimate of the observer in NED inertial frame
21 | Velocity
22 |
23 |
24 | attitude estimate of the observer
25 | Quaternion re;im
26 |
27 |
28 | Wind estimate in NED inertial frame
29 | Wind
30 |
31 |
32 | Estimate of the air velocity
33 | Air speed
34 | angle of attack
35 | slip angle
36 |
37 |
38 | IMU biases
39 | accelerometer bias
40 | gyroscope bias
41 |
42 |
43 | estimate of the pressure at sea level
44 | Wind
45 |
46 |
47 | ambient air temperature
48 | Air Temperatur
49 |
50 |
51 | filtered rotational velocity
52 | rotational velocity
53 |
54 |
55 | low level control output
56 | Servo signal
57 | motor signal
58 |
59 |
60 | Power managment
61 | current power consumption
62 | battery status
63 | Power generation from each module
64 |
65 |
66 | system status
67 | gps status
68 | actuator status
69 | module status
70 | module status
71 |
72 |
73 | change commanded air speed
74 | Target ID
75 | commanded airspeed
76 |
77 |
78 | accept change of airspeed
79 | commanded airspeed
80 | 0:ack, 1:nack
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/Libraries/AP_Common/AP_Test.h:
--------------------------------------------------------------------------------
1 | // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
2 | //
3 | // This is free software; you can redistribute it and/or modify it under
4 | // the terms of the GNU Lesser General Public License as published by the
5 | // Free Software Foundation; either version 2.1 of the License, or (at
6 | // your option) any later version.
7 | //
8 |
9 | /// @file AP_Test.h
10 | /// @brief A simple unit test framework.
11 | ///
12 | /// AP_Test provides the usual test start, condition validation and reporting
13 | /// functions in a compact form.
14 | ///
15 | /// Each test must be contained within a block; either a standalone function or
16 | /// a block within a function. The TEST macro is used to start a test; it creates
17 | /// the local object which will track the results of the test and saves the name
18 | /// for later reporting. Only one test may be performed within each block.
19 | ///
20 | /// Within the test, use the REQUIRE macro to describe a condition that must be
21 | /// met for the test to pass. If the condition within the macro is not met,
22 | /// the condition will be output as a diagnostic and the test will be considered
23 | /// to have failed.
24 | ///
25 | /// The test ends at the end of the block, and the result of the test will be
26 | /// output as a diagnostic.
27 | ///
28 | /// Optionally at the end of the test suite, the Test::report method may be used
29 | /// to summarize the results of all of the tests that were performed.
30 | ///
31 |
32 | /// Unit test state and methods.
33 | ///
34 | class Test
35 | {
36 | public:
37 | /// Constructor - creates a new test.
38 | ///
39 | /// Normally called by the TEST macro.
40 | ///
41 | /// @param name The name of the test being started.
42 | ///
43 | Test(const char *name);
44 |
45 | /// Destructor - ends the test.
46 | ///
47 | ~Test();
48 |
49 | /// Perform a success check.
50 | ///
51 | /// @param expr If false, the test has failed.
52 | /// @param source The expression source; emitted in the diagnostic
53 | /// indicating test failure.
54 | ///
55 | void require(bool expr, const char *source);
56 |
57 | /// Report the overall number of tests/pass/fails.
58 | ///
59 | static void report();
60 |
61 | private:
62 | const char *_name; ///< name of the current test
63 | bool _fail; ///< set if any ::require calls indicate the test failed
64 | static int _passed; ///< global pass count
65 | static int _failed; ///< global fail count
66 | };
67 |
68 | /// Constructor
69 | ///
70 | Test::Test(const char *name) :
71 | _name(name),
72 | _fail(false)
73 | {
74 | }
75 |
76 | /// Destructor
77 | ///
78 | Test::~Test()
79 | {
80 | Serial.printf("%s: %s\n", _fail ? "FAILED" : "passed", _name);
81 | if (_fail) {
82 | _failed++;
83 | } else {
84 | _passed++;
85 | }
86 | }
87 |
88 | /// Success check
89 | ///
90 | void
91 | Test::require(bool expr, const char *source)
92 | {
93 | if (!expr) {
94 | _fail = true;
95 | Serial.printf("%s: fail: %s\n", _name, source);
96 | }
97 | }
98 |
99 | /// Summary report
100 | ///
101 | void
102 | Test::report()
103 | {
104 | Serial.printf("\n%d passed %d failed\n", _passed, _failed);
105 | }
106 |
107 | int Test::_passed = 0;
108 | int Test::_failed = 0;
109 |
110 | /// Start a new test.
111 | ///
112 | /// This should be invoked at the beginning of a block, before any REQUIRE
113 | /// statements. A new test called name is started, and subsequent REQUIRE
114 | /// statements will be applied to the test. The test will continue until
115 | /// the end of the block (or until the _test object that is created otherwise
116 | /// goes out of scope).
117 | ///
118 | #define TEST(name) Test _test(#name)
119 |
120 | /// Attach an expression to the test's success criteria.
121 | ///
122 | /// The expression expr must evaluate true for the test to pass. If
123 | /// it does not, the text of the expression is output as a diagnostic
124 | /// and the test is marked as a failure.
125 | ///
126 | #define REQUIRE(expr) _test.require(expr, #expr)
127 |
128 |
--------------------------------------------------------------------------------
/Libraries/AP_Math/examples/polygon/polygon.pde:
--------------------------------------------------------------------------------
1 | /// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
2 | //
3 | // Unit tests for the AP_Math polygon code
4 | //
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | FastSerialPort(Serial, 0);
11 |
12 | /*
13 | this is the boundary of the 2010 outback challenge
14 | Note that the last point must be the same as the first for the
15 | Polygon_outside() algorithm
16 | */
17 | static const Vector2l OBC_boundary[] = {
18 | Vector2l(-265695640, 1518373730),
19 | Vector2l(-265699560, 1518394050),
20 | Vector2l(-265768230, 1518411420),
21 | Vector2l(-265773080, 1518403440),
22 | Vector2l(-265815110, 1518419500),
23 | Vector2l(-265784860, 1518474690),
24 | Vector2l(-265994890, 1518528860),
25 | Vector2l(-266092110, 1518747420),
26 | Vector2l(-266454780, 1518820530),
27 | Vector2l(-266435720, 1518303500),
28 | Vector2l(-265875990, 1518344050),
29 | Vector2l(-265695640, 1518373730)
30 | };
31 |
32 | static const struct {
33 | Vector2l point;
34 | bool outside;
35 | } test_points[] = {
36 | { Vector2l(-266398870, 1518220000), true },
37 | { Vector2l(-266418700, 1518709260), false },
38 | { Vector2l(-350000000, 1490000000), true },
39 | { Vector2l(0, 0), true },
40 | { Vector2l(-265768150, 1518408250), false },
41 | { Vector2l(-265774060, 1518405860), true },
42 | { Vector2l(-266435630, 1518303440), true },
43 | { Vector2l(-266435650, 1518313540), false },
44 | { Vector2l(-266435690, 1518303530), false },
45 | { Vector2l(-266435690, 1518303490), true },
46 | { Vector2l(-265875990, 1518344049), true },
47 | { Vector2l(-265875990, 1518344051), false },
48 | { Vector2l(-266454781, 1518820530), true },
49 | { Vector2l(-266454779, 1518820530), true },
50 | { Vector2l(-266092109, 1518747420), true },
51 | { Vector2l(-266092111, 1518747420), false },
52 | { Vector2l(-266092110, 1518747421), true },
53 | { Vector2l(-266092110, 1518747419), false },
54 | { Vector2l(-266092111, 1518747421), true },
55 | { Vector2l(-266092109, 1518747421), true },
56 | { Vector2l(-266092111, 1518747419), false },
57 | };
58 |
59 | #define ARRAY_LENGTH(x) (sizeof((x))/sizeof((x)[0]))
60 |
61 | /*
62 | polygon tests
63 | */
64 | void setup(void)
65 | {
66 | unsigned i, count;
67 | bool all_passed = true;
68 | uint32_t start_time;
69 |
70 | Serial.begin(115200);
71 | Serial.println("polygon unit tests\n");
72 |
73 | if (!Polygon_complete(OBC_boundary, ARRAY_LENGTH(OBC_boundary))) {
74 | Serial.println("OBC boundary is not complete!");
75 | all_passed = false;
76 | }
77 |
78 | if (Polygon_complete(OBC_boundary, ARRAY_LENGTH(OBC_boundary)-1)) {
79 | Serial.println("Polygon_complete test failed");
80 | all_passed = false;
81 | }
82 |
83 | for (i=0; imsgid = MAVLINK_MSG_ID_BOOT;
48 | return mavlink_finalize_message(msg, system_id, component_id, 4);
49 | }
50 |
51 | /**
52 | * @brief Pack a boot message on a channel
53 | * @param system_id ID of this system
54 | * @param component_id ID of this component (e.g. 200 for IMU)
55 | * @param chan The MAVLink channel this message was sent over
56 | * @param msg The MAVLink message to compress the data into
57 | * @param version The onboard software version
58 | * @return length of the message in bytes (excluding serial stream start sign)
59 | */
60 | static inline uint16_t mavlink_msg_boot_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
61 | mavlink_message_t* msg,
62 | uint32_t version)
63 | {
64 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
65 | char buf[4];
66 | _mav_put_uint32_t(buf, 0, version);
67 |
68 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4);
69 | #else
70 | mavlink_boot_t packet;
71 | packet.version = version;
72 |
73 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4);
74 | #endif
75 |
76 | msg->msgid = MAVLINK_MSG_ID_BOOT;
77 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 4);
78 | }
79 |
80 | /**
81 | * @brief Encode a boot struct into a message
82 | *
83 | * @param system_id ID of this system
84 | * @param component_id ID of this component (e.g. 200 for IMU)
85 | * @param msg The MAVLink message to compress the data into
86 | * @param boot C-struct to read the message contents from
87 | */
88 | 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)
89 | {
90 | return mavlink_msg_boot_pack(system_id, component_id, msg, boot->version);
91 | }
92 |
93 | /**
94 | * @brief Send a boot message
95 | * @param chan MAVLink channel to send the message
96 | *
97 | * @param version The onboard software version
98 | */
99 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
100 |
101 | static inline void mavlink_msg_boot_send(mavlink_channel_t chan, uint32_t version)
102 | {
103 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
104 | char buf[4];
105 | _mav_put_uint32_t(buf, 0, version);
106 |
107 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BOOT, buf, 4);
108 | #else
109 | mavlink_boot_t packet;
110 | packet.version = version;
111 |
112 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BOOT, (const char *)&packet, 4);
113 | #endif
114 | }
115 |
116 | #endif
117 |
118 | // MESSAGE BOOT UNPACKING
119 |
120 |
121 | /**
122 | * @brief Get field version from boot message
123 | *
124 | * @return The onboard software version
125 | */
126 | static inline uint32_t mavlink_msg_boot_get_version(const mavlink_message_t* msg)
127 | {
128 | return _MAV_RETURN_uint32_t(msg, 0);
129 | }
130 |
131 | /**
132 | * @brief Decode a boot message into a struct
133 | *
134 | * @param msg The message to decode
135 | * @param boot C-struct to decode the message contents into
136 | */
137 | static inline void mavlink_msg_boot_decode(const mavlink_message_t* msg, mavlink_boot_t* boot)
138 | {
139 | #if MAVLINK_NEED_BYTE_SWAP
140 | boot->version = mavlink_msg_boot_get_version(msg);
141 | #else
142 | memcpy(boot, _MAV_PAYLOAD(msg), 4);
143 | #endif
144 | }
145 |
--------------------------------------------------------------------------------
/Libraries/AP_Common/menu.cpp:
--------------------------------------------------------------------------------
1 | // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
2 |
3 | //
4 | // Simple commandline menu system.
5 | //
6 |
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include "include/menu.h"
15 |
16 | // statics
17 | char Menu::_inbuf[MENU_COMMANDLINE_MAX];
18 | Menu::arg Menu::_argv[MENU_ARGS_MAX + 1];
19 |
20 | // constructor
21 | Menu::Menu(const prog_char *prompt, const Menu::command *commands, uint8_t entries, preprompt ppfunc) :
22 | _prompt(prompt),
23 | _commands(commands),
24 | _entries(entries),
25 | _ppfunc(ppfunc)
26 | {
27 | }
28 |
29 | // run the menu
30 | void
31 | Menu::run(void)
32 | {
33 | int8_t ret;
34 | uint8_t len, i;
35 | uint8_t argc;
36 | int c;
37 | char *s;
38 |
39 | // loop performing commands
40 | for (;;) {
41 |
42 | // run the pre-prompt function, if one is defined
43 | if ((NULL != _ppfunc) && !_ppfunc())
44 | return;
45 |
46 | // loop reading characters from the input
47 | len = 0;
48 | Serial.printf("%S] ", FPSTR(_prompt));
49 | for (;;) {
50 | c = Serial.read();
51 | if (-1 == c)
52 | continue;
53 | // carriage return -> process command
54 | if ('\r' == c) {
55 | _inbuf[len] = '\0';
56 | Serial.write('\r');
57 | Serial.write('\n');
58 | break;
59 | }
60 | // backspace
61 | if ('\b' == c) {
62 | if (len > 0) {
63 | len--;
64 | Serial.write('\b');
65 | Serial.write(' ');
66 | Serial.write('\b');
67 | continue;
68 | }
69 | }
70 | // printable character
71 | if (isprint(c) && (len < (MENU_COMMANDLINE_MAX - 1))) {
72 | _inbuf[len++] = c;
73 | Serial.write((char)c);
74 | continue;
75 | }
76 | }
77 |
78 | // split the input line into tokens
79 | argc = 0;
80 | _argv[argc++].str = strtok_r(_inbuf, " ", &s);
81 | // XXX should an empty line by itself back out of the current menu?
82 | while (argc <= MENU_ARGS_MAX) {
83 | _argv[argc].str = strtok_r(NULL, " ", &s);
84 | if ('\0' == _argv[argc].str)
85 | break;
86 | _argv[argc].i = atol(_argv[argc].str);
87 | _argv[argc].f = atof(_argv[argc].str); // calls strtod, > 700B !
88 | argc++;
89 | }
90 |
91 | if (_argv[0].str == NULL) {
92 | continue;
93 | }
94 |
95 | // populate arguments that have not been specified with "" and 0
96 | // this is safer than NULL in the case where commands may look
97 | // without testing argc
98 | i = argc;
99 | while (i <= MENU_ARGS_MAX) {
100 | _argv[i].str = "";
101 | _argv[i].i = 0;
102 | _argv[i].f = 0;
103 | i++;
104 | }
105 |
106 | bool cmd_found = false;
107 | // look for a command matching the first word (note that it may be empty)
108 | for (i = 0; i < _entries; i++) {
109 | if (!strcasecmp_P(_argv[0].str, _commands[i].command)) {
110 | ret = _call(i, argc);
111 | cmd_found=true;
112 | if (-2 == ret)
113 | return;
114 | break;
115 | }
116 | }
117 |
118 | // implicit commands
119 | if (i == _entries) {
120 | if (!strcmp(_argv[0].str, "?") || (!strcasecmp_P(_argv[0].str, PSTR("help")))) {
121 | _help();
122 | cmd_found=true;
123 | } else if (!strcasecmp_P(_argv[0].str, PSTR("exit"))) {
124 | return;
125 | }
126 | }
127 |
128 | if (cmd_found==false)
129 | {
130 | Serial.println("Invalid command, type 'help'");
131 | }
132 |
133 | }
134 | }
135 |
136 | // display the list of commands in response to the 'help' command
137 | void
138 | Menu::_help(void)
139 | {
140 | int i;
141 |
142 | Serial.println("Commands:");
143 | for (i = 0; i < _entries; i++)
144 | Serial.printf(" %S\n", FPSTR(_commands[i].command));
145 | }
146 |
147 | // run the n'th command in the menu
148 | int8_t
149 | Menu::_call(uint8_t n, uint8_t argc)
150 | {
151 | func fn;
152 |
153 | fn = (func)pgm_read_pointer(&_commands[n].func);
154 | return(fn(argc, &_argv[0]));
155 | }
156 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/common/mavlink_msg_auth_key.h:
--------------------------------------------------------------------------------
1 | // MESSAGE AUTH_KEY PACKING
2 |
3 | #define MAVLINK_MSG_ID_AUTH_KEY 7
4 |
5 | typedef struct __mavlink_auth_key_t
6 | {
7 | char key[32]; ///< key
8 | } mavlink_auth_key_t;
9 |
10 | #define MAVLINK_MSG_ID_AUTH_KEY_LEN 32
11 | #define MAVLINK_MSG_ID_7_LEN 32
12 |
13 | #define MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN 32
14 |
15 | #define MAVLINK_MESSAGE_INFO_AUTH_KEY { \
16 | "AUTH_KEY", \
17 | 1, \
18 | { { "key", NULL, MAVLINK_TYPE_CHAR, 32, 0, offsetof(mavlink_auth_key_t, key) }, \
19 | } \
20 | }
21 |
22 |
23 | /**
24 | * @brief Pack a auth_key message
25 | * @param system_id ID of this system
26 | * @param component_id ID of this component (e.g. 200 for IMU)
27 | * @param msg The MAVLink message to compress the data into
28 | *
29 | * @param key key
30 | * @return length of the message in bytes (excluding serial stream start sign)
31 | */
32 | static inline uint16_t mavlink_msg_auth_key_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
33 | const char *key)
34 | {
35 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
36 | char buf[32];
37 |
38 | _mav_put_char_array(buf, 0, key, 32);
39 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32);
40 | #else
41 | mavlink_auth_key_t packet;
42 |
43 | mav_array_memcpy(packet.key, key, sizeof(char)*32);
44 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32);
45 | #endif
46 |
47 | msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
48 | return mavlink_finalize_message(msg, system_id, component_id, 32);
49 | }
50 |
51 | /**
52 | * @brief Pack a auth_key message on a channel
53 | * @param system_id ID of this system
54 | * @param component_id ID of this component (e.g. 200 for IMU)
55 | * @param chan The MAVLink channel this message was sent over
56 | * @param msg The MAVLink message to compress the data into
57 | * @param key key
58 | * @return length of the message in bytes (excluding serial stream start sign)
59 | */
60 | static inline uint16_t mavlink_msg_auth_key_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
61 | mavlink_message_t* msg,
62 | const char *key)
63 | {
64 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
65 | char buf[32];
66 |
67 | _mav_put_char_array(buf, 0, key, 32);
68 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32);
69 | #else
70 | mavlink_auth_key_t packet;
71 |
72 | mav_array_memcpy(packet.key, key, sizeof(char)*32);
73 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32);
74 | #endif
75 |
76 | msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
77 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 32);
78 | }
79 |
80 | /**
81 | * @brief Encode a auth_key struct into a message
82 | *
83 | * @param system_id ID of this system
84 | * @param component_id ID of this component (e.g. 200 for IMU)
85 | * @param msg The MAVLink message to compress the data into
86 | * @param auth_key C-struct to read the message contents from
87 | */
88 | 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)
89 | {
90 | return mavlink_msg_auth_key_pack(system_id, component_id, msg, auth_key->key);
91 | }
92 |
93 | /**
94 | * @brief Send a auth_key message
95 | * @param chan MAVLink channel to send the message
96 | *
97 | * @param key key
98 | */
99 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
100 |
101 | static inline void mavlink_msg_auth_key_send(mavlink_channel_t chan, const char *key)
102 | {
103 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
104 | char buf[32];
105 |
106 | _mav_put_char_array(buf, 0, key, 32);
107 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, buf, 32);
108 | #else
109 | mavlink_auth_key_t packet;
110 |
111 | mav_array_memcpy(packet.key, key, sizeof(char)*32);
112 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)&packet, 32);
113 | #endif
114 | }
115 |
116 | #endif
117 |
118 | // MESSAGE AUTH_KEY UNPACKING
119 |
120 |
121 | /**
122 | * @brief Get field key from auth_key message
123 | *
124 | * @return key
125 | */
126 | static inline uint16_t mavlink_msg_auth_key_get_key(const mavlink_message_t* msg, char *key)
127 | {
128 | return _MAV_RETURN_char_array(msg, key, 32, 0);
129 | }
130 |
131 | /**
132 | * @brief Decode a auth_key message into a struct
133 | *
134 | * @param msg The message to decode
135 | * @param auth_key C-struct to decode the message contents into
136 | */
137 | static inline void mavlink_msg_auth_key_decode(const mavlink_message_t* msg, mavlink_auth_key_t* auth_key)
138 | {
139 | #if MAVLINK_NEED_BYTE_SWAP
140 | mavlink_msg_auth_key_get_key(msg, auth_key->key);
141 | #else
142 | memcpy(auth_key, _MAV_PAYLOAD(msg), 32);
143 | #endif
144 | }
145 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v1.0/common/mavlink_msg_auth_key.h:
--------------------------------------------------------------------------------
1 | // MESSAGE AUTH_KEY PACKING
2 |
3 | #define MAVLINK_MSG_ID_AUTH_KEY 7
4 |
5 | typedef struct __mavlink_auth_key_t
6 | {
7 | char key[32]; ///< key
8 | } mavlink_auth_key_t;
9 |
10 | #define MAVLINK_MSG_ID_AUTH_KEY_LEN 32
11 | #define MAVLINK_MSG_ID_7_LEN 32
12 |
13 | #define MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN 32
14 |
15 | #define MAVLINK_MESSAGE_INFO_AUTH_KEY { \
16 | "AUTH_KEY", \
17 | 1, \
18 | { { "key", NULL, MAVLINK_TYPE_CHAR, 32, 0, offsetof(mavlink_auth_key_t, key) }, \
19 | } \
20 | }
21 |
22 |
23 | /**
24 | * @brief Pack a auth_key message
25 | * @param system_id ID of this system
26 | * @param component_id ID of this component (e.g. 200 for IMU)
27 | * @param msg The MAVLink message to compress the data into
28 | *
29 | * @param key key
30 | * @return length of the message in bytes (excluding serial stream start sign)
31 | */
32 | static inline uint16_t mavlink_msg_auth_key_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
33 | const char *key)
34 | {
35 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
36 | char buf[32];
37 |
38 | _mav_put_char_array(buf, 0, key, 32);
39 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32);
40 | #else
41 | mavlink_auth_key_t packet;
42 |
43 | mav_array_memcpy(packet.key, key, sizeof(char)*32);
44 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32);
45 | #endif
46 |
47 | msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
48 | return mavlink_finalize_message(msg, system_id, component_id, 32, 119);
49 | }
50 |
51 | /**
52 | * @brief Pack a auth_key message on a channel
53 | * @param system_id ID of this system
54 | * @param component_id ID of this component (e.g. 200 for IMU)
55 | * @param chan The MAVLink channel this message was sent over
56 | * @param msg The MAVLink message to compress the data into
57 | * @param key key
58 | * @return length of the message in bytes (excluding serial stream start sign)
59 | */
60 | static inline uint16_t mavlink_msg_auth_key_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
61 | mavlink_message_t* msg,
62 | const char *key)
63 | {
64 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
65 | char buf[32];
66 |
67 | _mav_put_char_array(buf, 0, key, 32);
68 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32);
69 | #else
70 | mavlink_auth_key_t packet;
71 |
72 | mav_array_memcpy(packet.key, key, sizeof(char)*32);
73 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32);
74 | #endif
75 |
76 | msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
77 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 32, 119);
78 | }
79 |
80 | /**
81 | * @brief Encode a auth_key struct into a message
82 | *
83 | * @param system_id ID of this system
84 | * @param component_id ID of this component (e.g. 200 for IMU)
85 | * @param msg The MAVLink message to compress the data into
86 | * @param auth_key C-struct to read the message contents from
87 | */
88 | 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)
89 | {
90 | return mavlink_msg_auth_key_pack(system_id, component_id, msg, auth_key->key);
91 | }
92 |
93 | /**
94 | * @brief Send a auth_key message
95 | * @param chan MAVLink channel to send the message
96 | *
97 | * @param key key
98 | */
99 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
100 |
101 | static inline void mavlink_msg_auth_key_send(mavlink_channel_t chan, const char *key)
102 | {
103 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
104 | char buf[32];
105 |
106 | _mav_put_char_array(buf, 0, key, 32);
107 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, buf, 32, 119);
108 | #else
109 | mavlink_auth_key_t packet;
110 |
111 | mav_array_memcpy(packet.key, key, sizeof(char)*32);
112 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)&packet, 32, 119);
113 | #endif
114 | }
115 |
116 | #endif
117 |
118 | // MESSAGE AUTH_KEY UNPACKING
119 |
120 |
121 | /**
122 | * @brief Get field key from auth_key message
123 | *
124 | * @return key
125 | */
126 | static inline uint16_t mavlink_msg_auth_key_get_key(const mavlink_message_t* msg, char *key)
127 | {
128 | return _MAV_RETURN_char_array(msg, key, 32, 0);
129 | }
130 |
131 | /**
132 | * @brief Decode a auth_key message into a struct
133 | *
134 | * @param msg The message to decode
135 | * @param auth_key C-struct to decode the message contents into
136 | */
137 | static inline void mavlink_msg_auth_key_decode(const mavlink_message_t* msg, mavlink_auth_key_t* auth_key)
138 | {
139 | #if MAVLINK_NEED_BYTE_SWAP
140 | mavlink_msg_auth_key_get_key(msg, auth_key->key);
141 | #else
142 | memcpy(auth_key, _MAV_PAYLOAD(msg), 32);
143 | #endif
144 | }
145 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v1.0/common/mavlink_msg_mission_current.h:
--------------------------------------------------------------------------------
1 | // MESSAGE MISSION_CURRENT PACKING
2 |
3 | #define MAVLINK_MSG_ID_MISSION_CURRENT 42
4 |
5 | typedef struct __mavlink_mission_current_t
6 | {
7 | uint16_t seq; ///< Sequence
8 | } mavlink_mission_current_t;
9 |
10 | #define MAVLINK_MSG_ID_MISSION_CURRENT_LEN 2
11 | #define MAVLINK_MSG_ID_42_LEN 2
12 |
13 |
14 |
15 | #define MAVLINK_MESSAGE_INFO_MISSION_CURRENT { \
16 | "MISSION_CURRENT", \
17 | 1, \
18 | { { "seq", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_mission_current_t, seq) }, \
19 | } \
20 | }
21 |
22 |
23 | /**
24 | * @brief Pack a mission_current message
25 | * @param system_id ID of this system
26 | * @param component_id ID of this component (e.g. 200 for IMU)
27 | * @param msg The MAVLink message to compress the data into
28 | *
29 | * @param seq Sequence
30 | * @return length of the message in bytes (excluding serial stream start sign)
31 | */
32 | static inline uint16_t mavlink_msg_mission_current_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
33 | uint16_t seq)
34 | {
35 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
36 | char buf[2];
37 | _mav_put_uint16_t(buf, 0, seq);
38 |
39 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
40 | #else
41 | mavlink_mission_current_t packet;
42 | packet.seq = seq;
43 |
44 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
45 | #endif
46 |
47 | msg->msgid = MAVLINK_MSG_ID_MISSION_CURRENT;
48 | return mavlink_finalize_message(msg, system_id, component_id, 2, 28);
49 | }
50 |
51 | /**
52 | * @brief Pack a mission_current message on a channel
53 | * @param system_id ID of this system
54 | * @param component_id ID of this component (e.g. 200 for IMU)
55 | * @param chan The MAVLink channel this message was sent over
56 | * @param msg The MAVLink message to compress the data into
57 | * @param seq Sequence
58 | * @return length of the message in bytes (excluding serial stream start sign)
59 | */
60 | static inline uint16_t mavlink_msg_mission_current_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
61 | mavlink_message_t* msg,
62 | uint16_t seq)
63 | {
64 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
65 | char buf[2];
66 | _mav_put_uint16_t(buf, 0, seq);
67 |
68 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
69 | #else
70 | mavlink_mission_current_t packet;
71 | packet.seq = seq;
72 |
73 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
74 | #endif
75 |
76 | msg->msgid = MAVLINK_MSG_ID_MISSION_CURRENT;
77 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 2, 28);
78 | }
79 |
80 | /**
81 | * @brief Encode a mission_current struct into a message
82 | *
83 | * @param system_id ID of this system
84 | * @param component_id ID of this component (e.g. 200 for IMU)
85 | * @param msg The MAVLink message to compress the data into
86 | * @param mission_current C-struct to read the message contents from
87 | */
88 | static inline uint16_t mavlink_msg_mission_current_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mission_current_t* mission_current)
89 | {
90 | return mavlink_msg_mission_current_pack(system_id, component_id, msg, mission_current->seq);
91 | }
92 |
93 | /**
94 | * @brief Send a mission_current message
95 | * @param chan MAVLink channel to send the message
96 | *
97 | * @param seq Sequence
98 | */
99 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
100 |
101 | static inline void mavlink_msg_mission_current_send(mavlink_channel_t chan, uint16_t seq)
102 | {
103 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
104 | char buf[2];
105 | _mav_put_uint16_t(buf, 0, seq);
106 |
107 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_CURRENT, buf, 2, 28);
108 | #else
109 | mavlink_mission_current_t packet;
110 | packet.seq = seq;
111 |
112 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_CURRENT, (const char *)&packet, 2, 28);
113 | #endif
114 | }
115 |
116 | #endif
117 |
118 | // MESSAGE MISSION_CURRENT UNPACKING
119 |
120 |
121 | /**
122 | * @brief Get field seq from mission_current message
123 | *
124 | * @return Sequence
125 | */
126 | static inline uint16_t mavlink_msg_mission_current_get_seq(const mavlink_message_t* msg)
127 | {
128 | return _MAV_RETURN_uint16_t(msg, 0);
129 | }
130 |
131 | /**
132 | * @brief Decode a mission_current message into a struct
133 | *
134 | * @param msg The message to decode
135 | * @param mission_current C-struct to decode the message contents into
136 | */
137 | static inline void mavlink_msg_mission_current_decode(const mavlink_message_t* msg, mavlink_mission_current_t* mission_current)
138 | {
139 | #if MAVLINK_NEED_BYTE_SWAP
140 | mission_current->seq = mavlink_msg_mission_current_get_seq(msg);
141 | #else
142 | memcpy(mission_current, _MAV_PAYLOAD(msg), 2);
143 | #endif
144 | }
145 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/common/mavlink_msg_waypoint_current.h:
--------------------------------------------------------------------------------
1 | // MESSAGE WAYPOINT_CURRENT PACKING
2 |
3 | #define MAVLINK_MSG_ID_WAYPOINT_CURRENT 42
4 |
5 | typedef struct __mavlink_waypoint_current_t
6 | {
7 | uint16_t seq; ///< Sequence
8 | } mavlink_waypoint_current_t;
9 |
10 | #define MAVLINK_MSG_ID_WAYPOINT_CURRENT_LEN 2
11 | #define MAVLINK_MSG_ID_42_LEN 2
12 |
13 |
14 |
15 | #define MAVLINK_MESSAGE_INFO_WAYPOINT_CURRENT { \
16 | "WAYPOINT_CURRENT", \
17 | 1, \
18 | { { "seq", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_waypoint_current_t, seq) }, \
19 | } \
20 | }
21 |
22 |
23 | /**
24 | * @brief Pack a waypoint_current message
25 | * @param system_id ID of this system
26 | * @param component_id ID of this component (e.g. 200 for IMU)
27 | * @param msg The MAVLink message to compress the data into
28 | *
29 | * @param seq Sequence
30 | * @return length of the message in bytes (excluding serial stream start sign)
31 | */
32 | static inline uint16_t mavlink_msg_waypoint_current_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
33 | uint16_t seq)
34 | {
35 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
36 | char buf[2];
37 | _mav_put_uint16_t(buf, 0, seq);
38 |
39 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
40 | #else
41 | mavlink_waypoint_current_t packet;
42 | packet.seq = seq;
43 |
44 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
45 | #endif
46 |
47 | msg->msgid = MAVLINK_MSG_ID_WAYPOINT_CURRENT;
48 | return mavlink_finalize_message(msg, system_id, component_id, 2);
49 | }
50 |
51 | /**
52 | * @brief Pack a waypoint_current message on a channel
53 | * @param system_id ID of this system
54 | * @param component_id ID of this component (e.g. 200 for IMU)
55 | * @param chan The MAVLink channel this message was sent over
56 | * @param msg The MAVLink message to compress the data into
57 | * @param seq Sequence
58 | * @return length of the message in bytes (excluding serial stream start sign)
59 | */
60 | static inline uint16_t mavlink_msg_waypoint_current_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
61 | mavlink_message_t* msg,
62 | uint16_t seq)
63 | {
64 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
65 | char buf[2];
66 | _mav_put_uint16_t(buf, 0, seq);
67 |
68 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
69 | #else
70 | mavlink_waypoint_current_t packet;
71 | packet.seq = seq;
72 |
73 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
74 | #endif
75 |
76 | msg->msgid = MAVLINK_MSG_ID_WAYPOINT_CURRENT;
77 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 2);
78 | }
79 |
80 | /**
81 | * @brief Encode a waypoint_current struct into a message
82 | *
83 | * @param system_id ID of this system
84 | * @param component_id ID of this component (e.g. 200 for IMU)
85 | * @param msg The MAVLink message to compress the data into
86 | * @param waypoint_current C-struct to read the message contents from
87 | */
88 | static inline uint16_t mavlink_msg_waypoint_current_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_waypoint_current_t* waypoint_current)
89 | {
90 | return mavlink_msg_waypoint_current_pack(system_id, component_id, msg, waypoint_current->seq);
91 | }
92 |
93 | /**
94 | * @brief Send a waypoint_current message
95 | * @param chan MAVLink channel to send the message
96 | *
97 | * @param seq Sequence
98 | */
99 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
100 |
101 | static inline void mavlink_msg_waypoint_current_send(mavlink_channel_t chan, uint16_t seq)
102 | {
103 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
104 | char buf[2];
105 | _mav_put_uint16_t(buf, 0, seq);
106 |
107 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WAYPOINT_CURRENT, buf, 2);
108 | #else
109 | mavlink_waypoint_current_t packet;
110 | packet.seq = seq;
111 |
112 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WAYPOINT_CURRENT, (const char *)&packet, 2);
113 | #endif
114 | }
115 |
116 | #endif
117 |
118 | // MESSAGE WAYPOINT_CURRENT UNPACKING
119 |
120 |
121 | /**
122 | * @brief Get field seq from waypoint_current message
123 | *
124 | * @return Sequence
125 | */
126 | static inline uint16_t mavlink_msg_waypoint_current_get_seq(const mavlink_message_t* msg)
127 | {
128 | return _MAV_RETURN_uint16_t(msg, 0);
129 | }
130 |
131 | /**
132 | * @brief Decode a waypoint_current message into a struct
133 | *
134 | * @param msg The message to decode
135 | * @param waypoint_current C-struct to decode the message contents into
136 | */
137 | static inline void mavlink_msg_waypoint_current_decode(const mavlink_message_t* msg, mavlink_waypoint_current_t* waypoint_current)
138 | {
139 | #if MAVLINK_NEED_BYTE_SWAP
140 | waypoint_current->seq = mavlink_msg_waypoint_current_get_seq(msg);
141 | #else
142 | memcpy(waypoint_current, _MAV_PAYLOAD(msg), 2);
143 | #endif
144 | }
145 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/common/mavlink_msg_waypoint_reached.h:
--------------------------------------------------------------------------------
1 | // MESSAGE WAYPOINT_REACHED PACKING
2 |
3 | #define MAVLINK_MSG_ID_WAYPOINT_REACHED 46
4 |
5 | typedef struct __mavlink_waypoint_reached_t
6 | {
7 | uint16_t seq; ///< Sequence
8 | } mavlink_waypoint_reached_t;
9 |
10 | #define MAVLINK_MSG_ID_WAYPOINT_REACHED_LEN 2
11 | #define MAVLINK_MSG_ID_46_LEN 2
12 |
13 |
14 |
15 | #define MAVLINK_MESSAGE_INFO_WAYPOINT_REACHED { \
16 | "WAYPOINT_REACHED", \
17 | 1, \
18 | { { "seq", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_waypoint_reached_t, seq) }, \
19 | } \
20 | }
21 |
22 |
23 | /**
24 | * @brief Pack a waypoint_reached message
25 | * @param system_id ID of this system
26 | * @param component_id ID of this component (e.g. 200 for IMU)
27 | * @param msg The MAVLink message to compress the data into
28 | *
29 | * @param seq Sequence
30 | * @return length of the message in bytes (excluding serial stream start sign)
31 | */
32 | static inline uint16_t mavlink_msg_waypoint_reached_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
33 | uint16_t seq)
34 | {
35 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
36 | char buf[2];
37 | _mav_put_uint16_t(buf, 0, seq);
38 |
39 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
40 | #else
41 | mavlink_waypoint_reached_t packet;
42 | packet.seq = seq;
43 |
44 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
45 | #endif
46 |
47 | msg->msgid = MAVLINK_MSG_ID_WAYPOINT_REACHED;
48 | return mavlink_finalize_message(msg, system_id, component_id, 2);
49 | }
50 |
51 | /**
52 | * @brief Pack a waypoint_reached message on a channel
53 | * @param system_id ID of this system
54 | * @param component_id ID of this component (e.g. 200 for IMU)
55 | * @param chan The MAVLink channel this message was sent over
56 | * @param msg The MAVLink message to compress the data into
57 | * @param seq Sequence
58 | * @return length of the message in bytes (excluding serial stream start sign)
59 | */
60 | static inline uint16_t mavlink_msg_waypoint_reached_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
61 | mavlink_message_t* msg,
62 | uint16_t seq)
63 | {
64 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
65 | char buf[2];
66 | _mav_put_uint16_t(buf, 0, seq);
67 |
68 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
69 | #else
70 | mavlink_waypoint_reached_t packet;
71 | packet.seq = seq;
72 |
73 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
74 | #endif
75 |
76 | msg->msgid = MAVLINK_MSG_ID_WAYPOINT_REACHED;
77 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 2);
78 | }
79 |
80 | /**
81 | * @brief Encode a waypoint_reached struct into a message
82 | *
83 | * @param system_id ID of this system
84 | * @param component_id ID of this component (e.g. 200 for IMU)
85 | * @param msg The MAVLink message to compress the data into
86 | * @param waypoint_reached C-struct to read the message contents from
87 | */
88 | static inline uint16_t mavlink_msg_waypoint_reached_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_waypoint_reached_t* waypoint_reached)
89 | {
90 | return mavlink_msg_waypoint_reached_pack(system_id, component_id, msg, waypoint_reached->seq);
91 | }
92 |
93 | /**
94 | * @brief Send a waypoint_reached message
95 | * @param chan MAVLink channel to send the message
96 | *
97 | * @param seq Sequence
98 | */
99 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
100 |
101 | static inline void mavlink_msg_waypoint_reached_send(mavlink_channel_t chan, uint16_t seq)
102 | {
103 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
104 | char buf[2];
105 | _mav_put_uint16_t(buf, 0, seq);
106 |
107 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WAYPOINT_REACHED, buf, 2);
108 | #else
109 | mavlink_waypoint_reached_t packet;
110 | packet.seq = seq;
111 |
112 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WAYPOINT_REACHED, (const char *)&packet, 2);
113 | #endif
114 | }
115 |
116 | #endif
117 |
118 | // MESSAGE WAYPOINT_REACHED UNPACKING
119 |
120 |
121 | /**
122 | * @brief Get field seq from waypoint_reached message
123 | *
124 | * @return Sequence
125 | */
126 | static inline uint16_t mavlink_msg_waypoint_reached_get_seq(const mavlink_message_t* msg)
127 | {
128 | return _MAV_RETURN_uint16_t(msg, 0);
129 | }
130 |
131 | /**
132 | * @brief Decode a waypoint_reached message into a struct
133 | *
134 | * @param msg The message to decode
135 | * @param waypoint_reached C-struct to decode the message contents into
136 | */
137 | static inline void mavlink_msg_waypoint_reached_decode(const mavlink_message_t* msg, mavlink_waypoint_reached_t* waypoint_reached)
138 | {
139 | #if MAVLINK_NEED_BYTE_SWAP
140 | waypoint_reached->seq = mavlink_msg_waypoint_reached_get_seq(msg);
141 | #else
142 | memcpy(waypoint_reached, _MAV_PAYLOAD(msg), 2);
143 | #endif
144 | }
145 |
--------------------------------------------------------------------------------
/Libraries/AP_Math/matrix3.h:
--------------------------------------------------------------------------------
1 | // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
2 |
3 | // Copyright 2010 Michael Smith, all rights reserved.
4 |
5 | // This library is free software; you can redistribute it and / or
6 | // modify it under the terms of the GNU Lesser General Public
7 | // License as published by the Free Software Foundation; either
8 | // version 2.1 of the License, or (at your option) any later version.
9 |
10 | // Inspired by:
11 | /****************************************
12 | * 3D Vector Classes
13 | * By Bill Perone (billperone@yahoo.com)
14 | */
15 |
16 | //
17 | // 3x3 matrix implementation.
18 | //
19 | // Note that the matrix is organised in row-normal form (the same as
20 | // applies to array indexing).
21 | //
22 | // In addition to the template, this header defines the following types:
23 | //
24 | // Matrix3i 3x3 matrix of signed integers
25 | // Matrix3ui 3x3 matrix of unsigned integers
26 | // Matrix3l 3x3 matrix of signed longs
27 | // Matrix3ul 3x3 matrix of unsigned longs
28 | // Matrix3f 3x3 matrix of signed floats
29 | //
30 |
31 | #ifndef MATRIX3_H
32 | #define MATRIX3_H
33 |
34 | #include "vector3.h"
35 |
36 | // 3x3 matrix with elements of type T
37 | template
38 | class Matrix3 {
39 | public:
40 |
41 | // Vectors comprising the rows of the matrix
42 | Vector3 a, b, c;
43 |
44 | // trivial ctor
45 | // note that the Vector3 ctor will zero the vector elements
46 | Matrix3() {}
47 |
48 | // setting ctor
49 | Matrix3(const Vector3 a0, const Vector3 b0, const Vector3 c0): a(a0), b(b0), c(c0) {}
50 |
51 | // setting ctor
52 | Matrix3(const T ax, const T ay, const T az, const T bx, const T by, const T bz, const T cx, const T cy, const T cz): a(ax,ay,az), b(bx,by,bz), c(cx,cy,cz) {}
53 |
54 | // function call operator
55 | void operator () (const Vector3 a0, const Vector3 b0, const Vector3 c0)
56 | { a = a0; b = b0; c = c0; }
57 |
58 | // test for equality
59 | bool operator == (const Matrix3 &m)
60 | { return (a==m.a && b==m.b && c==m.c); }
61 |
62 | // test for inequality
63 | bool operator != (const Matrix3 &m)
64 | { return (a!=m.a || b!=m.b || c!=m.c); }
65 |
66 | // negation
67 | Matrix3 operator - (void) const
68 | { return Matrix3(-a,-b,-c); }
69 |
70 | // addition
71 | Matrix3 operator + (const Matrix3 &m) const
72 | { return Matrix3(a+m.a, b+m.b, c+m.c); }
73 | Matrix3 &operator += (const Matrix3 &m)
74 | { return *this = *this + m; }
75 |
76 | // subtraction
77 | Matrix3 operator - (const Matrix3 &m) const
78 | { return Matrix3(a-m.a, b-m.b, c-m.c); }
79 | Matrix3 &operator -= (const Matrix3 &m)
80 | { return *this = *this - m; }
81 |
82 | // uniform scaling
83 | Matrix3 operator * (const T num) const
84 | { return Matrix3(a*num, b*num, c*num); }
85 | Matrix3 &operator *= (const T num)
86 | { return *this = *this * num; }
87 | Matrix3 operator / (const T num) const
88 | { return Matrix3(a/num, b/num, c/num); }
89 | Matrix3 &operator /= (const T num)
90 | { return *this = *this / num; }
91 |
92 | // multiplication by a vector
93 | Vector3 operator *(const Vector3 &v) const;
94 |
95 | // multiplication of transpose by a vector
96 | Vector3 mul_transpose(const Vector3 &v) const;
97 |
98 | // multiplication by another Matrix3
99 | Matrix3 operator *(const Matrix3 &m) const;
100 |
101 | Matrix3 &operator *=(const Matrix3 &m)
102 | { return *this = *this * m; }
103 |
104 | // transpose the matrix
105 | Matrix3 transposed(void) const
106 | {
107 | return Matrix3(Vector3(a.x, b.x, c.x),
108 | Vector3(a.y, b.y, c.y),
109 | Vector3(a.z, b.z, c.z));
110 | }
111 | Matrix3 transpose(void)
112 | { return *this = transposed(); }
113 |
114 | // zero the matrix
115 | void zero(void) {
116 | a.x = a.y = a.z = 0;
117 | b.x = b.y = b.z = 0;
118 | c.x = c.y = c.z = 0;
119 | }
120 |
121 | // setup the identity matrix
122 | void identity(void) {
123 | a.x = b.y = c.z = 1;
124 | a.y = a.z = 0;
125 | b.x = b.z = 0;
126 | c.x = c.y = 0;
127 | }
128 |
129 | // check if any elements are NAN
130 | bool is_nan(void)
131 | { return a.is_nan() || b.is_nan() || c.is_nan(); }
132 |
133 | // fill in the matrix with a standard rotation
134 | void rotation(enum Rotation rotation);
135 |
136 | // create a rotation matrix from Euler angles
137 | void from_euler(float roll, float pitch, float yaw);
138 |
139 | // create eulers from a rotation matrix
140 | void to_euler(float *roll, float *pitch, float *yaw);
141 |
142 | // apply an additional rotation from a body frame gyro vector
143 | // to a rotation matrix.
144 | void rotate(const Vector3 &g);
145 | };
146 |
147 | typedef Matrix3 Matrix3i;
148 | typedef Matrix3 Matrix3ui;
149 | typedef Matrix3 Matrix3l;
150 | typedef Matrix3 Matrix3ul;
151 | typedef Matrix3 Matrix3f;
152 |
153 | #endif // MATRIX3_H
154 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v1.0/common/mavlink_msg_mission_item_reached.h:
--------------------------------------------------------------------------------
1 | // MESSAGE MISSION_ITEM_REACHED PACKING
2 |
3 | #define MAVLINK_MSG_ID_MISSION_ITEM_REACHED 46
4 |
5 | typedef struct __mavlink_mission_item_reached_t
6 | {
7 | uint16_t seq; ///< Sequence
8 | } mavlink_mission_item_reached_t;
9 |
10 | #define MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN 2
11 | #define MAVLINK_MSG_ID_46_LEN 2
12 |
13 |
14 |
15 | #define MAVLINK_MESSAGE_INFO_MISSION_ITEM_REACHED { \
16 | "MISSION_ITEM_REACHED", \
17 | 1, \
18 | { { "seq", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_mission_item_reached_t, seq) }, \
19 | } \
20 | }
21 |
22 |
23 | /**
24 | * @brief Pack a mission_item_reached message
25 | * @param system_id ID of this system
26 | * @param component_id ID of this component (e.g. 200 for IMU)
27 | * @param msg The MAVLink message to compress the data into
28 | *
29 | * @param seq Sequence
30 | * @return length of the message in bytes (excluding serial stream start sign)
31 | */
32 | static inline uint16_t mavlink_msg_mission_item_reached_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
33 | uint16_t seq)
34 | {
35 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
36 | char buf[2];
37 | _mav_put_uint16_t(buf, 0, seq);
38 |
39 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
40 | #else
41 | mavlink_mission_item_reached_t packet;
42 | packet.seq = seq;
43 |
44 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
45 | #endif
46 |
47 | msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM_REACHED;
48 | return mavlink_finalize_message(msg, system_id, component_id, 2, 11);
49 | }
50 |
51 | /**
52 | * @brief Pack a mission_item_reached message on a channel
53 | * @param system_id ID of this system
54 | * @param component_id ID of this component (e.g. 200 for IMU)
55 | * @param chan The MAVLink channel this message was sent over
56 | * @param msg The MAVLink message to compress the data into
57 | * @param seq Sequence
58 | * @return length of the message in bytes (excluding serial stream start sign)
59 | */
60 | static inline uint16_t mavlink_msg_mission_item_reached_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
61 | mavlink_message_t* msg,
62 | uint16_t seq)
63 | {
64 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
65 | char buf[2];
66 | _mav_put_uint16_t(buf, 0, seq);
67 |
68 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
69 | #else
70 | mavlink_mission_item_reached_t packet;
71 | packet.seq = seq;
72 |
73 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
74 | #endif
75 |
76 | msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM_REACHED;
77 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 2, 11);
78 | }
79 |
80 | /**
81 | * @brief Encode a mission_item_reached struct into a message
82 | *
83 | * @param system_id ID of this system
84 | * @param component_id ID of this component (e.g. 200 for IMU)
85 | * @param msg The MAVLink message to compress the data into
86 | * @param mission_item_reached C-struct to read the message contents from
87 | */
88 | static inline uint16_t mavlink_msg_mission_item_reached_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mission_item_reached_t* mission_item_reached)
89 | {
90 | return mavlink_msg_mission_item_reached_pack(system_id, component_id, msg, mission_item_reached->seq);
91 | }
92 |
93 | /**
94 | * @brief Send a mission_item_reached message
95 | * @param chan MAVLink channel to send the message
96 | *
97 | * @param seq Sequence
98 | */
99 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
100 |
101 | static inline void mavlink_msg_mission_item_reached_send(mavlink_channel_t chan, uint16_t seq)
102 | {
103 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
104 | char buf[2];
105 | _mav_put_uint16_t(buf, 0, seq);
106 |
107 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED, buf, 2, 11);
108 | #else
109 | mavlink_mission_item_reached_t packet;
110 | packet.seq = seq;
111 |
112 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED, (const char *)&packet, 2, 11);
113 | #endif
114 | }
115 |
116 | #endif
117 |
118 | // MESSAGE MISSION_ITEM_REACHED UNPACKING
119 |
120 |
121 | /**
122 | * @brief Get field seq from mission_item_reached message
123 | *
124 | * @return Sequence
125 | */
126 | static inline uint16_t mavlink_msg_mission_item_reached_get_seq(const mavlink_message_t* msg)
127 | {
128 | return _MAV_RETURN_uint16_t(msg, 0);
129 | }
130 |
131 | /**
132 | * @brief Decode a mission_item_reached message into a struct
133 | *
134 | * @param msg The message to decode
135 | * @param mission_item_reached C-struct to decode the message contents into
136 | */
137 | static inline void mavlink_msg_mission_item_reached_decode(const mavlink_message_t* msg, mavlink_mission_item_reached_t* mission_item_reached)
138 | {
139 | #if MAVLINK_NEED_BYTE_SWAP
140 | mission_item_reached->seq = mavlink_msg_mission_item_reached_get_seq(msg);
141 | #else
142 | memcpy(mission_item_reached, _MAV_PAYLOAD(msg), 2);
143 | #endif
144 | }
145 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/common/mavlink_msg_system_time.h:
--------------------------------------------------------------------------------
1 | // MESSAGE SYSTEM_TIME PACKING
2 |
3 | #define MAVLINK_MSG_ID_SYSTEM_TIME 2
4 |
5 | typedef struct __mavlink_system_time_t
6 | {
7 | uint64_t time_usec; ///< Timestamp of the master clock in microseconds since UNIX epoch.
8 | } mavlink_system_time_t;
9 |
10 | #define MAVLINK_MSG_ID_SYSTEM_TIME_LEN 8
11 | #define MAVLINK_MSG_ID_2_LEN 8
12 |
13 |
14 |
15 | #define MAVLINK_MESSAGE_INFO_SYSTEM_TIME { \
16 | "SYSTEM_TIME", \
17 | 1, \
18 | { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_system_time_t, time_usec) }, \
19 | } \
20 | }
21 |
22 |
23 | /**
24 | * @brief Pack a system_time message
25 | * @param system_id ID of this system
26 | * @param component_id ID of this component (e.g. 200 for IMU)
27 | * @param msg The MAVLink message to compress the data into
28 | *
29 | * @param time_usec Timestamp of the master clock in microseconds since UNIX epoch.
30 | * @return length of the message in bytes (excluding serial stream start sign)
31 | */
32 | static inline uint16_t mavlink_msg_system_time_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
33 | uint64_t time_usec)
34 | {
35 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
36 | char buf[8];
37 | _mav_put_uint64_t(buf, 0, time_usec);
38 |
39 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8);
40 | #else
41 | mavlink_system_time_t packet;
42 | packet.time_usec = time_usec;
43 |
44 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8);
45 | #endif
46 |
47 | msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME;
48 | return mavlink_finalize_message(msg, system_id, component_id, 8);
49 | }
50 |
51 | /**
52 | * @brief Pack a system_time message on a channel
53 | * @param system_id ID of this system
54 | * @param component_id ID of this component (e.g. 200 for IMU)
55 | * @param chan The MAVLink channel this message was sent over
56 | * @param msg The MAVLink message to compress the data into
57 | * @param time_usec Timestamp of the master clock in microseconds since UNIX epoch.
58 | * @return length of the message in bytes (excluding serial stream start sign)
59 | */
60 | static inline uint16_t mavlink_msg_system_time_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
61 | mavlink_message_t* msg,
62 | uint64_t time_usec)
63 | {
64 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
65 | char buf[8];
66 | _mav_put_uint64_t(buf, 0, time_usec);
67 |
68 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8);
69 | #else
70 | mavlink_system_time_t packet;
71 | packet.time_usec = time_usec;
72 |
73 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8);
74 | #endif
75 |
76 | msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME;
77 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 8);
78 | }
79 |
80 | /**
81 | * @brief Encode a system_time struct into a message
82 | *
83 | * @param system_id ID of this system
84 | * @param component_id ID of this component (e.g. 200 for IMU)
85 | * @param msg The MAVLink message to compress the data into
86 | * @param system_time C-struct to read the message contents from
87 | */
88 | static inline uint16_t mavlink_msg_system_time_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_system_time_t* system_time)
89 | {
90 | return mavlink_msg_system_time_pack(system_id, component_id, msg, system_time->time_usec);
91 | }
92 |
93 | /**
94 | * @brief Send a system_time message
95 | * @param chan MAVLink channel to send the message
96 | *
97 | * @param time_usec Timestamp of the master clock in microseconds since UNIX epoch.
98 | */
99 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
100 |
101 | static inline void mavlink_msg_system_time_send(mavlink_channel_t chan, uint64_t time_usec)
102 | {
103 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
104 | char buf[8];
105 | _mav_put_uint64_t(buf, 0, time_usec);
106 |
107 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, buf, 8);
108 | #else
109 | mavlink_system_time_t packet;
110 | packet.time_usec = time_usec;
111 |
112 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)&packet, 8);
113 | #endif
114 | }
115 |
116 | #endif
117 |
118 | // MESSAGE SYSTEM_TIME UNPACKING
119 |
120 |
121 | /**
122 | * @brief Get field time_usec from system_time message
123 | *
124 | * @return Timestamp of the master clock in microseconds since UNIX epoch.
125 | */
126 | static inline uint64_t mavlink_msg_system_time_get_time_usec(const mavlink_message_t* msg)
127 | {
128 | return _MAV_RETURN_uint64_t(msg, 0);
129 | }
130 |
131 | /**
132 | * @brief Decode a system_time message into a struct
133 | *
134 | * @param msg The message to decode
135 | * @param system_time C-struct to decode the message contents into
136 | */
137 | static inline void mavlink_msg_system_time_decode(const mavlink_message_t* msg, mavlink_system_time_t* system_time)
138 | {
139 | #if MAVLINK_NEED_BYTE_SWAP
140 | system_time->time_usec = mavlink_msg_system_time_get_time_usec(msg);
141 | #else
142 | memcpy(system_time, _MAV_PAYLOAD(msg), 8);
143 | #endif
144 | }
145 |
--------------------------------------------------------------------------------
/Libraries/AP_Common/tools/eedump_apparam.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Simple tool to dump the AP_Param contents from an EEPROM dump
3 | * Andrew Tridgell February 2012
4 | */
5 | #include
6 | #include
7 | #include
8 |
9 | uint8_t eeprom[0x1000];
10 |
11 | #pragma pack(1)
12 |
13 | struct EEPROM_header {
14 | uint8_t magic[2];
15 | uint8_t revision;
16 | uint8_t spare;
17 | };
18 |
19 | static const uint16_t k_EEPROM_magic0 = 0x50;
20 | static const uint16_t k_EEPROM_magic1 = 0x41;
21 | static const uint16_t k_EEPROM_revision = 5;
22 |
23 | enum ap_var_type {
24 | AP_PARAM_NONE = 0,
25 | AP_PARAM_INT8,
26 | AP_PARAM_INT16,
27 | AP_PARAM_INT32,
28 | AP_PARAM_FLOAT,
29 | AP_PARAM_VECTOR3F,
30 | AP_PARAM_VECTOR6F,
31 | AP_PARAM_MATRIX3F,
32 | AP_PARAM_GROUP
33 | };
34 |
35 | static const char *type_names[8] = {
36 | "NONE", "INT8", "INT16", "INT32", "FLOAT", "VECTOR3F", "MATRIX6F", "GROUP"
37 | };
38 |
39 | struct Param_header {
40 | uint8_t key;
41 | uint8_t group_element;
42 | uint8_t type;
43 | };
44 |
45 |
46 | static const uint8_t _sentinal_key = 0xFF;
47 | static const uint8_t _sentinal_type = 0xFF;
48 | static const uint8_t _sentinal_group = 0xFF;
49 |
50 | static uint8_t type_size(enum ap_var_type type)
51 | {
52 | switch (type) {
53 | case AP_PARAM_NONE:
54 | case AP_PARAM_GROUP:
55 | return 0;
56 | case AP_PARAM_INT8:
57 | return 1;
58 | case AP_PARAM_INT16:
59 | return 2;
60 | case AP_PARAM_INT32:
61 | return 4;
62 | case AP_PARAM_FLOAT:
63 | return 4;
64 | case AP_PARAM_VECTOR3F:
65 | return 3*4;
66 | case AP_PARAM_VECTOR6F:
67 | return 6*4;
68 | case AP_PARAM_MATRIX3F:
69 | return 3*3*4;
70 | }
71 | printf("unknown type %u\n", type);
72 | return 0;
73 | }
74 |
75 | static void
76 | fail(const char *why)
77 | {
78 | fprintf(stderr, "ERROR: %s\n", why);
79 | exit(1);
80 | }
81 |
82 | int
83 | main(int argc, char *argv[])
84 | {
85 | FILE *fp;
86 | struct EEPROM_header *header;
87 | struct Param_header *var;
88 | unsigned index;
89 | unsigned i;
90 |
91 | if (argc != 2) {
92 | fail("missing EEPROM file name");
93 | }
94 | if (NULL == (fp = fopen(argv[1], "rb"))) {
95 | fail("can't open EEPROM file");
96 | }
97 | if (1 != fread(eeprom, sizeof(eeprom), 1, fp)) {
98 | fail("can't read EEPROM file");
99 | }
100 | fclose(fp);
101 |
102 | header = (struct EEPROM_header *)&eeprom[0];
103 | if (header->magic[0] != k_EEPROM_magic0 ||
104 | header->magic[1] != k_EEPROM_magic1) {
105 | fail("bad magic in EEPROM file");
106 | }
107 | if (header->revision != k_EEPROM_revision) {
108 | fail("unsupported EEPROM format revision");
109 | }
110 | printf("Header OK\n");
111 |
112 | index = sizeof(*header);
113 | for (;;) {
114 | uint8_t size;
115 | var = (struct Param_header *)&eeprom[index];
116 | if (var->key == _sentinal_key ||
117 | var->group_element == _sentinal_group ||
118 | var->type == _sentinal_type) {
119 | printf("end sentinel at %u\n", index);
120 | break;
121 | }
122 | size = type_size(var->type);
123 | printf("%04x: type %u (%s) key %u group_element %u size %d value ",
124 | index, var->type, type_names[var->type], var->key, var->group_element, size);
125 | index += sizeof(*var);
126 | switch (var->type) {
127 | case AP_PARAM_INT8:
128 | printf("%d\n", (int)*(int8_t *)&eeprom[index]);
129 | break;
130 | case AP_PARAM_INT16:
131 | printf("%d\n", (int)*(int16_t *)&eeprom[index]);
132 | break;
133 | case AP_PARAM_INT32:
134 | printf("%d\n", (int)*(int32_t *)&eeprom[index]);
135 | break;
136 | case AP_PARAM_FLOAT:
137 | printf("%f\n", *(float *)&eeprom[index]);
138 | break;
139 | case AP_PARAM_VECTOR3F:
140 | printf("%f %f %f\n",
141 | *(float *)&eeprom[index],
142 | *(float *)&eeprom[index+4],
143 | *(float *)&eeprom[index+8]);
144 | break;
145 | case AP_PARAM_VECTOR6F:
146 | printf("%f %f %f %f %f %f\n",
147 | *(float *)&eeprom[index],
148 | *(float *)&eeprom[index+4],
149 | *(float *)&eeprom[index+8],
150 | *(float *)&eeprom[index+12],
151 | *(float *)&eeprom[index+16],
152 | *(float *)&eeprom[index+20]);
153 | break;
154 | case AP_PARAM_MATRIX3F:
155 | printf("%f %f %f %f %f %f %f %f %f\n",
156 | *(float *)&eeprom[index],
157 | *(float *)&eeprom[index+4],
158 | *(float *)&eeprom[index+8],
159 | *(float *)&eeprom[index+12],
160 | *(float *)&eeprom[index+16],
161 | *(float *)&eeprom[index+20],
162 | *(float *)&eeprom[index+24],
163 | *(float *)&eeprom[index+28],
164 | *(float *)&eeprom[index+32]);
165 | break;
166 | default:
167 | printf("NONE\n");
168 | break;
169 | }
170 | for (i = 0; i < size; i++) {
171 | printf(" %02x", eeprom[index + i]);
172 | }
173 | printf("\n");
174 | index += size;
175 | if (index >= sizeof(eeprom)) {
176 | fflush(stdout);
177 | fail("missing end sentinel");
178 | }
179 | }
180 | return 0;
181 | }
182 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/common/mavlink_msg_debug.h:
--------------------------------------------------------------------------------
1 | // MESSAGE DEBUG PACKING
2 |
3 | #define MAVLINK_MSG_ID_DEBUG 255
4 |
5 | typedef struct __mavlink_debug_t
6 | {
7 | uint8_t ind; ///< index of debug variable
8 | float value; ///< DEBUG value
9 | } mavlink_debug_t;
10 |
11 | #define MAVLINK_MSG_ID_DEBUG_LEN 5
12 | #define MAVLINK_MSG_ID_255_LEN 5
13 |
14 |
15 |
16 | #define MAVLINK_MESSAGE_INFO_DEBUG { \
17 | "DEBUG", \
18 | 2, \
19 | { { "ind", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_debug_t, ind) }, \
20 | { "value", NULL, MAVLINK_TYPE_FLOAT, 0, 1, offsetof(mavlink_debug_t, value) }, \
21 | } \
22 | }
23 |
24 |
25 | /**
26 | * @brief Pack a debug message
27 | * @param system_id ID of this system
28 | * @param component_id ID of this component (e.g. 200 for IMU)
29 | * @param msg The MAVLink message to compress the data into
30 | *
31 | * @param ind index of debug variable
32 | * @param value DEBUG value
33 | * @return length of the message in bytes (excluding serial stream start sign)
34 | */
35 | static inline uint16_t mavlink_msg_debug_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
36 | uint8_t ind, float value)
37 | {
38 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
39 | char buf[5];
40 | _mav_put_uint8_t(buf, 0, ind);
41 | _mav_put_float(buf, 1, value);
42 |
43 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 5);
44 | #else
45 | mavlink_debug_t packet;
46 | packet.ind = ind;
47 | packet.value = value;
48 |
49 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 5);
50 | #endif
51 |
52 | msg->msgid = MAVLINK_MSG_ID_DEBUG;
53 | return mavlink_finalize_message(msg, system_id, component_id, 5);
54 | }
55 |
56 | /**
57 | * @brief Pack a debug message on a channel
58 | * @param system_id ID of this system
59 | * @param component_id ID of this component (e.g. 200 for IMU)
60 | * @param chan The MAVLink channel this message was sent over
61 | * @param msg The MAVLink message to compress the data into
62 | * @param ind index of debug variable
63 | * @param value DEBUG value
64 | * @return length of the message in bytes (excluding serial stream start sign)
65 | */
66 | static inline uint16_t mavlink_msg_debug_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
67 | mavlink_message_t* msg,
68 | uint8_t ind,float value)
69 | {
70 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 | char buf[5];
72 | _mav_put_uint8_t(buf, 0, ind);
73 | _mav_put_float(buf, 1, value);
74 |
75 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 5);
76 | #else
77 | mavlink_debug_t packet;
78 | packet.ind = ind;
79 | packet.value = value;
80 |
81 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 5);
82 | #endif
83 |
84 | msg->msgid = MAVLINK_MSG_ID_DEBUG;
85 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 5);
86 | }
87 |
88 | /**
89 | * @brief Encode a debug struct into a message
90 | *
91 | * @param system_id ID of this system
92 | * @param component_id ID of this component (e.g. 200 for IMU)
93 | * @param msg The MAVLink message to compress the data into
94 | * @param debug C-struct to read the message contents from
95 | */
96 | 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)
97 | {
98 | return mavlink_msg_debug_pack(system_id, component_id, msg, debug->ind, debug->value);
99 | }
100 |
101 | /**
102 | * @brief Send a debug message
103 | * @param chan MAVLink channel to send the message
104 | *
105 | * @param ind index of debug variable
106 | * @param value DEBUG value
107 | */
108 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
109 |
110 | static inline void mavlink_msg_debug_send(mavlink_channel_t chan, uint8_t ind, float value)
111 | {
112 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 | char buf[5];
114 | _mav_put_uint8_t(buf, 0, ind);
115 | _mav_put_float(buf, 1, value);
116 |
117 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, buf, 5);
118 | #else
119 | mavlink_debug_t packet;
120 | packet.ind = ind;
121 | packet.value = value;
122 |
123 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, (const char *)&packet, 5);
124 | #endif
125 | }
126 |
127 | #endif
128 |
129 | // MESSAGE DEBUG UNPACKING
130 |
131 |
132 | /**
133 | * @brief Get field ind from debug message
134 | *
135 | * @return index of debug variable
136 | */
137 | static inline uint8_t mavlink_msg_debug_get_ind(const mavlink_message_t* msg)
138 | {
139 | return _MAV_RETURN_uint8_t(msg, 0);
140 | }
141 |
142 | /**
143 | * @brief Get field value from debug message
144 | *
145 | * @return DEBUG value
146 | */
147 | static inline float mavlink_msg_debug_get_value(const mavlink_message_t* msg)
148 | {
149 | return _MAV_RETURN_float(msg, 1);
150 | }
151 |
152 | /**
153 | * @brief Decode a debug message into a struct
154 | *
155 | * @param msg The message to decode
156 | * @param debug C-struct to decode the message contents into
157 | */
158 | static inline void mavlink_msg_debug_decode(const mavlink_message_t* msg, mavlink_debug_t* debug)
159 | {
160 | #if MAVLINK_NEED_BYTE_SWAP
161 | debug->ind = mavlink_msg_debug_get_ind(msg);
162 | debug->value = mavlink_msg_debug_get_value(msg);
163 | #else
164 | memcpy(debug, _MAV_PAYLOAD(msg), 5);
165 | #endif
166 | }
167 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/ardupilotmega/mavlink_msg_meminfo.h:
--------------------------------------------------------------------------------
1 | // MESSAGE MEMINFO PACKING
2 |
3 | #define MAVLINK_MSG_ID_MEMINFO 152
4 |
5 | typedef struct __mavlink_meminfo_t
6 | {
7 | uint16_t brkval; ///< heap top
8 | uint16_t freemem; ///< free memory
9 | } mavlink_meminfo_t;
10 |
11 | #define MAVLINK_MSG_ID_MEMINFO_LEN 4
12 | #define MAVLINK_MSG_ID_152_LEN 4
13 |
14 |
15 |
16 | #define MAVLINK_MESSAGE_INFO_MEMINFO { \
17 | "MEMINFO", \
18 | 2, \
19 | { { "brkval", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_meminfo_t, brkval) }, \
20 | { "freemem", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_meminfo_t, freemem) }, \
21 | } \
22 | }
23 |
24 |
25 | /**
26 | * @brief Pack a meminfo message
27 | * @param system_id ID of this system
28 | * @param component_id ID of this component (e.g. 200 for IMU)
29 | * @param msg The MAVLink message to compress the data into
30 | *
31 | * @param brkval heap top
32 | * @param freemem free memory
33 | * @return length of the message in bytes (excluding serial stream start sign)
34 | */
35 | static inline uint16_t mavlink_msg_meminfo_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
36 | uint16_t brkval, uint16_t freemem)
37 | {
38 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
39 | char buf[4];
40 | _mav_put_uint16_t(buf, 0, brkval);
41 | _mav_put_uint16_t(buf, 2, freemem);
42 |
43 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4);
44 | #else
45 | mavlink_meminfo_t packet;
46 | packet.brkval = brkval;
47 | packet.freemem = freemem;
48 |
49 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4);
50 | #endif
51 |
52 | msg->msgid = MAVLINK_MSG_ID_MEMINFO;
53 | return mavlink_finalize_message(msg, system_id, component_id, 4);
54 | }
55 |
56 | /**
57 | * @brief Pack a meminfo message on a channel
58 | * @param system_id ID of this system
59 | * @param component_id ID of this component (e.g. 200 for IMU)
60 | * @param chan The MAVLink channel this message was sent over
61 | * @param msg The MAVLink message to compress the data into
62 | * @param brkval heap top
63 | * @param freemem free memory
64 | * @return length of the message in bytes (excluding serial stream start sign)
65 | */
66 | static inline uint16_t mavlink_msg_meminfo_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
67 | mavlink_message_t* msg,
68 | uint16_t brkval,uint16_t freemem)
69 | {
70 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 | char buf[4];
72 | _mav_put_uint16_t(buf, 0, brkval);
73 | _mav_put_uint16_t(buf, 2, freemem);
74 |
75 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4);
76 | #else
77 | mavlink_meminfo_t packet;
78 | packet.brkval = brkval;
79 | packet.freemem = freemem;
80 |
81 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4);
82 | #endif
83 |
84 | msg->msgid = MAVLINK_MSG_ID_MEMINFO;
85 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 4);
86 | }
87 |
88 | /**
89 | * @brief Encode a meminfo struct into a message
90 | *
91 | * @param system_id ID of this system
92 | * @param component_id ID of this component (e.g. 200 for IMU)
93 | * @param msg The MAVLink message to compress the data into
94 | * @param meminfo C-struct to read the message contents from
95 | */
96 | static inline uint16_t mavlink_msg_meminfo_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_meminfo_t* meminfo)
97 | {
98 | return mavlink_msg_meminfo_pack(system_id, component_id, msg, meminfo->brkval, meminfo->freemem);
99 | }
100 |
101 | /**
102 | * @brief Send a meminfo message
103 | * @param chan MAVLink channel to send the message
104 | *
105 | * @param brkval heap top
106 | * @param freemem free memory
107 | */
108 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
109 |
110 | static inline void mavlink_msg_meminfo_send(mavlink_channel_t chan, uint16_t brkval, uint16_t freemem)
111 | {
112 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 | char buf[4];
114 | _mav_put_uint16_t(buf, 0, brkval);
115 | _mav_put_uint16_t(buf, 2, freemem);
116 |
117 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MEMINFO, buf, 4);
118 | #else
119 | mavlink_meminfo_t packet;
120 | packet.brkval = brkval;
121 | packet.freemem = freemem;
122 |
123 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MEMINFO, (const char *)&packet, 4);
124 | #endif
125 | }
126 |
127 | #endif
128 |
129 | // MESSAGE MEMINFO UNPACKING
130 |
131 |
132 | /**
133 | * @brief Get field brkval from meminfo message
134 | *
135 | * @return heap top
136 | */
137 | static inline uint16_t mavlink_msg_meminfo_get_brkval(const mavlink_message_t* msg)
138 | {
139 | return _MAV_RETURN_uint16_t(msg, 0);
140 | }
141 |
142 | /**
143 | * @brief Get field freemem from meminfo message
144 | *
145 | * @return free memory
146 | */
147 | static inline uint16_t mavlink_msg_meminfo_get_freemem(const mavlink_message_t* msg)
148 | {
149 | return _MAV_RETURN_uint16_t(msg, 2);
150 | }
151 |
152 | /**
153 | * @brief Decode a meminfo message into a struct
154 | *
155 | * @param msg The message to decode
156 | * @param meminfo C-struct to decode the message contents into
157 | */
158 | static inline void mavlink_msg_meminfo_decode(const mavlink_message_t* msg, mavlink_meminfo_t* meminfo)
159 | {
160 | #if MAVLINK_NEED_BYTE_SWAP
161 | meminfo->brkval = mavlink_msg_meminfo_get_brkval(msg);
162 | meminfo->freemem = mavlink_msg_meminfo_get_freemem(msg);
163 | #else
164 | memcpy(meminfo, _MAV_PAYLOAD(msg), 4);
165 | #endif
166 | }
167 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/ardupilotmega/mavlink_msg_hwstatus.h:
--------------------------------------------------------------------------------
1 | // MESSAGE HWSTATUS PACKING
2 |
3 | #define MAVLINK_MSG_ID_HWSTATUS 165
4 |
5 | typedef struct __mavlink_hwstatus_t
6 | {
7 | uint16_t Vcc; ///< board voltage (mV)
8 | uint8_t I2Cerr; ///< I2C error count
9 | } mavlink_hwstatus_t;
10 |
11 | #define MAVLINK_MSG_ID_HWSTATUS_LEN 3
12 | #define MAVLINK_MSG_ID_165_LEN 3
13 |
14 |
15 |
16 | #define MAVLINK_MESSAGE_INFO_HWSTATUS { \
17 | "HWSTATUS", \
18 | 2, \
19 | { { "Vcc", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_hwstatus_t, Vcc) }, \
20 | { "I2Cerr", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_hwstatus_t, I2Cerr) }, \
21 | } \
22 | }
23 |
24 |
25 | /**
26 | * @brief Pack a hwstatus message
27 | * @param system_id ID of this system
28 | * @param component_id ID of this component (e.g. 200 for IMU)
29 | * @param msg The MAVLink message to compress the data into
30 | *
31 | * @param Vcc board voltage (mV)
32 | * @param I2Cerr I2C error count
33 | * @return length of the message in bytes (excluding serial stream start sign)
34 | */
35 | static inline uint16_t mavlink_msg_hwstatus_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
36 | uint16_t Vcc, uint8_t I2Cerr)
37 | {
38 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
39 | char buf[3];
40 | _mav_put_uint16_t(buf, 0, Vcc);
41 | _mav_put_uint8_t(buf, 2, I2Cerr);
42 |
43 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3);
44 | #else
45 | mavlink_hwstatus_t packet;
46 | packet.Vcc = Vcc;
47 | packet.I2Cerr = I2Cerr;
48 |
49 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3);
50 | #endif
51 |
52 | msg->msgid = MAVLINK_MSG_ID_HWSTATUS;
53 | return mavlink_finalize_message(msg, system_id, component_id, 3);
54 | }
55 |
56 | /**
57 | * @brief Pack a hwstatus message on a channel
58 | * @param system_id ID of this system
59 | * @param component_id ID of this component (e.g. 200 for IMU)
60 | * @param chan The MAVLink channel this message was sent over
61 | * @param msg The MAVLink message to compress the data into
62 | * @param Vcc board voltage (mV)
63 | * @param I2Cerr I2C error count
64 | * @return length of the message in bytes (excluding serial stream start sign)
65 | */
66 | static inline uint16_t mavlink_msg_hwstatus_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
67 | mavlink_message_t* msg,
68 | uint16_t Vcc,uint8_t I2Cerr)
69 | {
70 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 | char buf[3];
72 | _mav_put_uint16_t(buf, 0, Vcc);
73 | _mav_put_uint8_t(buf, 2, I2Cerr);
74 |
75 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3);
76 | #else
77 | mavlink_hwstatus_t packet;
78 | packet.Vcc = Vcc;
79 | packet.I2Cerr = I2Cerr;
80 |
81 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3);
82 | #endif
83 |
84 | msg->msgid = MAVLINK_MSG_ID_HWSTATUS;
85 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 3);
86 | }
87 |
88 | /**
89 | * @brief Encode a hwstatus struct into a message
90 | *
91 | * @param system_id ID of this system
92 | * @param component_id ID of this component (e.g. 200 for IMU)
93 | * @param msg The MAVLink message to compress the data into
94 | * @param hwstatus C-struct to read the message contents from
95 | */
96 | static inline uint16_t mavlink_msg_hwstatus_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_hwstatus_t* hwstatus)
97 | {
98 | return mavlink_msg_hwstatus_pack(system_id, component_id, msg, hwstatus->Vcc, hwstatus->I2Cerr);
99 | }
100 |
101 | /**
102 | * @brief Send a hwstatus message
103 | * @param chan MAVLink channel to send the message
104 | *
105 | * @param Vcc board voltage (mV)
106 | * @param I2Cerr I2C error count
107 | */
108 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
109 |
110 | static inline void mavlink_msg_hwstatus_send(mavlink_channel_t chan, uint16_t Vcc, uint8_t I2Cerr)
111 | {
112 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 | char buf[3];
114 | _mav_put_uint16_t(buf, 0, Vcc);
115 | _mav_put_uint8_t(buf, 2, I2Cerr);
116 |
117 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HWSTATUS, buf, 3);
118 | #else
119 | mavlink_hwstatus_t packet;
120 | packet.Vcc = Vcc;
121 | packet.I2Cerr = I2Cerr;
122 |
123 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HWSTATUS, (const char *)&packet, 3);
124 | #endif
125 | }
126 |
127 | #endif
128 |
129 | // MESSAGE HWSTATUS UNPACKING
130 |
131 |
132 | /**
133 | * @brief Get field Vcc from hwstatus message
134 | *
135 | * @return board voltage (mV)
136 | */
137 | static inline uint16_t mavlink_msg_hwstatus_get_Vcc(const mavlink_message_t* msg)
138 | {
139 | return _MAV_RETURN_uint16_t(msg, 0);
140 | }
141 |
142 | /**
143 | * @brief Get field I2Cerr from hwstatus message
144 | *
145 | * @return I2C error count
146 | */
147 | static inline uint8_t mavlink_msg_hwstatus_get_I2Cerr(const mavlink_message_t* msg)
148 | {
149 | return _MAV_RETURN_uint8_t(msg, 2);
150 | }
151 |
152 | /**
153 | * @brief Decode a hwstatus message into a struct
154 | *
155 | * @param msg The message to decode
156 | * @param hwstatus C-struct to decode the message contents into
157 | */
158 | static inline void mavlink_msg_hwstatus_decode(const mavlink_message_t* msg, mavlink_hwstatus_t* hwstatus)
159 | {
160 | #if MAVLINK_NEED_BYTE_SWAP
161 | hwstatus->Vcc = mavlink_msg_hwstatus_get_Vcc(msg);
162 | hwstatus->I2Cerr = mavlink_msg_hwstatus_get_I2Cerr(msg);
163 | #else
164 | memcpy(hwstatus, _MAV_PAYLOAD(msg), 3);
165 | #endif
166 | }
167 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v1.0/ardupilotmega/mavlink_msg_meminfo.h:
--------------------------------------------------------------------------------
1 | // MESSAGE MEMINFO PACKING
2 |
3 | #define MAVLINK_MSG_ID_MEMINFO 152
4 |
5 | typedef struct __mavlink_meminfo_t
6 | {
7 | uint16_t brkval; ///< heap top
8 | uint16_t freemem; ///< free memory
9 | } mavlink_meminfo_t;
10 |
11 | #define MAVLINK_MSG_ID_MEMINFO_LEN 4
12 | #define MAVLINK_MSG_ID_152_LEN 4
13 |
14 |
15 |
16 | #define MAVLINK_MESSAGE_INFO_MEMINFO { \
17 | "MEMINFO", \
18 | 2, \
19 | { { "brkval", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_meminfo_t, brkval) }, \
20 | { "freemem", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_meminfo_t, freemem) }, \
21 | } \
22 | }
23 |
24 |
25 | /**
26 | * @brief Pack a meminfo message
27 | * @param system_id ID of this system
28 | * @param component_id ID of this component (e.g. 200 for IMU)
29 | * @param msg The MAVLink message to compress the data into
30 | *
31 | * @param brkval heap top
32 | * @param freemem free memory
33 | * @return length of the message in bytes (excluding serial stream start sign)
34 | */
35 | static inline uint16_t mavlink_msg_meminfo_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
36 | uint16_t brkval, uint16_t freemem)
37 | {
38 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
39 | char buf[4];
40 | _mav_put_uint16_t(buf, 0, brkval);
41 | _mav_put_uint16_t(buf, 2, freemem);
42 |
43 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4);
44 | #else
45 | mavlink_meminfo_t packet;
46 | packet.brkval = brkval;
47 | packet.freemem = freemem;
48 |
49 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4);
50 | #endif
51 |
52 | msg->msgid = MAVLINK_MSG_ID_MEMINFO;
53 | return mavlink_finalize_message(msg, system_id, component_id, 4, 208);
54 | }
55 |
56 | /**
57 | * @brief Pack a meminfo message on a channel
58 | * @param system_id ID of this system
59 | * @param component_id ID of this component (e.g. 200 for IMU)
60 | * @param chan The MAVLink channel this message was sent over
61 | * @param msg The MAVLink message to compress the data into
62 | * @param brkval heap top
63 | * @param freemem free memory
64 | * @return length of the message in bytes (excluding serial stream start sign)
65 | */
66 | static inline uint16_t mavlink_msg_meminfo_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
67 | mavlink_message_t* msg,
68 | uint16_t brkval,uint16_t freemem)
69 | {
70 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 | char buf[4];
72 | _mav_put_uint16_t(buf, 0, brkval);
73 | _mav_put_uint16_t(buf, 2, freemem);
74 |
75 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4);
76 | #else
77 | mavlink_meminfo_t packet;
78 | packet.brkval = brkval;
79 | packet.freemem = freemem;
80 |
81 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4);
82 | #endif
83 |
84 | msg->msgid = MAVLINK_MSG_ID_MEMINFO;
85 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 4, 208);
86 | }
87 |
88 | /**
89 | * @brief Encode a meminfo struct into a message
90 | *
91 | * @param system_id ID of this system
92 | * @param component_id ID of this component (e.g. 200 for IMU)
93 | * @param msg The MAVLink message to compress the data into
94 | * @param meminfo C-struct to read the message contents from
95 | */
96 | static inline uint16_t mavlink_msg_meminfo_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_meminfo_t* meminfo)
97 | {
98 | return mavlink_msg_meminfo_pack(system_id, component_id, msg, meminfo->brkval, meminfo->freemem);
99 | }
100 |
101 | /**
102 | * @brief Send a meminfo message
103 | * @param chan MAVLink channel to send the message
104 | *
105 | * @param brkval heap top
106 | * @param freemem free memory
107 | */
108 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
109 |
110 | static inline void mavlink_msg_meminfo_send(mavlink_channel_t chan, uint16_t brkval, uint16_t freemem)
111 | {
112 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 | char buf[4];
114 | _mav_put_uint16_t(buf, 0, brkval);
115 | _mav_put_uint16_t(buf, 2, freemem);
116 |
117 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MEMINFO, buf, 4, 208);
118 | #else
119 | mavlink_meminfo_t packet;
120 | packet.brkval = brkval;
121 | packet.freemem = freemem;
122 |
123 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MEMINFO, (const char *)&packet, 4, 208);
124 | #endif
125 | }
126 |
127 | #endif
128 |
129 | // MESSAGE MEMINFO UNPACKING
130 |
131 |
132 | /**
133 | * @brief Get field brkval from meminfo message
134 | *
135 | * @return heap top
136 | */
137 | static inline uint16_t mavlink_msg_meminfo_get_brkval(const mavlink_message_t* msg)
138 | {
139 | return _MAV_RETURN_uint16_t(msg, 0);
140 | }
141 |
142 | /**
143 | * @brief Get field freemem from meminfo message
144 | *
145 | * @return free memory
146 | */
147 | static inline uint16_t mavlink_msg_meminfo_get_freemem(const mavlink_message_t* msg)
148 | {
149 | return _MAV_RETURN_uint16_t(msg, 2);
150 | }
151 |
152 | /**
153 | * @brief Decode a meminfo message into a struct
154 | *
155 | * @param msg The message to decode
156 | * @param meminfo C-struct to decode the message contents into
157 | */
158 | static inline void mavlink_msg_meminfo_decode(const mavlink_message_t* msg, mavlink_meminfo_t* meminfo)
159 | {
160 | #if MAVLINK_NEED_BYTE_SWAP
161 | meminfo->brkval = mavlink_msg_meminfo_get_brkval(msg);
162 | meminfo->freemem = mavlink_msg_meminfo_get_freemem(msg);
163 | #else
164 | memcpy(meminfo, _MAV_PAYLOAD(msg), 4);
165 | #endif
166 | }
167 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v1.0/ardupilotmega/mavlink_msg_hwstatus.h:
--------------------------------------------------------------------------------
1 | // MESSAGE HWSTATUS PACKING
2 |
3 | #define MAVLINK_MSG_ID_HWSTATUS 165
4 |
5 | typedef struct __mavlink_hwstatus_t
6 | {
7 | uint16_t Vcc; ///< board voltage (mV)
8 | uint8_t I2Cerr; ///< I2C error count
9 | } mavlink_hwstatus_t;
10 |
11 | #define MAVLINK_MSG_ID_HWSTATUS_LEN 3
12 | #define MAVLINK_MSG_ID_165_LEN 3
13 |
14 |
15 |
16 | #define MAVLINK_MESSAGE_INFO_HWSTATUS { \
17 | "HWSTATUS", \
18 | 2, \
19 | { { "Vcc", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_hwstatus_t, Vcc) }, \
20 | { "I2Cerr", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_hwstatus_t, I2Cerr) }, \
21 | } \
22 | }
23 |
24 |
25 | /**
26 | * @brief Pack a hwstatus message
27 | * @param system_id ID of this system
28 | * @param component_id ID of this component (e.g. 200 for IMU)
29 | * @param msg The MAVLink message to compress the data into
30 | *
31 | * @param Vcc board voltage (mV)
32 | * @param I2Cerr I2C error count
33 | * @return length of the message in bytes (excluding serial stream start sign)
34 | */
35 | static inline uint16_t mavlink_msg_hwstatus_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
36 | uint16_t Vcc, uint8_t I2Cerr)
37 | {
38 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
39 | char buf[3];
40 | _mav_put_uint16_t(buf, 0, Vcc);
41 | _mav_put_uint8_t(buf, 2, I2Cerr);
42 |
43 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3);
44 | #else
45 | mavlink_hwstatus_t packet;
46 | packet.Vcc = Vcc;
47 | packet.I2Cerr = I2Cerr;
48 |
49 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3);
50 | #endif
51 |
52 | msg->msgid = MAVLINK_MSG_ID_HWSTATUS;
53 | return mavlink_finalize_message(msg, system_id, component_id, 3, 21);
54 | }
55 |
56 | /**
57 | * @brief Pack a hwstatus message on a channel
58 | * @param system_id ID of this system
59 | * @param component_id ID of this component (e.g. 200 for IMU)
60 | * @param chan The MAVLink channel this message was sent over
61 | * @param msg The MAVLink message to compress the data into
62 | * @param Vcc board voltage (mV)
63 | * @param I2Cerr I2C error count
64 | * @return length of the message in bytes (excluding serial stream start sign)
65 | */
66 | static inline uint16_t mavlink_msg_hwstatus_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
67 | mavlink_message_t* msg,
68 | uint16_t Vcc,uint8_t I2Cerr)
69 | {
70 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 | char buf[3];
72 | _mav_put_uint16_t(buf, 0, Vcc);
73 | _mav_put_uint8_t(buf, 2, I2Cerr);
74 |
75 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3);
76 | #else
77 | mavlink_hwstatus_t packet;
78 | packet.Vcc = Vcc;
79 | packet.I2Cerr = I2Cerr;
80 |
81 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3);
82 | #endif
83 |
84 | msg->msgid = MAVLINK_MSG_ID_HWSTATUS;
85 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 3, 21);
86 | }
87 |
88 | /**
89 | * @brief Encode a hwstatus struct into a message
90 | *
91 | * @param system_id ID of this system
92 | * @param component_id ID of this component (e.g. 200 for IMU)
93 | * @param msg The MAVLink message to compress the data into
94 | * @param hwstatus C-struct to read the message contents from
95 | */
96 | static inline uint16_t mavlink_msg_hwstatus_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_hwstatus_t* hwstatus)
97 | {
98 | return mavlink_msg_hwstatus_pack(system_id, component_id, msg, hwstatus->Vcc, hwstatus->I2Cerr);
99 | }
100 |
101 | /**
102 | * @brief Send a hwstatus message
103 | * @param chan MAVLink channel to send the message
104 | *
105 | * @param Vcc board voltage (mV)
106 | * @param I2Cerr I2C error count
107 | */
108 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
109 |
110 | static inline void mavlink_msg_hwstatus_send(mavlink_channel_t chan, uint16_t Vcc, uint8_t I2Cerr)
111 | {
112 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 | char buf[3];
114 | _mav_put_uint16_t(buf, 0, Vcc);
115 | _mav_put_uint8_t(buf, 2, I2Cerr);
116 |
117 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HWSTATUS, buf, 3, 21);
118 | #else
119 | mavlink_hwstatus_t packet;
120 | packet.Vcc = Vcc;
121 | packet.I2Cerr = I2Cerr;
122 |
123 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HWSTATUS, (const char *)&packet, 3, 21);
124 | #endif
125 | }
126 |
127 | #endif
128 |
129 | // MESSAGE HWSTATUS UNPACKING
130 |
131 |
132 | /**
133 | * @brief Get field Vcc from hwstatus message
134 | *
135 | * @return board voltage (mV)
136 | */
137 | static inline uint16_t mavlink_msg_hwstatus_get_Vcc(const mavlink_message_t* msg)
138 | {
139 | return _MAV_RETURN_uint16_t(msg, 0);
140 | }
141 |
142 | /**
143 | * @brief Get field I2Cerr from hwstatus message
144 | *
145 | * @return I2C error count
146 | */
147 | static inline uint8_t mavlink_msg_hwstatus_get_I2Cerr(const mavlink_message_t* msg)
148 | {
149 | return _MAV_RETURN_uint8_t(msg, 2);
150 | }
151 |
152 | /**
153 | * @brief Decode a hwstatus message into a struct
154 | *
155 | * @param msg The message to decode
156 | * @param hwstatus C-struct to decode the message contents into
157 | */
158 | static inline void mavlink_msg_hwstatus_decode(const mavlink_message_t* msg, mavlink_hwstatus_t* hwstatus)
159 | {
160 | #if MAVLINK_NEED_BYTE_SWAP
161 | hwstatus->Vcc = mavlink_msg_hwstatus_get_Vcc(msg);
162 | hwstatus->I2Cerr = mavlink_msg_hwstatus_get_I2Cerr(msg);
163 | #else
164 | memcpy(hwstatus, _MAV_PAYLOAD(msg), 3);
165 | #endif
166 | }
167 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/common/mavlink_msg_set_mode.h:
--------------------------------------------------------------------------------
1 | // MESSAGE SET_MODE PACKING
2 |
3 | #define MAVLINK_MSG_ID_SET_MODE 11
4 |
5 | typedef struct __mavlink_set_mode_t
6 | {
7 | uint8_t target; ///< The system setting the mode
8 | uint8_t mode; ///< The new mode
9 | } mavlink_set_mode_t;
10 |
11 | #define MAVLINK_MSG_ID_SET_MODE_LEN 2
12 | #define MAVLINK_MSG_ID_11_LEN 2
13 |
14 |
15 |
16 | #define MAVLINK_MESSAGE_INFO_SET_MODE { \
17 | "SET_MODE", \
18 | 2, \
19 | { { "target", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_set_mode_t, target) }, \
20 | { "mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_set_mode_t, mode) }, \
21 | } \
22 | }
23 |
24 |
25 | /**
26 | * @brief Pack a set_mode message
27 | * @param system_id ID of this system
28 | * @param component_id ID of this component (e.g. 200 for IMU)
29 | * @param msg The MAVLink message to compress the data into
30 | *
31 | * @param target The system setting the mode
32 | * @param mode The new mode
33 | * @return length of the message in bytes (excluding serial stream start sign)
34 | */
35 | static inline uint16_t mavlink_msg_set_mode_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
36 | uint8_t target, uint8_t mode)
37 | {
38 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
39 | char buf[2];
40 | _mav_put_uint8_t(buf, 0, target);
41 | _mav_put_uint8_t(buf, 1, mode);
42 |
43 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
44 | #else
45 | mavlink_set_mode_t packet;
46 | packet.target = target;
47 | packet.mode = mode;
48 |
49 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
50 | #endif
51 |
52 | msg->msgid = MAVLINK_MSG_ID_SET_MODE;
53 | return mavlink_finalize_message(msg, system_id, component_id, 2);
54 | }
55 |
56 | /**
57 | * @brief Pack a set_mode message on a channel
58 | * @param system_id ID of this system
59 | * @param component_id ID of this component (e.g. 200 for IMU)
60 | * @param chan The MAVLink channel this message was sent over
61 | * @param msg The MAVLink message to compress the data into
62 | * @param target The system setting the mode
63 | * @param mode The new mode
64 | * @return length of the message in bytes (excluding serial stream start sign)
65 | */
66 | static inline uint16_t mavlink_msg_set_mode_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
67 | mavlink_message_t* msg,
68 | uint8_t target,uint8_t mode)
69 | {
70 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 | char buf[2];
72 | _mav_put_uint8_t(buf, 0, target);
73 | _mav_put_uint8_t(buf, 1, mode);
74 |
75 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
76 | #else
77 | mavlink_set_mode_t packet;
78 | packet.target = target;
79 | packet.mode = mode;
80 |
81 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
82 | #endif
83 |
84 | msg->msgid = MAVLINK_MSG_ID_SET_MODE;
85 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 2);
86 | }
87 |
88 | /**
89 | * @brief Encode a set_mode struct into a message
90 | *
91 | * @param system_id ID of this system
92 | * @param component_id ID of this component (e.g. 200 for IMU)
93 | * @param msg The MAVLink message to compress the data into
94 | * @param set_mode C-struct to read the message contents from
95 | */
96 | static inline uint16_t mavlink_msg_set_mode_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_mode_t* set_mode)
97 | {
98 | return mavlink_msg_set_mode_pack(system_id, component_id, msg, set_mode->target, set_mode->mode);
99 | }
100 |
101 | /**
102 | * @brief Send a set_mode message
103 | * @param chan MAVLink channel to send the message
104 | *
105 | * @param target The system setting the mode
106 | * @param mode The new mode
107 | */
108 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
109 |
110 | static inline void mavlink_msg_set_mode_send(mavlink_channel_t chan, uint8_t target, uint8_t mode)
111 | {
112 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 | char buf[2];
114 | _mav_put_uint8_t(buf, 0, target);
115 | _mav_put_uint8_t(buf, 1, mode);
116 |
117 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MODE, buf, 2);
118 | #else
119 | mavlink_set_mode_t packet;
120 | packet.target = target;
121 | packet.mode = mode;
122 |
123 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MODE, (const char *)&packet, 2);
124 | #endif
125 | }
126 |
127 | #endif
128 |
129 | // MESSAGE SET_MODE UNPACKING
130 |
131 |
132 | /**
133 | * @brief Get field target from set_mode message
134 | *
135 | * @return The system setting the mode
136 | */
137 | static inline uint8_t mavlink_msg_set_mode_get_target(const mavlink_message_t* msg)
138 | {
139 | return _MAV_RETURN_uint8_t(msg, 0);
140 | }
141 |
142 | /**
143 | * @brief Get field mode from set_mode message
144 | *
145 | * @return The new mode
146 | */
147 | static inline uint8_t mavlink_msg_set_mode_get_mode(const mavlink_message_t* msg)
148 | {
149 | return _MAV_RETURN_uint8_t(msg, 1);
150 | }
151 |
152 | /**
153 | * @brief Decode a set_mode message into a struct
154 | *
155 | * @param msg The message to decode
156 | * @param set_mode C-struct to decode the message contents into
157 | */
158 | static inline void mavlink_msg_set_mode_decode(const mavlink_message_t* msg, mavlink_set_mode_t* set_mode)
159 | {
160 | #if MAVLINK_NEED_BYTE_SWAP
161 | set_mode->target = mavlink_msg_set_mode_get_target(msg);
162 | set_mode->mode = mavlink_msg_set_mode_get_mode(msg);
163 | #else
164 | memcpy(set_mode, _MAV_PAYLOAD(msg), 2);
165 | #endif
166 | }
167 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/common/mavlink_msg_action_ack.h:
--------------------------------------------------------------------------------
1 | // MESSAGE ACTION_ACK PACKING
2 |
3 | #define MAVLINK_MSG_ID_ACTION_ACK 9
4 |
5 | typedef struct __mavlink_action_ack_t
6 | {
7 | uint8_t action; ///< The action id
8 | uint8_t result; ///< 0: Action DENIED, 1: Action executed
9 | } mavlink_action_ack_t;
10 |
11 | #define MAVLINK_MSG_ID_ACTION_ACK_LEN 2
12 | #define MAVLINK_MSG_ID_9_LEN 2
13 |
14 |
15 |
16 | #define MAVLINK_MESSAGE_INFO_ACTION_ACK { \
17 | "ACTION_ACK", \
18 | 2, \
19 | { { "action", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_action_ack_t, action) }, \
20 | { "result", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_action_ack_t, result) }, \
21 | } \
22 | }
23 |
24 |
25 | /**
26 | * @brief Pack a action_ack message
27 | * @param system_id ID of this system
28 | * @param component_id ID of this component (e.g. 200 for IMU)
29 | * @param msg The MAVLink message to compress the data into
30 | *
31 | * @param action The action id
32 | * @param result 0: Action DENIED, 1: Action executed
33 | * @return length of the message in bytes (excluding serial stream start sign)
34 | */
35 | static inline uint16_t mavlink_msg_action_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
36 | uint8_t action, uint8_t result)
37 | {
38 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
39 | char buf[2];
40 | _mav_put_uint8_t(buf, 0, action);
41 | _mav_put_uint8_t(buf, 1, result);
42 |
43 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
44 | #else
45 | mavlink_action_ack_t packet;
46 | packet.action = action;
47 | packet.result = result;
48 |
49 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
50 | #endif
51 |
52 | msg->msgid = MAVLINK_MSG_ID_ACTION_ACK;
53 | return mavlink_finalize_message(msg, system_id, component_id, 2);
54 | }
55 |
56 | /**
57 | * @brief Pack a action_ack message on a channel
58 | * @param system_id ID of this system
59 | * @param component_id ID of this component (e.g. 200 for IMU)
60 | * @param chan The MAVLink channel this message was sent over
61 | * @param msg The MAVLink message to compress the data into
62 | * @param action The action id
63 | * @param result 0: Action DENIED, 1: Action executed
64 | * @return length of the message in bytes (excluding serial stream start sign)
65 | */
66 | static inline uint16_t mavlink_msg_action_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
67 | mavlink_message_t* msg,
68 | uint8_t action,uint8_t result)
69 | {
70 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 | char buf[2];
72 | _mav_put_uint8_t(buf, 0, action);
73 | _mav_put_uint8_t(buf, 1, result);
74 |
75 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
76 | #else
77 | mavlink_action_ack_t packet;
78 | packet.action = action;
79 | packet.result = result;
80 |
81 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
82 | #endif
83 |
84 | msg->msgid = MAVLINK_MSG_ID_ACTION_ACK;
85 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 2);
86 | }
87 |
88 | /**
89 | * @brief Encode a action_ack struct into a message
90 | *
91 | * @param system_id ID of this system
92 | * @param component_id ID of this component (e.g. 200 for IMU)
93 | * @param msg The MAVLink message to compress the data into
94 | * @param action_ack C-struct to read the message contents from
95 | */
96 | 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)
97 | {
98 | return mavlink_msg_action_ack_pack(system_id, component_id, msg, action_ack->action, action_ack->result);
99 | }
100 |
101 | /**
102 | * @brief Send a action_ack message
103 | * @param chan MAVLink channel to send the message
104 | *
105 | * @param action The action id
106 | * @param result 0: Action DENIED, 1: Action executed
107 | */
108 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
109 |
110 | static inline void mavlink_msg_action_ack_send(mavlink_channel_t chan, uint8_t action, uint8_t result)
111 | {
112 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 | char buf[2];
114 | _mav_put_uint8_t(buf, 0, action);
115 | _mav_put_uint8_t(buf, 1, result);
116 |
117 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ACTION_ACK, buf, 2);
118 | #else
119 | mavlink_action_ack_t packet;
120 | packet.action = action;
121 | packet.result = result;
122 |
123 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ACTION_ACK, (const char *)&packet, 2);
124 | #endif
125 | }
126 |
127 | #endif
128 |
129 | // MESSAGE ACTION_ACK UNPACKING
130 |
131 |
132 | /**
133 | * @brief Get field action from action_ack message
134 | *
135 | * @return The action id
136 | */
137 | static inline uint8_t mavlink_msg_action_ack_get_action(const mavlink_message_t* msg)
138 | {
139 | return _MAV_RETURN_uint8_t(msg, 0);
140 | }
141 |
142 | /**
143 | * @brief Get field result from action_ack message
144 | *
145 | * @return 0: Action DENIED, 1: Action executed
146 | */
147 | static inline uint8_t mavlink_msg_action_ack_get_result(const mavlink_message_t* msg)
148 | {
149 | return _MAV_RETURN_uint8_t(msg, 1);
150 | }
151 |
152 | /**
153 | * @brief Decode a action_ack message into a struct
154 | *
155 | * @param msg The message to decode
156 | * @param action_ack C-struct to decode the message contents into
157 | */
158 | static inline void mavlink_msg_action_ack_decode(const mavlink_message_t* msg, mavlink_action_ack_t* action_ack)
159 | {
160 | #if MAVLINK_NEED_BYTE_SWAP
161 | action_ack->action = mavlink_msg_action_ack_get_action(msg);
162 | action_ack->result = mavlink_msg_action_ack_get_result(msg);
163 | #else
164 | memcpy(action_ack, _MAV_PAYLOAD(msg), 2);
165 | #endif
166 | }
167 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/common/mavlink_msg_set_altitude.h:
--------------------------------------------------------------------------------
1 | // MESSAGE SET_ALTITUDE PACKING
2 |
3 | #define MAVLINK_MSG_ID_SET_ALTITUDE 65
4 |
5 | typedef struct __mavlink_set_altitude_t
6 | {
7 | uint8_t target; ///< The system setting the altitude
8 | uint32_t mode; ///< The new altitude in meters
9 | } mavlink_set_altitude_t;
10 |
11 | #define MAVLINK_MSG_ID_SET_ALTITUDE_LEN 5
12 | #define MAVLINK_MSG_ID_65_LEN 5
13 |
14 |
15 |
16 | #define MAVLINK_MESSAGE_INFO_SET_ALTITUDE { \
17 | "SET_ALTITUDE", \
18 | 2, \
19 | { { "target", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_set_altitude_t, target) }, \
20 | { "mode", NULL, MAVLINK_TYPE_UINT32_T, 0, 1, offsetof(mavlink_set_altitude_t, mode) }, \
21 | } \
22 | }
23 |
24 |
25 | /**
26 | * @brief Pack a set_altitude message
27 | * @param system_id ID of this system
28 | * @param component_id ID of this component (e.g. 200 for IMU)
29 | * @param msg The MAVLink message to compress the data into
30 | *
31 | * @param target The system setting the altitude
32 | * @param mode The new altitude in meters
33 | * @return length of the message in bytes (excluding serial stream start sign)
34 | */
35 | static inline uint16_t mavlink_msg_set_altitude_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
36 | uint8_t target, uint32_t mode)
37 | {
38 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
39 | char buf[5];
40 | _mav_put_uint8_t(buf, 0, target);
41 | _mav_put_uint32_t(buf, 1, mode);
42 |
43 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 5);
44 | #else
45 | mavlink_set_altitude_t packet;
46 | packet.target = target;
47 | packet.mode = mode;
48 |
49 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 5);
50 | #endif
51 |
52 | msg->msgid = MAVLINK_MSG_ID_SET_ALTITUDE;
53 | return mavlink_finalize_message(msg, system_id, component_id, 5);
54 | }
55 |
56 | /**
57 | * @brief Pack a set_altitude message on a channel
58 | * @param system_id ID of this system
59 | * @param component_id ID of this component (e.g. 200 for IMU)
60 | * @param chan The MAVLink channel this message was sent over
61 | * @param msg The MAVLink message to compress the data into
62 | * @param target The system setting the altitude
63 | * @param mode The new altitude in meters
64 | * @return length of the message in bytes (excluding serial stream start sign)
65 | */
66 | static inline uint16_t mavlink_msg_set_altitude_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
67 | mavlink_message_t* msg,
68 | uint8_t target,uint32_t mode)
69 | {
70 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 | char buf[5];
72 | _mav_put_uint8_t(buf, 0, target);
73 | _mav_put_uint32_t(buf, 1, mode);
74 |
75 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 5);
76 | #else
77 | mavlink_set_altitude_t packet;
78 | packet.target = target;
79 | packet.mode = mode;
80 |
81 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 5);
82 | #endif
83 |
84 | msg->msgid = MAVLINK_MSG_ID_SET_ALTITUDE;
85 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 5);
86 | }
87 |
88 | /**
89 | * @brief Encode a set_altitude struct into a message
90 | *
91 | * @param system_id ID of this system
92 | * @param component_id ID of this component (e.g. 200 for IMU)
93 | * @param msg The MAVLink message to compress the data into
94 | * @param set_altitude C-struct to read the message contents from
95 | */
96 | static inline uint16_t mavlink_msg_set_altitude_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_altitude_t* set_altitude)
97 | {
98 | return mavlink_msg_set_altitude_pack(system_id, component_id, msg, set_altitude->target, set_altitude->mode);
99 | }
100 |
101 | /**
102 | * @brief Send a set_altitude message
103 | * @param chan MAVLink channel to send the message
104 | *
105 | * @param target The system setting the altitude
106 | * @param mode The new altitude in meters
107 | */
108 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
109 |
110 | static inline void mavlink_msg_set_altitude_send(mavlink_channel_t chan, uint8_t target, uint32_t mode)
111 | {
112 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 | char buf[5];
114 | _mav_put_uint8_t(buf, 0, target);
115 | _mav_put_uint32_t(buf, 1, mode);
116 |
117 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_ALTITUDE, buf, 5);
118 | #else
119 | mavlink_set_altitude_t packet;
120 | packet.target = target;
121 | packet.mode = mode;
122 |
123 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_ALTITUDE, (const char *)&packet, 5);
124 | #endif
125 | }
126 |
127 | #endif
128 |
129 | // MESSAGE SET_ALTITUDE UNPACKING
130 |
131 |
132 | /**
133 | * @brief Get field target from set_altitude message
134 | *
135 | * @return The system setting the altitude
136 | */
137 | static inline uint8_t mavlink_msg_set_altitude_get_target(const mavlink_message_t* msg)
138 | {
139 | return _MAV_RETURN_uint8_t(msg, 0);
140 | }
141 |
142 | /**
143 | * @brief Get field mode from set_altitude message
144 | *
145 | * @return The new altitude in meters
146 | */
147 | static inline uint32_t mavlink_msg_set_altitude_get_mode(const mavlink_message_t* msg)
148 | {
149 | return _MAV_RETURN_uint32_t(msg, 1);
150 | }
151 |
152 | /**
153 | * @brief Decode a set_altitude message into a struct
154 | *
155 | * @param msg The message to decode
156 | * @param set_altitude C-struct to decode the message contents into
157 | */
158 | static inline void mavlink_msg_set_altitude_decode(const mavlink_message_t* msg, mavlink_set_altitude_t* set_altitude)
159 | {
160 | #if MAVLINK_NEED_BYTE_SWAP
161 | set_altitude->target = mavlink_msg_set_altitude_get_target(msg);
162 | set_altitude->mode = mavlink_msg_set_altitude_get_mode(msg);
163 | #else
164 | memcpy(set_altitude, _MAV_PAYLOAD(msg), 5);
165 | #endif
166 | }
167 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/common/mavlink_msg_set_nav_mode.h:
--------------------------------------------------------------------------------
1 | // MESSAGE SET_NAV_MODE PACKING
2 |
3 | #define MAVLINK_MSG_ID_SET_NAV_MODE 12
4 |
5 | typedef struct __mavlink_set_nav_mode_t
6 | {
7 | uint8_t target; ///< The system setting the mode
8 | uint8_t nav_mode; ///< The new navigation mode
9 | } mavlink_set_nav_mode_t;
10 |
11 | #define MAVLINK_MSG_ID_SET_NAV_MODE_LEN 2
12 | #define MAVLINK_MSG_ID_12_LEN 2
13 |
14 |
15 |
16 | #define MAVLINK_MESSAGE_INFO_SET_NAV_MODE { \
17 | "SET_NAV_MODE", \
18 | 2, \
19 | { { "target", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_set_nav_mode_t, target) }, \
20 | { "nav_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_set_nav_mode_t, nav_mode) }, \
21 | } \
22 | }
23 |
24 |
25 | /**
26 | * @brief Pack a set_nav_mode message
27 | * @param system_id ID of this system
28 | * @param component_id ID of this component (e.g. 200 for IMU)
29 | * @param msg The MAVLink message to compress the data into
30 | *
31 | * @param target The system setting the mode
32 | * @param nav_mode The new navigation mode
33 | * @return length of the message in bytes (excluding serial stream start sign)
34 | */
35 | static inline uint16_t mavlink_msg_set_nav_mode_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
36 | uint8_t target, uint8_t nav_mode)
37 | {
38 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
39 | char buf[2];
40 | _mav_put_uint8_t(buf, 0, target);
41 | _mav_put_uint8_t(buf, 1, nav_mode);
42 |
43 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
44 | #else
45 | mavlink_set_nav_mode_t packet;
46 | packet.target = target;
47 | packet.nav_mode = nav_mode;
48 |
49 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
50 | #endif
51 |
52 | msg->msgid = MAVLINK_MSG_ID_SET_NAV_MODE;
53 | return mavlink_finalize_message(msg, system_id, component_id, 2);
54 | }
55 |
56 | /**
57 | * @brief Pack a set_nav_mode message on a channel
58 | * @param system_id ID of this system
59 | * @param component_id ID of this component (e.g. 200 for IMU)
60 | * @param chan The MAVLink channel this message was sent over
61 | * @param msg The MAVLink message to compress the data into
62 | * @param target The system setting the mode
63 | * @param nav_mode The new navigation mode
64 | * @return length of the message in bytes (excluding serial stream start sign)
65 | */
66 | static inline uint16_t mavlink_msg_set_nav_mode_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
67 | mavlink_message_t* msg,
68 | uint8_t target,uint8_t nav_mode)
69 | {
70 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 | char buf[2];
72 | _mav_put_uint8_t(buf, 0, target);
73 | _mav_put_uint8_t(buf, 1, nav_mode);
74 |
75 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2);
76 | #else
77 | mavlink_set_nav_mode_t packet;
78 | packet.target = target;
79 | packet.nav_mode = nav_mode;
80 |
81 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2);
82 | #endif
83 |
84 | msg->msgid = MAVLINK_MSG_ID_SET_NAV_MODE;
85 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 2);
86 | }
87 |
88 | /**
89 | * @brief Encode a set_nav_mode struct into a message
90 | *
91 | * @param system_id ID of this system
92 | * @param component_id ID of this component (e.g. 200 for IMU)
93 | * @param msg The MAVLink message to compress the data into
94 | * @param set_nav_mode C-struct to read the message contents from
95 | */
96 | static inline uint16_t mavlink_msg_set_nav_mode_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_nav_mode_t* set_nav_mode)
97 | {
98 | return mavlink_msg_set_nav_mode_pack(system_id, component_id, msg, set_nav_mode->target, set_nav_mode->nav_mode);
99 | }
100 |
101 | /**
102 | * @brief Send a set_nav_mode message
103 | * @param chan MAVLink channel to send the message
104 | *
105 | * @param target The system setting the mode
106 | * @param nav_mode The new navigation mode
107 | */
108 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
109 |
110 | static inline void mavlink_msg_set_nav_mode_send(mavlink_channel_t chan, uint8_t target, uint8_t nav_mode)
111 | {
112 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 | char buf[2];
114 | _mav_put_uint8_t(buf, 0, target);
115 | _mav_put_uint8_t(buf, 1, nav_mode);
116 |
117 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_NAV_MODE, buf, 2);
118 | #else
119 | mavlink_set_nav_mode_t packet;
120 | packet.target = target;
121 | packet.nav_mode = nav_mode;
122 |
123 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_NAV_MODE, (const char *)&packet, 2);
124 | #endif
125 | }
126 |
127 | #endif
128 |
129 | // MESSAGE SET_NAV_MODE UNPACKING
130 |
131 |
132 | /**
133 | * @brief Get field target from set_nav_mode message
134 | *
135 | * @return The system setting the mode
136 | */
137 | static inline uint8_t mavlink_msg_set_nav_mode_get_target(const mavlink_message_t* msg)
138 | {
139 | return _MAV_RETURN_uint8_t(msg, 0);
140 | }
141 |
142 | /**
143 | * @brief Get field nav_mode from set_nav_mode message
144 | *
145 | * @return The new navigation mode
146 | */
147 | static inline uint8_t mavlink_msg_set_nav_mode_get_nav_mode(const mavlink_message_t* msg)
148 | {
149 | return _MAV_RETURN_uint8_t(msg, 1);
150 | }
151 |
152 | /**
153 | * @brief Decode a set_nav_mode message into a struct
154 | *
155 | * @param msg The message to decode
156 | * @param set_nav_mode C-struct to decode the message contents into
157 | */
158 | static inline void mavlink_msg_set_nav_mode_decode(const mavlink_message_t* msg, mavlink_set_nav_mode_t* set_nav_mode)
159 | {
160 | #if MAVLINK_NEED_BYTE_SWAP
161 | set_nav_mode->target = mavlink_msg_set_nav_mode_get_target(msg);
162 | set_nav_mode->nav_mode = mavlink_msg_set_nav_mode_get_nav_mode(msg);
163 | #else
164 | memcpy(set_nav_mode, _MAV_PAYLOAD(msg), 2);
165 | #endif
166 | }
167 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v1.0/common/mavlink_msg_command_ack.h:
--------------------------------------------------------------------------------
1 | // MESSAGE COMMAND_ACK PACKING
2 |
3 | #define MAVLINK_MSG_ID_COMMAND_ACK 77
4 |
5 | typedef struct __mavlink_command_ack_t
6 | {
7 | uint16_t command; ///< Command ID, as defined by MAV_CMD enum.
8 | uint8_t result; ///< See MAV_RESULT enum
9 | } mavlink_command_ack_t;
10 |
11 | #define MAVLINK_MSG_ID_COMMAND_ACK_LEN 3
12 | #define MAVLINK_MSG_ID_77_LEN 3
13 |
14 |
15 |
16 | #define MAVLINK_MESSAGE_INFO_COMMAND_ACK { \
17 | "COMMAND_ACK", \
18 | 2, \
19 | { { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_command_ack_t, command) }, \
20 | { "result", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_command_ack_t, result) }, \
21 | } \
22 | }
23 |
24 |
25 | /**
26 | * @brief Pack a command_ack message
27 | * @param system_id ID of this system
28 | * @param component_id ID of this component (e.g. 200 for IMU)
29 | * @param msg The MAVLink message to compress the data into
30 | *
31 | * @param command Command ID, as defined by MAV_CMD enum.
32 | * @param result See MAV_RESULT enum
33 | * @return length of the message in bytes (excluding serial stream start sign)
34 | */
35 | static inline uint16_t mavlink_msg_command_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
36 | uint16_t command, uint8_t result)
37 | {
38 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
39 | char buf[3];
40 | _mav_put_uint16_t(buf, 0, command);
41 | _mav_put_uint8_t(buf, 2, result);
42 |
43 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3);
44 | #else
45 | mavlink_command_ack_t packet;
46 | packet.command = command;
47 | packet.result = result;
48 |
49 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3);
50 | #endif
51 |
52 | msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
53 | return mavlink_finalize_message(msg, system_id, component_id, 3, 143);
54 | }
55 |
56 | /**
57 | * @brief Pack a command_ack message on a channel
58 | * @param system_id ID of this system
59 | * @param component_id ID of this component (e.g. 200 for IMU)
60 | * @param chan The MAVLink channel this message was sent over
61 | * @param msg The MAVLink message to compress the data into
62 | * @param command Command ID, as defined by MAV_CMD enum.
63 | * @param result See MAV_RESULT enum
64 | * @return length of the message in bytes (excluding serial stream start sign)
65 | */
66 | static inline uint16_t mavlink_msg_command_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
67 | mavlink_message_t* msg,
68 | uint16_t command,uint8_t result)
69 | {
70 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 | char buf[3];
72 | _mav_put_uint16_t(buf, 0, command);
73 | _mav_put_uint8_t(buf, 2, result);
74 |
75 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3);
76 | #else
77 | mavlink_command_ack_t packet;
78 | packet.command = command;
79 | packet.result = result;
80 |
81 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3);
82 | #endif
83 |
84 | msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
85 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 3, 143);
86 | }
87 |
88 | /**
89 | * @brief Encode a command_ack struct into a message
90 | *
91 | * @param system_id ID of this system
92 | * @param component_id ID of this component (e.g. 200 for IMU)
93 | * @param msg The MAVLink message to compress the data into
94 | * @param command_ack C-struct to read the message contents from
95 | */
96 | 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)
97 | {
98 | return mavlink_msg_command_ack_pack(system_id, component_id, msg, command_ack->command, command_ack->result);
99 | }
100 |
101 | /**
102 | * @brief Send a command_ack message
103 | * @param chan MAVLink channel to send the message
104 | *
105 | * @param command Command ID, as defined by MAV_CMD enum.
106 | * @param result See MAV_RESULT enum
107 | */
108 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
109 |
110 | static inline void mavlink_msg_command_ack_send(mavlink_channel_t chan, uint16_t command, uint8_t result)
111 | {
112 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 | char buf[3];
114 | _mav_put_uint16_t(buf, 0, command);
115 | _mav_put_uint8_t(buf, 2, result);
116 |
117 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, buf, 3, 143);
118 | #else
119 | mavlink_command_ack_t packet;
120 | packet.command = command;
121 | packet.result = result;
122 |
123 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, (const char *)&packet, 3, 143);
124 | #endif
125 | }
126 |
127 | #endif
128 |
129 | // MESSAGE COMMAND_ACK UNPACKING
130 |
131 |
132 | /**
133 | * @brief Get field command from command_ack message
134 | *
135 | * @return Command ID, as defined by MAV_CMD enum.
136 | */
137 | static inline uint16_t mavlink_msg_command_ack_get_command(const mavlink_message_t* msg)
138 | {
139 | return _MAV_RETURN_uint16_t(msg, 0);
140 | }
141 |
142 | /**
143 | * @brief Get field result from command_ack message
144 | *
145 | * @return See MAV_RESULT enum
146 | */
147 | static inline uint8_t mavlink_msg_command_ack_get_result(const mavlink_message_t* msg)
148 | {
149 | return _MAV_RETURN_uint8_t(msg, 2);
150 | }
151 |
152 | /**
153 | * @brief Decode a command_ack message into a struct
154 | *
155 | * @param msg The message to decode
156 | * @param command_ack C-struct to decode the message contents into
157 | */
158 | static inline void mavlink_msg_command_ack_decode(const mavlink_message_t* msg, mavlink_command_ack_t* command_ack)
159 | {
160 | #if MAVLINK_NEED_BYTE_SWAP
161 | command_ack->command = mavlink_msg_command_ack_get_command(msg);
162 | command_ack->result = mavlink_msg_command_ack_get_result(msg);
163 | #else
164 | memcpy(command_ack, _MAV_PAYLOAD(msg), 3);
165 | #endif
166 | }
167 |
--------------------------------------------------------------------------------
/Libraries/AP_Common/include/menu.h:
--------------------------------------------------------------------------------
1 | // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
2 |
3 | /// @file menu.h
4 | /// @brief Simple commandline menu subsystem.
5 | /// @discussion
6 | /// The Menu class implements a simple CLI that accepts commands typed by
7 | /// the user, and passes the arguments to those commands to a function
8 | /// defined as handing the command.
9 | ///
10 | /// Commands are defined in an array of Menu::command structures passed
11 | /// to the constructor. Each entry in the array defines one command.
12 | ///
13 | /// Arguments passed to the handler function are pre-converted to both
14 | /// long and float for convenience.
15 |
16 | #ifndef __AP_COMMON_MENU_H
17 | #define __AP_COMMON_MENU_H
18 |
19 | #include
20 |
21 | #define MENU_COMMANDLINE_MAX 32 ///< maximum input line length
22 | #define MENU_ARGS_MAX 4 ///< maximum number of arguments
23 | #define MENU_COMMAND_MAX 14 ///< maximum size of a command name
24 |
25 | /// Class defining and handling one menu tree
26 | class Menu {
27 | public:
28 | /// argument passed to a menu function
29 | ///
30 | /// Space-delimited arguments are parsed from the commandline and
31 | /// separated into these structures.
32 | ///
33 | /// If the argument cannot be parsed as a float or a long, the value
34 | /// of f or i respectively is undefined. You should range-check
35 | /// the inputs to your function.
36 | ///
37 | struct arg {
38 | const char *str; ///< string form of the argument
39 | long i; ///< integer form of the argument (if a number)
40 | float f; ///< floating point form of the argument (if a number)
41 | };
42 |
43 | /// menu command function
44 | ///
45 | /// Functions called by menu array entries are expected to be of this
46 | /// type.
47 | ///
48 | /// @param argc The number of valid arguments, including the
49 | /// name of the command in argv[0]. Will never be
50 | /// more than MENU_ARGS_MAX.
51 | /// @param argv Pointer to an array of Menu::arg structures
52 | /// detailing any optional arguments given to the
53 | /// command. argv[0] is always the name of the
54 | /// command, so that the same function can be used
55 | /// to handle more than one command.
56 | ///
57 | typedef int8_t (*func)(uint8_t argc, const struct arg *argv);
58 |
59 | /// menu pre-prompt function
60 | ///
61 | /// Called immediately before waiting for the user to type a command; can be
62 | /// used to display help text or status, for example.
63 | ///
64 | /// If this function returns false, the menu exits.
65 | ///
66 | typedef bool (*preprompt)(void);
67 |
68 | /// menu command description
69 | ///
70 | struct command {
71 | /// Name of the command, as typed or received.
72 | /// Command names are limited in size to keep this structure compact.
73 | ///
74 | const char command[MENU_COMMAND_MAX];
75 |
76 | /// The function to call when the command is received.
77 | ///
78 | /// The argc argument will be at least 1, and no more than
79 | /// MENU_ARGS_MAX. The argv array will be populated with
80 | /// arguments typed/received up to MENU_ARGS_MAX. The command
81 | /// name will always be in argv[0].
82 | ///
83 | /// Commands may return -2 to cause the menu itself to exit.
84 | /// The "?", "help" and "exit" commands are always defined, but
85 | /// can be overridden by explicit entries in the command array.
86 | ///
87 | int8_t (*func)(uint8_t argc, const struct arg *argv); ///< callback function
88 | };
89 |
90 | /// constructor
91 | ///
92 | /// Note that you should normally not call the constructor directly. Use
93 | /// the MENU and MENU2 macros defined below.
94 | ///
95 | /// @param prompt The prompt to be displayed with this menu.
96 | /// @param commands An array of ::command structures in program memory (PROGMEM).
97 | /// @param entries The number of entries in the menu.
98 | ///
99 | Menu(const char *prompt, const struct command *commands, uint8_t entries, preprompt ppfunc = 0);
100 |
101 | /// menu runner
102 | void run(void);
103 |
104 | private:
105 | /// Implements the default 'help' command.
106 | ///
107 | void _help(void); ///< implements the 'help' command
108 |
109 | /// calls the function for the n'th menu item
110 | ///
111 | /// @param n Index for the menu item to call
112 | /// @param argc Number of arguments prepared for the menu item
113 | ///
114 | int8_t _call(uint8_t n, uint8_t argc);
115 |
116 | const char *_prompt; ///< prompt to display
117 | const command *_commands; ///< array of commands
118 | const uint8_t _entries; ///< size of the menu
119 | const preprompt _ppfunc; ///< optional pre-prompt action
120 |
121 | static char _inbuf[MENU_COMMANDLINE_MAX]; ///< input buffer
122 | static arg _argv[MENU_ARGS_MAX + 1]; ///< arguments
123 | };
124 |
125 | /// Macros used to define a menu.
126 | ///
127 | /// The commands argument should be an arary of Menu::command structures, one
128 | /// per command name. The array does not need to be terminated with any special
129 | /// record.
130 | ///
131 | /// Use name.run() to run the menu.
132 | ///
133 | /// The MENU2 macro supports the optional pre-prompt printing function.
134 | ///
135 | #define MENU(name, prompt, commands) \
136 | static const char __menu_name__ ##name[] PROGMEM = prompt; \
137 | static Menu name(__menu_name__ ##name, commands, sizeof(commands) / sizeof(commands[0]))
138 |
139 | #define MENU2(name, prompt, commands, preprompt) \
140 | static const char __menu_name__ ##name[] PROGMEM = prompt; \
141 | static Menu name(__menu_name__ ##name, commands, sizeof(commands) / sizeof(commands[0]), preprompt)
142 |
143 | #endif
144 |
--------------------------------------------------------------------------------
/Libraries/GCS_MAVLink/include/mavlink/v0.9/common/mavlink_msg_system_time_utc.h:
--------------------------------------------------------------------------------
1 | // MESSAGE SYSTEM_TIME_UTC PACKING
2 |
3 | #define MAVLINK_MSG_ID_SYSTEM_TIME_UTC 4
4 |
5 | typedef struct __mavlink_system_time_utc_t
6 | {
7 | uint32_t utc_date; ///< GPS UTC date ddmmyy
8 | uint32_t utc_time; ///< GPS UTC time hhmmss
9 | } mavlink_system_time_utc_t;
10 |
11 | #define MAVLINK_MSG_ID_SYSTEM_TIME_UTC_LEN 8
12 | #define MAVLINK_MSG_ID_4_LEN 8
13 |
14 |
15 |
16 | #define MAVLINK_MESSAGE_INFO_SYSTEM_TIME_UTC { \
17 | "SYSTEM_TIME_UTC", \
18 | 2, \
19 | { { "utc_date", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_system_time_utc_t, utc_date) }, \
20 | { "utc_time", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_system_time_utc_t, utc_time) }, \
21 | } \
22 | }
23 |
24 |
25 | /**
26 | * @brief Pack a system_time_utc message
27 | * @param system_id ID of this system
28 | * @param component_id ID of this component (e.g. 200 for IMU)
29 | * @param msg The MAVLink message to compress the data into
30 | *
31 | * @param utc_date GPS UTC date ddmmyy
32 | * @param utc_time GPS UTC time hhmmss
33 | * @return length of the message in bytes (excluding serial stream start sign)
34 | */
35 | static inline uint16_t mavlink_msg_system_time_utc_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
36 | uint32_t utc_date, uint32_t utc_time)
37 | {
38 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
39 | char buf[8];
40 | _mav_put_uint32_t(buf, 0, utc_date);
41 | _mav_put_uint32_t(buf, 4, utc_time);
42 |
43 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8);
44 | #else
45 | mavlink_system_time_utc_t packet;
46 | packet.utc_date = utc_date;
47 | packet.utc_time = utc_time;
48 |
49 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8);
50 | #endif
51 |
52 | msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME_UTC;
53 | return mavlink_finalize_message(msg, system_id, component_id, 8);
54 | }
55 |
56 | /**
57 | * @brief Pack a system_time_utc message on a channel
58 | * @param system_id ID of this system
59 | * @param component_id ID of this component (e.g. 200 for IMU)
60 | * @param chan The MAVLink channel this message was sent over
61 | * @param msg The MAVLink message to compress the data into
62 | * @param utc_date GPS UTC date ddmmyy
63 | * @param utc_time GPS UTC time hhmmss
64 | * @return length of the message in bytes (excluding serial stream start sign)
65 | */
66 | static inline uint16_t mavlink_msg_system_time_utc_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
67 | mavlink_message_t* msg,
68 | uint32_t utc_date,uint32_t utc_time)
69 | {
70 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 | char buf[8];
72 | _mav_put_uint32_t(buf, 0, utc_date);
73 | _mav_put_uint32_t(buf, 4, utc_time);
74 |
75 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8);
76 | #else
77 | mavlink_system_time_utc_t packet;
78 | packet.utc_date = utc_date;
79 | packet.utc_time = utc_time;
80 |
81 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8);
82 | #endif
83 |
84 | msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME_UTC;
85 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 8);
86 | }
87 |
88 | /**
89 | * @brief Encode a system_time_utc struct into a message
90 | *
91 | * @param system_id ID of this system
92 | * @param component_id ID of this component (e.g. 200 for IMU)
93 | * @param msg The MAVLink message to compress the data into
94 | * @param system_time_utc C-struct to read the message contents from
95 | */
96 | static inline uint16_t mavlink_msg_system_time_utc_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_system_time_utc_t* system_time_utc)
97 | {
98 | return mavlink_msg_system_time_utc_pack(system_id, component_id, msg, system_time_utc->utc_date, system_time_utc->utc_time);
99 | }
100 |
101 | /**
102 | * @brief Send a system_time_utc message
103 | * @param chan MAVLink channel to send the message
104 | *
105 | * @param utc_date GPS UTC date ddmmyy
106 | * @param utc_time GPS UTC time hhmmss
107 | */
108 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
109 |
110 | static inline void mavlink_msg_system_time_utc_send(mavlink_channel_t chan, uint32_t utc_date, uint32_t utc_time)
111 | {
112 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 | char buf[8];
114 | _mav_put_uint32_t(buf, 0, utc_date);
115 | _mav_put_uint32_t(buf, 4, utc_time);
116 |
117 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME_UTC, buf, 8);
118 | #else
119 | mavlink_system_time_utc_t packet;
120 | packet.utc_date = utc_date;
121 | packet.utc_time = utc_time;
122 |
123 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME_UTC, (const char *)&packet, 8);
124 | #endif
125 | }
126 |
127 | #endif
128 |
129 | // MESSAGE SYSTEM_TIME_UTC UNPACKING
130 |
131 |
132 | /**
133 | * @brief Get field utc_date from system_time_utc message
134 | *
135 | * @return GPS UTC date ddmmyy
136 | */
137 | static inline uint32_t mavlink_msg_system_time_utc_get_utc_date(const mavlink_message_t* msg)
138 | {
139 | return _MAV_RETURN_uint32_t(msg, 0);
140 | }
141 |
142 | /**
143 | * @brief Get field utc_time from system_time_utc message
144 | *
145 | * @return GPS UTC time hhmmss
146 | */
147 | static inline uint32_t mavlink_msg_system_time_utc_get_utc_time(const mavlink_message_t* msg)
148 | {
149 | return _MAV_RETURN_uint32_t(msg, 4);
150 | }
151 |
152 | /**
153 | * @brief Decode a system_time_utc message into a struct
154 | *
155 | * @param msg The message to decode
156 | * @param system_time_utc C-struct to decode the message contents into
157 | */
158 | static inline void mavlink_msg_system_time_utc_decode(const mavlink_message_t* msg, mavlink_system_time_utc_t* system_time_utc)
159 | {
160 | #if MAVLINK_NEED_BYTE_SWAP
161 | system_time_utc->utc_date = mavlink_msg_system_time_utc_get_utc_date(msg);
162 | system_time_utc->utc_time = mavlink_msg_system_time_utc_get_utc_time(msg);
163 | #else
164 | memcpy(system_time_utc, _MAV_PAYLOAD(msg), 8);
165 | #endif
166 | }
167 |
--------------------------------------------------------------------------------
/Libraries/FastSerial/ultoa_invert.S:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2005,2007 Dmitry Xmelkov
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in
11 | the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of the copyright holders nor the names of
14 | contributors may be used to endorse or promote products derived
15 | from this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 | POSSIBILITY OF SUCH DAMAGE. */
28 |
29 | /* $Id: ultoa_invert.S 1944 2009-04-01 23:12:20Z arcanum $ */
30 |
31 | #ifndef __DOXYGEN__
32 |
33 | #include "macros.inc"
34 | #include "ntz.h"
35 | #include "xtoa_fast.h"
36 |
37 | /* --------------------------------------------------------------------
38 | char * __ultoa_invert (unsigned long val, char * str, int base)
39 |
40 | This function is intended for usage as internal printf's one.
41 | It differs from others of `xtoa_fast' family:
42 | * srt[] will NOT 0 terminated.
43 | * Sequence of digits is inverted.
44 | * It returns pointer to first byte after a string.
45 | * Only `XTOA_UPPER' flag is operated.
46 | Notes:
47 | * base: check only 8 and 16, all others are treated as 10.
48 | (internal printf's function).
49 | */
50 |
51 | /* Input */
52 | #define v_lo r22
53 | #define v_hi r23
54 | #define v_hlo r24
55 | #define v_hhi r25
56 | #define str_lo r20
57 | #define str_hi r21
58 | #define base r18
59 | #define flags r19
60 |
61 | /* Used */
62 | #define v_fifth r26 /* val: bits 39..32 */
63 | #define t_lo r18 /* temporary for shifted `val' */
64 | #define t_hi r19
65 | #define t_hlo r20
66 | #define t_hhi r21
67 | #define symb r20 /* write to string */
68 | #define cnt r27 /* shift loop counter, local arg */
69 |
70 | /* Fixed */
71 | #define rzero r1
72 |
73 | /* ASSEMBLY_CLIB_SECTION */
74 | .global __ultoa_invert
75 | .type __ultoa_invert, "function"
76 |
77 | __ultoa_invert:
78 | X_movw ZL, str_lo
79 | clr v_fifth ; needed for all (ultoa_lsr)
80 | cpi base, 8
81 | breq .L_oct
82 | cpi base, 16
83 | breq .L_hex
84 |
85 | ; decimal format
86 | clt ; flag of val == 0
87 | .L_dec_loop:
88 | push v_lo ; to calculate remander
89 | ; val &= ~1
90 | andi v_lo, ~1
91 | ; val += 2
92 | subi v_lo, lo8(-2)
93 | sbci v_hi, hi8(-2)
94 | sbci v_hlo, hlo8(-2)
95 | sbci v_hhi, hhi8(-2)
96 | sbci v_fifth, hhi8(-2)
97 | ; val += val/2
98 | ldi cnt, 1
99 | rcall .L_div_add
100 | ; val += val/16
101 | ldi cnt, 4
102 | rcall .L_div_add
103 | ; val += val/256
104 | add v_lo, v_hi
105 | adc v_hi, v_hlo
106 | adc v_hlo, v_hhi
107 | adc v_hhi, v_fifth
108 | adc v_fifth, rzero
109 | ; val += val/65536
110 | add v_lo, v_hlo
111 | adc v_hi, v_hhi
112 | adc v_hlo, v_fifth
113 | adc v_hhi, rzero
114 | adc v_fifth, rzero
115 | ; val += val >> 32
116 | add v_lo, v_fifth
117 | adc v_hi, rzero
118 | adc v_hlo, rzero
119 | adc v_hhi, rzero
120 | adc v_fifth, rzero
121 | ; division result: val /= 16
122 | rcall .L_lsr_4 ; v_fitth := 0
123 | brne 1f
124 | set ; T := Z flag
125 | 1:
126 | ; rem: val_original - 10*val
127 | pop t_hi
128 | #if defined(__AVR_ENHANCED__) && __AVR_ENHANCED__
129 | ldi t_lo, 10
130 | mul t_lo, v_lo
131 | clr r1
132 | #else
133 | mov r0, v_lo
134 | lsl r0
135 | sub t_hi, r0
136 | lsl r0
137 | lsl r0
138 | #endif
139 | sub t_hi, r0
140 | ; output digit
141 | subi t_hi, lo8(-'0')
142 | st Z+, t_hi
143 | ; quotient == 0 ?
144 | brtc .L_dec_loop
145 | ; end of string
146 | .L_eos:
147 | X_movw r24, ZL
148 | ret
149 |
150 | ; octal format
151 | .L_oct:
152 | mov symb, v_lo
153 | andi symb, 7
154 | subi symb, lo8(-'0')
155 | st Z+, symb
156 | ldi cnt, 3
157 | rcall .L_lsr
158 | brne .L_oct
159 | rjmp .L_eos
160 |
161 | ; hex format
162 | .L_hex:
163 | mov symb, v_lo
164 | andi symb, 0x0f
165 | subi symb, lo8(-'0')
166 | cpi symb, '9' + 1
167 | brlo 3f
168 | subi symb, lo8('9' + 1 - 'a')
169 | sbrc flags, ntz(XTOA_UPPER) - 8
170 | subi symb, lo8('a' - 'A')
171 | 3: st Z+, symb
172 | rcall .L_lsr_4
173 | brne .L_hex
174 | rjmp .L_eos
175 |
176 | .L_lsr_4:
177 | ldi cnt, 4
178 | .L_lsr:
179 | lsr v_fifth
180 | ror v_hhi
181 | ror v_hlo
182 | ror v_hi
183 | ror v_lo
184 | dec cnt
185 | brne .L_lsr
186 | ; tst
187 | sbiw v_hlo, 0 ; only Z flag is needed
188 | cpc v_lo, rzero
189 | cpc v_hi, rzero
190 | ret
191 |
192 | .L_div_add:
193 | ; copy to temporary
194 | X_movw t_lo, v_lo
195 | X_movw t_hlo, v_hlo
196 | mov r0, v_fifth
197 | ; lsr temporary
198 | 7: lsr r0
199 | ror t_hhi
200 | ror t_hlo
201 | ror t_hi
202 | ror t_lo
203 | dec cnt
204 | brne 7b
205 | ; add
206 | add v_lo, t_lo
207 | adc v_hi, t_hi
208 | adc v_hlo, t_hlo
209 | adc v_hhi, t_hhi
210 | adc v_fifth, r0 ; here r0 == 0
211 | ret
212 |
213 | .size __ultoa_invert, . - __ultoa_invert
214 | .end
215 |
216 | #endif /* !__DOXYGEN__ */
217 |
--------------------------------------------------------------------------------