├── libraries ├── NewPing │ ├── NewPing.h │ ├── keywords.txt │ └── examples │ │ ├── NewPingExample │ │ └── NewPingExample.pde │ │ ├── TimerExample │ │ └── TimerExample.pde │ │ ├── NewPingEventTimer │ │ └── NewPingEventTimer.pde │ │ └── NewPing15Sensors │ │ └── NewPing15Sensors.pde └── mavlink │ ├── common │ ├── version.h │ ├── mavlink.h │ ├── mavlink_msg_auth_key.h │ ├── mavlink_msg_mission_current.h │ ├── mavlink_msg_timesync.h │ ├── mavlink_msg_mission_item_reached.h │ ├── mavlink_msg_terrain_check.h │ ├── mavlink_msg_command_ack.h │ ├── mavlink_msg_log_erase.h │ ├── mavlink_msg_camera_trigger.h │ ├── mavlink_msg_statustext.h │ ├── mavlink_msg_debug.h │ ├── mavlink_msg_log_request_end.h │ ├── mavlink_msg_system_time.h │ ├── mavlink_msg_encapsulated_data.h │ ├── mavlink_msg_mission_clear_all.h │ ├── mavlink_msg_param_request_list.h │ ├── mavlink_msg_mission_request_list.h │ ├── mavlink_msg_power_status.h │ ├── mavlink_msg_gps_rtcm_data.h │ └── mavlink_msg_mission_ack.h │ ├── checksum.h │ ├── mavlink_conversions.h │ └── mavlink_types.h └── README.md /libraries/NewPing/NewPing.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shaofuhw/UltrasonicMavlink/HEAD/libraries/NewPing/NewPing.h -------------------------------------------------------------------------------- /libraries/mavlink/common/version.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief MAVLink comm protocol built from common.xml 3 | * @see http://mavlink.org 4 | */ 5 | #ifndef MAVLINK_VERSION_H 6 | #define MAVLINK_VERSION_H 7 | 8 | #define MAVLINK_BUILD_DATE "Sun Jun 05 2016" 9 | #define MAVLINK_WIRE_PROTOCOL_VERSION "1.0" 10 | #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 11 | 12 | #endif // MAVLINK_VERSION_H 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Control de Obstáculos Ultrasonidos 2 | Trabajo fin de grado Ingeniería Electrónica y Automática 3 | 4 | El siguiente código se ha realizado para una placa Arduino. 5 | Utiliza la librería "NewPing" para medir la distancia de 5 sensores ultrasonidos HC-SR04. 6 | 4 Sensores para medir distancias laterales y uno para medir altura. 7 | Si el sensor inferior mide más de 1.5 metros, empieza a actuar el control. Si alguno de los sensores laterales mide una distancia menor de 1.5 metros, manda un comando MAVLINK de RCOverride, el cual sobreescribe las entradas que recibe el APM de la controladora de vuelo. 8 | -------------------------------------------------------------------------------- /libraries/NewPing/keywords.txt: -------------------------------------------------------------------------------- 1 | ################################### 2 | # Syntax Coloring Map For NewPing 3 | ################################### 4 | 5 | ################################### 6 | # Datatypes (KEYWORD1) 7 | ################################### 8 | 9 | NewPing KEYWORD1 10 | 11 | ################################### 12 | # Methods and Functions (KEYWORD2) 13 | ################################### 14 | 15 | ping KEYWORD2 16 | ping_in KEYWORD2 17 | ping_cm KEYWORD2 18 | ping_median KEYWORD2 19 | ping_timer KEYWORD2 20 | check_timer KEYWORD2 21 | timer_us KEYWORD2 22 | timer_ms KEYWORD2 23 | timer_stop KEYWORD2 24 | convert_in KEYWORD2 25 | convert_cm KEYWORD2 26 | 27 | ################################### 28 | # Constants (LITERAL1) 29 | ################################### 30 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief MAVLink comm protocol built from common.xml 3 | * @see http://mavlink.org 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 | #ifndef MAVLINK_COMMAND_24BIT 25 | #define MAVLINK_COMMAND_24BIT 0 26 | #endif 27 | 28 | #ifndef MAVLINK_PACKED 29 | #define MAVLINK_PACKED __attribute__((__packed__)) 30 | #endif 31 | 32 | #include "version.h" 33 | #include "common.h" 34 | 35 | #endif // MAVLINK_H 36 | -------------------------------------------------------------------------------- /libraries/NewPing/examples/NewPingExample/NewPingExample.pde: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------- 2 | // Example NewPing library sketch that does a ping about 20 times per second. 3 | // --------------------------------------------------------------------------- 4 | 5 | #include 6 | 7 | #define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor. 8 | #define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor. 9 | #define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. 10 | 11 | NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. 12 | 13 | void setup() { 14 | Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results. 15 | } 16 | 17 | void loop() { 18 | delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings. 19 | Serial.print("Ping: "); 20 | Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range) 21 | Serial.println("cm"); 22 | } -------------------------------------------------------------------------------- /libraries/NewPing/examples/TimerExample/TimerExample.pde: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------- 2 | // While the NewPing library's primary goal is to interface with ultrasonic sensors, interfacing with 3 | // the Timer2 interrupt was a result of creating an interrupt-based ping method. Since these Timer2 4 | // interrupt methods were built, the library may as well provide the functionality to use these methods 5 | // in your sketches. This shows how simple it is (no ultrasonic sensor required). Keep in mind that 6 | // these methods use Timer2, as does NewPing's ping_timer method for using ultrasonic sensors. You 7 | // can't use ping_timer at the same time you're using timer_ms or timer_us as all use the same timer. 8 | // --------------------------------------------------------------------------- 9 | 10 | #include 11 | 12 | #define LED_PIN 13 // Pin with LED attached. 13 | 14 | void setup() { 15 | pinMode(LED_PIN, OUTPUT); 16 | NewPing::timer_ms(500, toggleLED); // Create a Timer2 interrupt that calls toggleLED in your sketch once every 500 milliseconds. 17 | } 18 | 19 | void loop() { 20 | // Do anything here, the Timer2 interrupt will take care of the flashing LED without your intervention. 21 | } 22 | 23 | void toggleLED() { 24 | digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Toggle the LED. 25 | } -------------------------------------------------------------------------------- /libraries/mavlink/checksum.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | 5 | #ifndef _CHECKSUM_H_ 6 | #define _CHECKSUM_H_ 7 | 8 | // Visual Studio versions before 2010 don't have stdint.h, so we just error out. 9 | #if (defined _MSC_VER) && (_MSC_VER < 1600) 10 | #error "The C-MAVLink implementation requires Visual Studio 2010 or greater" 11 | #endif 12 | 13 | #include 14 | 15 | /** 16 | * 17 | * CALCULATE THE CHECKSUM 18 | * 19 | */ 20 | 21 | #define X25_INIT_CRC 0xffff 22 | #define X25_VALIDATE_CRC 0xf0b8 23 | 24 | #ifndef HAVE_CRC_ACCUMULATE 25 | /** 26 | * @brief Accumulate the X.25 CRC by adding one char at a time. 27 | * 28 | * The checksum function adds the hash of one char at a time to the 29 | * 16 bit checksum (uint16_t). 30 | * 31 | * @param data new char to hash 32 | * @param crcAccum the already accumulated checksum 33 | **/ 34 | static inline void crc_accumulate(uint8_t data, uint16_t *crcAccum) 35 | { 36 | /*Accumulate one byte of data into the CRC*/ 37 | uint8_t tmp; 38 | 39 | tmp = data ^ (uint8_t)(*crcAccum &0xff); 40 | tmp ^= (tmp<<4); 41 | *crcAccum = (*crcAccum>>8) ^ (tmp<<8) ^ (tmp <<3) ^ (tmp>>4); 42 | } 43 | #endif 44 | 45 | 46 | /** 47 | * @brief Initiliaze the buffer for the X.25 CRC 48 | * 49 | * @param crcAccum the 16 bit X.25 CRC 50 | */ 51 | static inline void crc_init(uint16_t* crcAccum) 52 | { 53 | *crcAccum = X25_INIT_CRC; 54 | } 55 | 56 | 57 | /** 58 | * @brief Calculates the X.25 checksum on a byte buffer 59 | * 60 | * @param pBuffer buffer containing the byte array to hash 61 | * @param length length of the byte array 62 | * @return the checksum over the buffer bytes 63 | **/ 64 | static inline uint16_t crc_calculate(const uint8_t* pBuffer, uint16_t length) 65 | { 66 | uint16_t crcTmp; 67 | crc_init(&crcTmp); 68 | while (length--) { 69 | crc_accumulate(*pBuffer++, &crcTmp); 70 | } 71 | return crcTmp; 72 | } 73 | 74 | 75 | /** 76 | * @brief Accumulate the X.25 CRC by adding an array of bytes 77 | * 78 | * The checksum function adds the hash of one char at a time to the 79 | * 16 bit checksum (uint16_t). 80 | * 81 | * @param data new bytes to hash 82 | * @param crcAccum the already accumulated checksum 83 | **/ 84 | static inline void crc_accumulate_buffer(uint16_t *crcAccum, const char *pBuffer, uint16_t length) 85 | { 86 | const uint8_t *p = (const uint8_t *)pBuffer; 87 | while (length--) { 88 | crc_accumulate(*p++, crcAccum); 89 | } 90 | } 91 | 92 | #endif /* _CHECKSUM_H_ */ 93 | 94 | #ifdef __cplusplus 95 | } 96 | #endif 97 | -------------------------------------------------------------------------------- /libraries/NewPing/examples/NewPingEventTimer/NewPingEventTimer.pde: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------- 2 | // This example shows how to use NewPing's ping_timer method which uses the Timer2 interrupt to get the 3 | // ping time. The advantage of using this method over the standard ping method is that it permits a more 4 | // event-driven sketch which allows you to appear to do two things at once. An example would be to ping 5 | // an ultrasonic sensor for a possible collision while at the same time navigating. This allows a 6 | // properly developed sketch to multitask. Be aware that because the ping_timer method uses Timer2, 7 | // other features or libraries that also use Timer2 would be effected. For example, the PWM function on 8 | // pins 3 & 11 on Arduino Uno (pins 9 and 11 on Arduino Mega) and the Tone library. Note, only the PWM 9 | // functionality of the pins is lost (as they use Timer2 to do PWM), the pins are still available to use. 10 | // NOTE: For Teensy/Leonardo (ATmega32U4) the library uses Timer4 instead of Timer2. 11 | // --------------------------------------------------------------------------- 12 | #include 13 | 14 | #define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on ping sensor. 15 | #define ECHO_PIN 11 // Arduino pin tied to echo pin on ping sensor. 16 | #define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. 17 | 18 | NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. 19 | 20 | unsigned int pingSpeed = 50; // How frequently are we going to send out a ping (in milliseconds). 50ms would be 20 times a second. 21 | unsigned long pingTimer; // Holds the next ping time. 22 | 23 | void setup() { 24 | Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results. 25 | pingTimer = millis(); // Start now. 26 | } 27 | 28 | void loop() { 29 | // Notice how there's no delays in this sketch to allow you to do other processing in-line while doing distance pings. 30 | if (millis() >= pingTimer) { // pingSpeed milliseconds since last ping, do another ping. 31 | pingTimer += pingSpeed; // Set the next ping time. 32 | sonar.ping_timer(echoCheck); // Send out the ping, calls "echoCheck" function every 24uS where you can check the ping status. 33 | } 34 | // Do other stuff here, really. Think of it as multi-tasking. 35 | } 36 | 37 | void echoCheck() { // Timer2 interrupt calls this function every 24uS where you can check the ping status. 38 | // Don't do anything here! 39 | if (sonar.check_timer()) { // This is how you check to see if the ping was received. 40 | // Here's where you can add code. 41 | Serial.print("Ping: "); 42 | Serial.print(sonar.ping_result / US_ROUNDTRIP_CM); // Ping returned, uS result in ping_result, convert to cm with US_ROUNDTRIP_CM. 43 | Serial.println("cm"); 44 | } 45 | // Don't do anything here! 46 | } -------------------------------------------------------------------------------- /libraries/NewPing/examples/NewPing15Sensors/NewPing15Sensors.pde: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------- 2 | // This example code was used to successfully communicate with 15 ultrasonic sensors. You can adjust 3 | // the number of sensors in your project by changing SONAR_NUM and the number of NewPing objects in the 4 | // "sonar" array. You also need to change the pins for each sensor for the NewPing objects. Each sensor 5 | // is pinged at 33ms intervals. So, one cycle of all sensors takes 495ms (33 * 15 = 495ms). The results 6 | // are sent to the "oneSensorCycle" function which currently just displays the distance data. Your project 7 | // would normally process the sensor results in this function (for example, decide if a robot needs to 8 | // turn and call the turn function). Keep in mind this example is event-driven. Your complete sketch needs 9 | // to be written so there's no "delay" commands and the loop() cycles at faster than a 33ms rate. If other 10 | // processes take longer than 33ms, you'll need to increase PING_INTERVAL so it doesn't get behind. 11 | // --------------------------------------------------------------------------- 12 | #include 13 | 14 | #define SONAR_NUM 15 // Number of sensors. 15 | #define MAX_DISTANCE 200 // Maximum distance (in cm) to ping. 16 | #define PING_INTERVAL 33 // Milliseconds between sensor pings (29ms is about the min to avoid cross-sensor echo). 17 | 18 | unsigned long pingTimer[SONAR_NUM]; // Holds the times when the next ping should happen for each sensor. 19 | unsigned int cm[SONAR_NUM]; // Where the ping distances are stored. 20 | uint8_t currentSensor = 0; // Keeps track of which sensor is active. 21 | 22 | NewPing sonar[SONAR_NUM] = { // Sensor object array. 23 | NewPing(41, 42, MAX_DISTANCE), // Each sensor's trigger pin, echo pin, and max distance to ping. 24 | NewPing(43, 44, MAX_DISTANCE), 25 | NewPing(45, 20, MAX_DISTANCE), 26 | NewPing(21, 22, MAX_DISTANCE), 27 | NewPing(23, 24, MAX_DISTANCE), 28 | NewPing(25, 26, MAX_DISTANCE), 29 | NewPing(27, 28, MAX_DISTANCE), 30 | NewPing(29, 30, MAX_DISTANCE), 31 | NewPing(31, 32, MAX_DISTANCE), 32 | NewPing(34, 33, MAX_DISTANCE), 33 | NewPing(35, 36, MAX_DISTANCE), 34 | NewPing(37, 38, MAX_DISTANCE), 35 | NewPing(39, 40, MAX_DISTANCE), 36 | NewPing(50, 51, MAX_DISTANCE), 37 | NewPing(52, 53, MAX_DISTANCE) 38 | }; 39 | 40 | void setup() { 41 | Serial.begin(115200); 42 | pingTimer[0] = millis() + 75; // First ping starts at 75ms, gives time for the Arduino to chill before starting. 43 | for (uint8_t i = 1; i < SONAR_NUM; i++) // Set the starting time for each sensor. 44 | pingTimer[i] = pingTimer[i - 1] + PING_INTERVAL; 45 | } 46 | 47 | void loop() { 48 | for (uint8_t i = 0; i < SONAR_NUM; i++) { // Loop through all the sensors. 49 | if (millis() >= pingTimer[i]) { // Is it this sensor's time to ping? 50 | pingTimer[i] += PING_INTERVAL * SONAR_NUM; // Set next time this sensor will be pinged. 51 | if (i == 0 && currentSensor == SONAR_NUM - 1) oneSensorCycle(); // Sensor ping cycle complete, do something with the results. 52 | sonar[currentSensor].timer_stop(); // Make sure previous timer is canceled before starting a new ping (insurance). 53 | currentSensor = i; // Sensor being accessed. 54 | cm[currentSensor] = 0; // Make distance zero in case there's no ping echo for this sensor. 55 | sonar[currentSensor].ping_timer(echoCheck); // Do the ping (processing continues, interrupt will call echoCheck to look for echo). 56 | } 57 | } 58 | // Other code that *DOESN'T* analyze ping results can go here. 59 | } 60 | 61 | void echoCheck() { // If ping received, set the sensor distance to array. 62 | if (sonar[currentSensor].check_timer()) 63 | cm[currentSensor] = sonar[currentSensor].ping_result / US_ROUNDTRIP_CM; 64 | } 65 | 66 | void oneSensorCycle() { // Sensor ping cycle complete, do something with the results. 67 | // The following code would be replaced with your code that does something with the ping results. 68 | for (uint8_t i = 0; i < SONAR_NUM; i++) { 69 | Serial.print(i); 70 | Serial.print("="); 71 | Serial.print(cm[i]); 72 | Serial.print("cm "); 73 | } 74 | Serial.println(); 75 | } -------------------------------------------------------------------------------- /libraries/mavlink/mavlink_conversions.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAVLINK_CONVERSIONS_H_ 2 | #define _MAVLINK_CONVERSIONS_H_ 3 | 4 | /* enable math defines on Windows */ 5 | #ifdef _MSC_VER 6 | #ifndef _USE_MATH_DEFINES 7 | #define _USE_MATH_DEFINES 8 | #endif 9 | #endif 10 | #include 11 | 12 | #ifndef M_PI_2 13 | #define M_PI_2 ((float)asin(1)) 14 | #endif 15 | 16 | /** 17 | * @file mavlink_conversions.h 18 | * 19 | * These conversion functions follow the NASA rotation standards definition file 20 | * available online. 21 | * 22 | * Their intent is to lower the barrier for MAVLink adopters to use gimbal-lock free 23 | * (both rotation matrices, sometimes called DCM, and quaternions are gimbal-lock free) 24 | * rotation representations. Euler angles (roll, pitch, yaw) will be phased out of the 25 | * protocol as widely as possible. 26 | * 27 | * @author James Goppert 28 | * @author Thomas Gubler 29 | */ 30 | 31 | 32 | /** 33 | * Converts a quaternion to a rotation matrix 34 | * 35 | * @param quaternion a [w, x, y, z] ordered quaternion (null-rotation being 1 0 0 0) 36 | * @param dcm a 3x3 rotation matrix 37 | */ 38 | MAVLINK_HELPER void mavlink_quaternion_to_dcm(const float quaternion[4], float dcm[3][3]) 39 | { 40 | double a = quaternion[0]; 41 | double b = quaternion[1]; 42 | double c = quaternion[2]; 43 | double d = quaternion[3]; 44 | double aSq = a * a; 45 | double bSq = b * b; 46 | double cSq = c * c; 47 | double dSq = d * d; 48 | dcm[0][0] = aSq + bSq - cSq - dSq; 49 | dcm[0][1] = 2 * (b * c - a * d); 50 | dcm[0][2] = 2 * (a * c + b * d); 51 | dcm[1][0] = 2 * (b * c + a * d); 52 | dcm[1][1] = aSq - bSq + cSq - dSq; 53 | dcm[1][2] = 2 * (c * d - a * b); 54 | dcm[2][0] = 2 * (b * d - a * c); 55 | dcm[2][1] = 2 * (a * b + c * d); 56 | dcm[2][2] = aSq - bSq - cSq + dSq; 57 | } 58 | 59 | 60 | /** 61 | * Converts a rotation matrix to euler angles 62 | * 63 | * @param dcm a 3x3 rotation matrix 64 | * @param roll the roll angle in radians 65 | * @param pitch the pitch angle in radians 66 | * @param yaw the yaw angle in radians 67 | */ 68 | MAVLINK_HELPER void mavlink_dcm_to_euler(const float dcm[3][3], float* roll, float* pitch, float* yaw) 69 | { 70 | float phi, theta, psi; 71 | theta = asin(-dcm[2][0]); 72 | 73 | if (fabsf(theta - (float)M_PI_2) < 1.0e-3f) { 74 | phi = 0.0f; 75 | psi = (atan2f(dcm[1][2] - dcm[0][1], 76 | dcm[0][2] + dcm[1][1]) + phi); 77 | 78 | } else if (fabsf(theta + (float)M_PI_2) < 1.0e-3f) { 79 | phi = 0.0f; 80 | psi = atan2f(dcm[1][2] - dcm[0][1], 81 | dcm[0][2] + dcm[1][1] - phi); 82 | 83 | } else { 84 | phi = atan2f(dcm[2][1], dcm[2][2]); 85 | psi = atan2f(dcm[1][0], dcm[0][0]); 86 | } 87 | 88 | *roll = phi; 89 | *pitch = theta; 90 | *yaw = psi; 91 | } 92 | 93 | 94 | /** 95 | * Converts a quaternion to euler angles 96 | * 97 | * @param quaternion a [w, x, y, z] ordered quaternion (null-rotation being 1 0 0 0) 98 | * @param roll the roll angle in radians 99 | * @param pitch the pitch angle in radians 100 | * @param yaw the yaw angle in radians 101 | */ 102 | MAVLINK_HELPER void mavlink_quaternion_to_euler(const float quaternion[4], float* roll, float* pitch, float* yaw) 103 | { 104 | float dcm[3][3]; 105 | mavlink_quaternion_to_dcm(quaternion, dcm); 106 | mavlink_dcm_to_euler((const float(*)[3])dcm, roll, pitch, yaw); 107 | } 108 | 109 | 110 | /** 111 | * Converts euler angles to a quaternion 112 | * 113 | * @param roll the roll angle in radians 114 | * @param pitch the pitch angle in radians 115 | * @param yaw the yaw angle in radians 116 | * @param quaternion a [w, x, y, z] ordered quaternion (null-rotation being 1 0 0 0) 117 | */ 118 | MAVLINK_HELPER void mavlink_euler_to_quaternion(float roll, float pitch, float yaw, float quaternion[4]) 119 | { 120 | float cosPhi_2 = cosf(roll / 2); 121 | float sinPhi_2 = sinf(roll / 2); 122 | float cosTheta_2 = cosf(pitch / 2); 123 | float sinTheta_2 = sinf(pitch / 2); 124 | float cosPsi_2 = cosf(yaw / 2); 125 | float sinPsi_2 = sinf(yaw / 2); 126 | quaternion[0] = (cosPhi_2 * cosTheta_2 * cosPsi_2 + 127 | sinPhi_2 * sinTheta_2 * sinPsi_2); 128 | quaternion[1] = (sinPhi_2 * cosTheta_2 * cosPsi_2 - 129 | cosPhi_2 * sinTheta_2 * sinPsi_2); 130 | quaternion[2] = (cosPhi_2 * sinTheta_2 * cosPsi_2 + 131 | sinPhi_2 * cosTheta_2 * sinPsi_2); 132 | quaternion[3] = (cosPhi_2 * cosTheta_2 * sinPsi_2 - 133 | sinPhi_2 * sinTheta_2 * cosPsi_2); 134 | } 135 | 136 | 137 | /** 138 | * Converts a rotation matrix to a quaternion 139 | * Reference: 140 | * - Shoemake, Quaternions, 141 | * http://www.cs.ucr.edu/~vbz/resources/quatut.pdf 142 | * 143 | * @param dcm a 3x3 rotation matrix 144 | * @param quaternion a [w, x, y, z] ordered quaternion (null-rotation being 1 0 0 0) 145 | */ 146 | MAVLINK_HELPER void mavlink_dcm_to_quaternion(const float dcm[3][3], float quaternion[4]) 147 | { 148 | float tr = dcm[0][0] + dcm[1][1] + dcm[2][2]; 149 | if (tr > 0.0f) { 150 | float s = sqrtf(tr + 1.0f); 151 | quaternion[0] = s * 0.5f; 152 | s = 0.5f / s; 153 | quaternion[1] = (dcm[2][1] - dcm[1][2]) * s; 154 | quaternion[2] = (dcm[0][2] - dcm[2][0]) * s; 155 | quaternion[3] = (dcm[1][0] - dcm[0][1]) * s; 156 | } else { 157 | /* Find maximum diagonal element in dcm 158 | * store index in dcm_i */ 159 | int dcm_i = 0; 160 | int i; 161 | for (i = 1; i < 3; i++) { 162 | if (dcm[i][i] > dcm[dcm_i][dcm_i]) { 163 | dcm_i = i; 164 | } 165 | } 166 | 167 | int dcm_j = (dcm_i + 1) % 3; 168 | int dcm_k = (dcm_i + 2) % 3; 169 | 170 | float s = sqrtf((dcm[dcm_i][dcm_i] - dcm[dcm_j][dcm_j] - 171 | dcm[dcm_k][dcm_k]) + 1.0f); 172 | quaternion[dcm_i + 1] = s * 0.5f; 173 | s = 0.5f / s; 174 | quaternion[dcm_j + 1] = (dcm[dcm_i][dcm_j] + dcm[dcm_j][dcm_i]) * s; 175 | quaternion[dcm_k + 1] = (dcm[dcm_k][dcm_i] + dcm[dcm_i][dcm_k]) * s; 176 | quaternion[0] = (dcm[dcm_k][dcm_j] - dcm[dcm_j][dcm_k]) * s; 177 | } 178 | } 179 | 180 | 181 | /** 182 | * Converts euler angles to a rotation matrix 183 | * 184 | * @param roll the roll angle in radians 185 | * @param pitch the pitch angle in radians 186 | * @param yaw the yaw angle in radians 187 | * @param dcm a 3x3 rotation matrix 188 | */ 189 | MAVLINK_HELPER void mavlink_euler_to_dcm(float roll, float pitch, float yaw, float dcm[3][3]) 190 | { 191 | float cosPhi = cosf(roll); 192 | float sinPhi = sinf(roll); 193 | float cosThe = cosf(pitch); 194 | float sinThe = sinf(pitch); 195 | float cosPsi = cosf(yaw); 196 | float sinPsi = sinf(yaw); 197 | 198 | dcm[0][0] = cosThe * cosPsi; 199 | dcm[0][1] = -cosPhi * sinPsi + sinPhi * sinThe * cosPsi; 200 | dcm[0][2] = sinPhi * sinPsi + cosPhi * sinThe * cosPsi; 201 | 202 | dcm[1][0] = cosThe * sinPsi; 203 | dcm[1][1] = cosPhi * cosPsi + sinPhi * sinThe * sinPsi; 204 | dcm[1][2] = -sinPhi * cosPsi + cosPhi * sinThe * sinPsi; 205 | 206 | dcm[2][0] = -sinThe; 207 | dcm[2][1] = sinPhi * cosThe; 208 | dcm[2][2] = cosPhi * cosThe; 209 | } 210 | 211 | #endif 212 | -------------------------------------------------------------------------------- /libraries/mavlink/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_PACKED __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_AUTH_KEY_MIN_LEN 32 12 | #define MAVLINK_MSG_ID_7_LEN 32 13 | #define MAVLINK_MSG_ID_7_MIN_LEN 32 14 | 15 | #define MAVLINK_MSG_ID_AUTH_KEY_CRC 119 16 | #define MAVLINK_MSG_ID_7_CRC 119 17 | 18 | #define MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN 32 19 | 20 | #if MAVLINK_COMMAND_24BIT 21 | #define MAVLINK_MESSAGE_INFO_AUTH_KEY { \ 22 | 7, \ 23 | "AUTH_KEY", \ 24 | 1, \ 25 | { { "key", NULL, MAVLINK_TYPE_CHAR, 32, 0, offsetof(mavlink_auth_key_t, key) }, \ 26 | } \ 27 | } 28 | #else 29 | #define MAVLINK_MESSAGE_INFO_AUTH_KEY { \ 30 | "AUTH_KEY", \ 31 | 1, \ 32 | { { "key", NULL, MAVLINK_TYPE_CHAR, 32, 0, offsetof(mavlink_auth_key_t, key) }, \ 33 | } \ 34 | } 35 | #endif 36 | 37 | /** 38 | * @brief Pack a auth_key message 39 | * @param system_id ID of this system 40 | * @param component_id ID of this component (e.g. 200 for IMU) 41 | * @param msg The MAVLink message to compress the data into 42 | * 43 | * @param key key 44 | * @return length of the message in bytes (excluding serial stream start sign) 45 | */ 46 | static inline uint16_t mavlink_msg_auth_key_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 47 | const char *key) 48 | { 49 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 50 | char buf[MAVLINK_MSG_ID_AUTH_KEY_LEN]; 51 | 52 | _mav_put_char_array(buf, 0, key, 32); 53 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AUTH_KEY_LEN); 54 | #else 55 | mavlink_auth_key_t packet; 56 | 57 | mav_array_memcpy(packet.key, key, sizeof(char)*32); 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTH_KEY_LEN); 59 | #endif 60 | 61 | msg->msgid = MAVLINK_MSG_ID_AUTH_KEY; 62 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); 63 | } 64 | 65 | /** 66 | * @brief Pack a auth_key message on a channel 67 | * @param system_id ID of this system 68 | * @param component_id ID of this component (e.g. 200 for IMU) 69 | * @param chan The MAVLink channel this message will be sent over 70 | * @param msg The MAVLink message to compress the data into 71 | * @param key key 72 | * @return length of the message in bytes (excluding serial stream start sign) 73 | */ 74 | static inline uint16_t mavlink_msg_auth_key_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 75 | mavlink_message_t* msg, 76 | const char *key) 77 | { 78 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 79 | char buf[MAVLINK_MSG_ID_AUTH_KEY_LEN]; 80 | 81 | _mav_put_char_array(buf, 0, key, 32); 82 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AUTH_KEY_LEN); 83 | #else 84 | mavlink_auth_key_t packet; 85 | 86 | mav_array_memcpy(packet.key, key, sizeof(char)*32); 87 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTH_KEY_LEN); 88 | #endif 89 | 90 | msg->msgid = MAVLINK_MSG_ID_AUTH_KEY; 91 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); 92 | } 93 | 94 | /** 95 | * @brief Encode a auth_key struct 96 | * 97 | * @param system_id ID of this system 98 | * @param component_id ID of this component (e.g. 200 for IMU) 99 | * @param msg The MAVLink message to compress the data into 100 | * @param auth_key C-struct to read the message contents from 101 | */ 102 | 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) 103 | { 104 | return mavlink_msg_auth_key_pack(system_id, component_id, msg, auth_key->key); 105 | } 106 | 107 | /** 108 | * @brief Encode a auth_key struct on a channel 109 | * 110 | * @param system_id ID of this system 111 | * @param component_id ID of this component (e.g. 200 for IMU) 112 | * @param chan The MAVLink channel this message will be sent over 113 | * @param msg The MAVLink message to compress the data into 114 | * @param auth_key C-struct to read the message contents from 115 | */ 116 | static inline uint16_t mavlink_msg_auth_key_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_auth_key_t* auth_key) 117 | { 118 | return mavlink_msg_auth_key_pack_chan(system_id, component_id, chan, msg, auth_key->key); 119 | } 120 | 121 | /** 122 | * @brief Send a auth_key message 123 | * @param chan MAVLink channel to send the message 124 | * 125 | * @param key key 126 | */ 127 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 128 | 129 | static inline void mavlink_msg_auth_key_send(mavlink_channel_t chan, const char *key) 130 | { 131 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 132 | char buf[MAVLINK_MSG_ID_AUTH_KEY_LEN]; 133 | 134 | _mav_put_char_array(buf, 0, key, 32); 135 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, buf, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); 136 | #else 137 | mavlink_auth_key_t packet; 138 | 139 | mav_array_memcpy(packet.key, key, sizeof(char)*32); 140 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)&packet, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); 141 | #endif 142 | } 143 | 144 | /** 145 | * @brief Send a auth_key message 146 | * @param chan MAVLink channel to send the message 147 | * @param struct The MAVLink struct to serialize 148 | */ 149 | static inline void mavlink_msg_auth_key_send_struct(mavlink_channel_t chan, const mavlink_auth_key_t* auth_key) 150 | { 151 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 152 | mavlink_msg_auth_key_send(chan, auth_key->key); 153 | #else 154 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)auth_key, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); 155 | #endif 156 | } 157 | 158 | #if MAVLINK_MSG_ID_AUTH_KEY_LEN <= MAVLINK_MAX_PAYLOAD_LEN 159 | /* 160 | This varient of _send() can be used to save stack space by re-using 161 | memory from the receive buffer. The caller provides a 162 | mavlink_message_t which is the size of a full mavlink message. This 163 | is usually the receive buffer for the channel, and allows a reply to an 164 | incoming message with minimum stack space usage. 165 | */ 166 | static inline void mavlink_msg_auth_key_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, const char *key) 167 | { 168 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 169 | char *buf = (char *)msgbuf; 170 | 171 | _mav_put_char_array(buf, 0, key, 32); 172 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, buf, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); 173 | #else 174 | mavlink_auth_key_t *packet = (mavlink_auth_key_t *)msgbuf; 175 | 176 | mav_array_memcpy(packet->key, key, sizeof(char)*32); 177 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)packet, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); 178 | #endif 179 | } 180 | #endif 181 | 182 | #endif 183 | 184 | // MESSAGE AUTH_KEY UNPACKING 185 | 186 | 187 | /** 188 | * @brief Get field key from auth_key message 189 | * 190 | * @return key 191 | */ 192 | static inline uint16_t mavlink_msg_auth_key_get_key(const mavlink_message_t* msg, char *key) 193 | { 194 | return _MAV_RETURN_char_array(msg, key, 32, 0); 195 | } 196 | 197 | /** 198 | * @brief Decode a auth_key message into a struct 199 | * 200 | * @param msg The message to decode 201 | * @param auth_key C-struct to decode the message contents into 202 | */ 203 | static inline void mavlink_msg_auth_key_decode(const mavlink_message_t* msg, mavlink_auth_key_t* auth_key) 204 | { 205 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 206 | mavlink_msg_auth_key_get_key(msg, auth_key->key); 207 | #else 208 | uint8_t len = msg->len < MAVLINK_MSG_ID_AUTH_KEY_LEN? msg->len : MAVLINK_MSG_ID_AUTH_KEY_LEN; 209 | memset(auth_key, 0, MAVLINK_MSG_ID_AUTH_KEY_LEN); 210 | memcpy(auth_key, _MAV_PAYLOAD(msg), len); 211 | #endif 212 | } 213 | -------------------------------------------------------------------------------- /libraries/mavlink/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_PACKED __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_MISSION_CURRENT_MIN_LEN 2 12 | #define MAVLINK_MSG_ID_42_LEN 2 13 | #define MAVLINK_MSG_ID_42_MIN_LEN 2 14 | 15 | #define MAVLINK_MSG_ID_MISSION_CURRENT_CRC 28 16 | #define MAVLINK_MSG_ID_42_CRC 28 17 | 18 | 19 | 20 | #if MAVLINK_COMMAND_24BIT 21 | #define MAVLINK_MESSAGE_INFO_MISSION_CURRENT { \ 22 | 42, \ 23 | "MISSION_CURRENT", \ 24 | 1, \ 25 | { { "seq", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_mission_current_t, seq) }, \ 26 | } \ 27 | } 28 | #else 29 | #define MAVLINK_MESSAGE_INFO_MISSION_CURRENT { \ 30 | "MISSION_CURRENT", \ 31 | 1, \ 32 | { { "seq", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_mission_current_t, seq) }, \ 33 | } \ 34 | } 35 | #endif 36 | 37 | /** 38 | * @brief Pack a mission_current message 39 | * @param system_id ID of this system 40 | * @param component_id ID of this component (e.g. 200 for IMU) 41 | * @param msg The MAVLink message to compress the data into 42 | * 43 | * @param seq Sequence 44 | * @return length of the message in bytes (excluding serial stream start sign) 45 | */ 46 | static inline uint16_t mavlink_msg_mission_current_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 47 | uint16_t seq) 48 | { 49 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 50 | char buf[MAVLINK_MSG_ID_MISSION_CURRENT_LEN]; 51 | _mav_put_uint16_t(buf, 0, seq); 52 | 53 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_CURRENT_LEN); 54 | #else 55 | mavlink_mission_current_t packet; 56 | packet.seq = seq; 57 | 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_CURRENT_LEN); 59 | #endif 60 | 61 | msg->msgid = MAVLINK_MSG_ID_MISSION_CURRENT; 62 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_CURRENT_MIN_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_CRC); 63 | } 64 | 65 | /** 66 | * @brief Pack a mission_current message on a channel 67 | * @param system_id ID of this system 68 | * @param component_id ID of this component (e.g. 200 for IMU) 69 | * @param chan The MAVLink channel this message will be sent over 70 | * @param msg The MAVLink message to compress the data into 71 | * @param seq Sequence 72 | * @return length of the message in bytes (excluding serial stream start sign) 73 | */ 74 | static inline uint16_t mavlink_msg_mission_current_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 75 | mavlink_message_t* msg, 76 | uint16_t seq) 77 | { 78 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 79 | char buf[MAVLINK_MSG_ID_MISSION_CURRENT_LEN]; 80 | _mav_put_uint16_t(buf, 0, seq); 81 | 82 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_CURRENT_LEN); 83 | #else 84 | mavlink_mission_current_t packet; 85 | packet.seq = seq; 86 | 87 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_CURRENT_LEN); 88 | #endif 89 | 90 | msg->msgid = MAVLINK_MSG_ID_MISSION_CURRENT; 91 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MISSION_CURRENT_MIN_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_CRC); 92 | } 93 | 94 | /** 95 | * @brief Encode a mission_current struct 96 | * 97 | * @param system_id ID of this system 98 | * @param component_id ID of this component (e.g. 200 for IMU) 99 | * @param msg The MAVLink message to compress the data into 100 | * @param mission_current C-struct to read the message contents from 101 | */ 102 | 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) 103 | { 104 | return mavlink_msg_mission_current_pack(system_id, component_id, msg, mission_current->seq); 105 | } 106 | 107 | /** 108 | * @brief Encode a mission_current struct on a channel 109 | * 110 | * @param system_id ID of this system 111 | * @param component_id ID of this component (e.g. 200 for IMU) 112 | * @param chan The MAVLink channel this message will be sent over 113 | * @param msg The MAVLink message to compress the data into 114 | * @param mission_current C-struct to read the message contents from 115 | */ 116 | static inline uint16_t mavlink_msg_mission_current_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_mission_current_t* mission_current) 117 | { 118 | return mavlink_msg_mission_current_pack_chan(system_id, component_id, chan, msg, mission_current->seq); 119 | } 120 | 121 | /** 122 | * @brief Send a mission_current message 123 | * @param chan MAVLink channel to send the message 124 | * 125 | * @param seq Sequence 126 | */ 127 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 128 | 129 | static inline void mavlink_msg_mission_current_send(mavlink_channel_t chan, uint16_t seq) 130 | { 131 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 132 | char buf[MAVLINK_MSG_ID_MISSION_CURRENT_LEN]; 133 | _mav_put_uint16_t(buf, 0, seq); 134 | 135 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_CURRENT, buf, MAVLINK_MSG_ID_MISSION_CURRENT_MIN_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_CRC); 136 | #else 137 | mavlink_mission_current_t packet; 138 | packet.seq = seq; 139 | 140 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_CURRENT, (const char *)&packet, MAVLINK_MSG_ID_MISSION_CURRENT_MIN_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_CRC); 141 | #endif 142 | } 143 | 144 | /** 145 | * @brief Send a mission_current message 146 | * @param chan MAVLink channel to send the message 147 | * @param struct The MAVLink struct to serialize 148 | */ 149 | static inline void mavlink_msg_mission_current_send_struct(mavlink_channel_t chan, const mavlink_mission_current_t* mission_current) 150 | { 151 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 152 | mavlink_msg_mission_current_send(chan, mission_current->seq); 153 | #else 154 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_CURRENT, (const char *)mission_current, MAVLINK_MSG_ID_MISSION_CURRENT_MIN_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_CRC); 155 | #endif 156 | } 157 | 158 | #if MAVLINK_MSG_ID_MISSION_CURRENT_LEN <= MAVLINK_MAX_PAYLOAD_LEN 159 | /* 160 | This varient of _send() can be used to save stack space by re-using 161 | memory from the receive buffer. The caller provides a 162 | mavlink_message_t which is the size of a full mavlink message. This 163 | is usually the receive buffer for the channel, and allows a reply to an 164 | incoming message with minimum stack space usage. 165 | */ 166 | static inline void mavlink_msg_mission_current_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t seq) 167 | { 168 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 169 | char *buf = (char *)msgbuf; 170 | _mav_put_uint16_t(buf, 0, seq); 171 | 172 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_CURRENT, buf, MAVLINK_MSG_ID_MISSION_CURRENT_MIN_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_CRC); 173 | #else 174 | mavlink_mission_current_t *packet = (mavlink_mission_current_t *)msgbuf; 175 | packet->seq = seq; 176 | 177 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_CURRENT, (const char *)packet, MAVLINK_MSG_ID_MISSION_CURRENT_MIN_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_CRC); 178 | #endif 179 | } 180 | #endif 181 | 182 | #endif 183 | 184 | // MESSAGE MISSION_CURRENT UNPACKING 185 | 186 | 187 | /** 188 | * @brief Get field seq from mission_current message 189 | * 190 | * @return Sequence 191 | */ 192 | static inline uint16_t mavlink_msg_mission_current_get_seq(const mavlink_message_t* msg) 193 | { 194 | return _MAV_RETURN_uint16_t(msg, 0); 195 | } 196 | 197 | /** 198 | * @brief Decode a mission_current message into a struct 199 | * 200 | * @param msg The message to decode 201 | * @param mission_current C-struct to decode the message contents into 202 | */ 203 | static inline void mavlink_msg_mission_current_decode(const mavlink_message_t* msg, mavlink_mission_current_t* mission_current) 204 | { 205 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 206 | mission_current->seq = mavlink_msg_mission_current_get_seq(msg); 207 | #else 208 | uint8_t len = msg->len < MAVLINK_MSG_ID_MISSION_CURRENT_LEN? msg->len : MAVLINK_MSG_ID_MISSION_CURRENT_LEN; 209 | memset(mission_current, 0, MAVLINK_MSG_ID_MISSION_CURRENT_LEN); 210 | memcpy(mission_current, _MAV_PAYLOAD(msg), len); 211 | #endif 212 | } 213 | -------------------------------------------------------------------------------- /libraries/mavlink/mavlink_types.h: -------------------------------------------------------------------------------- 1 | #ifndef MAVLINK_TYPES_H_ 2 | #define MAVLINK_TYPES_H_ 3 | 4 | // Visual Studio versions before 2010 don't have stdint.h, so we just error out. 5 | #if (defined _MSC_VER) && (_MSC_VER < 1600) 6 | #error "The C-MAVLink implementation requires Visual Studio 2010 or greater" 7 | #endif 8 | 9 | #include 10 | 11 | // Macro to define packed structures 12 | #ifdef __GNUC__ 13 | #define MAVPACKED( __Declaration__ ) __Declaration__ __attribute__((packed)) 14 | #else 15 | #define MAVPACKED( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) ) 16 | #endif 17 | 18 | #ifndef MAVLINK_MAX_PAYLOAD_LEN 19 | // it is possible to override this, but be careful! 20 | #define MAVLINK_MAX_PAYLOAD_LEN 255 ///< Maximum payload length 21 | #endif 22 | 23 | #define MAVLINK_CORE_HEADER_LEN 5 ///< Length of core header (of the comm. layer): message length (1 byte) + message sequence (1 byte) + message system id (1 byte) + message component id (1 byte) + message type id (1 byte) 24 | #define MAVLINK_NUM_HEADER_BYTES (MAVLINK_CORE_HEADER_LEN + 1) ///< Length of all header bytes, including core and checksum 25 | #define MAVLINK_NUM_CHECKSUM_BYTES 2 26 | #define MAVLINK_NUM_NON_PAYLOAD_BYTES (MAVLINK_NUM_HEADER_BYTES + MAVLINK_NUM_CHECKSUM_BYTES) 27 | 28 | #define MAVLINK_MAX_PACKET_LEN (MAVLINK_MAX_PAYLOAD_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES) ///< Maximum packet length 29 | 30 | #define MAVLINK_MSG_ID_EXTENDED_MESSAGE 255 31 | #define MAVLINK_EXTENDED_HEADER_LEN 14 32 | 33 | #if (defined _MSC_VER) || ((defined __APPLE__) && (defined __MACH__)) || (defined __linux__) 34 | /* full fledged 32bit++ OS */ 35 | #define MAVLINK_MAX_EXTENDED_PACKET_LEN 65507 36 | #else 37 | /* small microcontrollers */ 38 | #define MAVLINK_MAX_EXTENDED_PACKET_LEN 2048 39 | #endif 40 | 41 | #define MAVLINK_MAX_EXTENDED_PAYLOAD_LEN (MAVLINK_MAX_EXTENDED_PACKET_LEN - MAVLINK_EXTENDED_HEADER_LEN - MAVLINK_NUM_NON_PAYLOAD_BYTES) 42 | 43 | 44 | /** 45 | * Old-style 4 byte param union 46 | * 47 | * This struct is the data format to be used when sending 48 | * parameters. The parameter should be copied to the native 49 | * type (without type conversion) 50 | * and re-instanted on the receiving side using the 51 | * native type as well. 52 | */ 53 | MAVPACKED( 54 | typedef struct param_union { 55 | union { 56 | float param_float; 57 | int32_t param_int32; 58 | uint32_t param_uint32; 59 | int16_t param_int16; 60 | uint16_t param_uint16; 61 | int8_t param_int8; 62 | uint8_t param_uint8; 63 | uint8_t bytes[4]; 64 | }; 65 | uint8_t type; 66 | }) mavlink_param_union_t; 67 | 68 | 69 | /** 70 | * New-style 8 byte param union 71 | * mavlink_param_union_double_t will be 8 bytes long, and treated as needing 8 byte alignment for the purposes of MAVLink 1.0 field ordering. 72 | * The mavlink_param_union_double_t will be treated as a little-endian structure. 73 | * 74 | * If is_double is 1 then the type is a double, and the remaining 63 bits are the double, with the lowest bit of the mantissa zero. 75 | * The intention is that by replacing the is_double bit with 0 the type can be directly used as a double (as the is_double bit corresponds to the 76 | * lowest mantissa bit of a double). If is_double is 0 then mavlink_type gives the type in the union. 77 | * The mavlink_types.h header will also need to have shifts/masks to define the bit boundaries in the above, 78 | * as bitfield ordering isn’t consistent between platforms. The above is intended to be for gcc on x86, 79 | * which should be the same as gcc on little-endian arm. When using shifts/masks the value will be treated as a 64 bit unsigned number, 80 | * and the bits pulled out using the shifts/masks. 81 | */ 82 | MAVPACKED( 83 | typedef struct param_union_extended { 84 | union { 85 | struct { 86 | uint8_t is_double:1; 87 | uint8_t mavlink_type:7; 88 | union { 89 | char c; 90 | uint8_t uint8; 91 | int8_t int8; 92 | uint16_t uint16; 93 | int16_t int16; 94 | uint32_t uint32; 95 | int32_t int32; 96 | float f; 97 | uint8_t align[7]; 98 | }; 99 | }; 100 | uint8_t data[8]; 101 | }; 102 | }) mavlink_param_union_double_t; 103 | 104 | /** 105 | * This structure is required to make the mavlink_send_xxx convenience functions 106 | * work, as it tells the library what the current system and component ID are. 107 | */ 108 | MAVPACKED( 109 | typedef struct __mavlink_system { 110 | uint8_t sysid; ///< Used by the MAVLink message_xx_send() convenience function 111 | uint8_t compid; ///< Used by the MAVLink message_xx_send() convenience function 112 | }) mavlink_system_t; 113 | 114 | MAVPACKED( 115 | typedef struct __mavlink_message { 116 | uint16_t checksum; ///< sent at end of packet 117 | uint8_t magic; ///< protocol magic marker 118 | uint8_t len; ///< Length of payload 119 | uint8_t seq; ///< Sequence of packet 120 | uint8_t sysid; ///< ID of message sender system/aircraft 121 | uint8_t compid; ///< ID of the message sender component 122 | uint8_t msgid; ///< ID of message in payload 123 | uint64_t payload64[(MAVLINK_MAX_PAYLOAD_LEN+MAVLINK_NUM_CHECKSUM_BYTES+7)/8]; 124 | }) mavlink_message_t; 125 | 126 | MAVPACKED( 127 | typedef struct __mavlink_extended_message { 128 | mavlink_message_t base_msg; 129 | int32_t extended_payload_len; ///< Length of extended payload if any 130 | uint8_t extended_payload[MAVLINK_MAX_EXTENDED_PAYLOAD_LEN]; 131 | }) mavlink_extended_message_t; 132 | 133 | typedef enum { 134 | MAVLINK_TYPE_CHAR = 0, 135 | MAVLINK_TYPE_UINT8_T = 1, 136 | MAVLINK_TYPE_INT8_T = 2, 137 | MAVLINK_TYPE_UINT16_T = 3, 138 | MAVLINK_TYPE_INT16_T = 4, 139 | MAVLINK_TYPE_UINT32_T = 5, 140 | MAVLINK_TYPE_INT32_T = 6, 141 | MAVLINK_TYPE_UINT64_T = 7, 142 | MAVLINK_TYPE_INT64_T = 8, 143 | MAVLINK_TYPE_FLOAT = 9, 144 | MAVLINK_TYPE_DOUBLE = 10 145 | } mavlink_message_type_t; 146 | 147 | #define MAVLINK_MAX_FIELDS 64 148 | 149 | typedef struct __mavlink_field_info { 150 | const char *name; // name of this field 151 | const char *print_format; // printing format hint, or NULL 152 | mavlink_message_type_t type; // type of this field 153 | unsigned int array_length; // if non-zero, field is an array 154 | unsigned int wire_offset; // offset of each field in the payload 155 | unsigned int structure_offset; // offset in a C structure 156 | } mavlink_field_info_t; 157 | 158 | // note that in this structure the order of fields is the order 159 | // in the XML file, not necessary the wire order 160 | typedef struct __mavlink_message_info { 161 | const char *name; // name of the message 162 | unsigned num_fields; // how many fields in this message 163 | mavlink_field_info_t fields[MAVLINK_MAX_FIELDS]; // field information 164 | } mavlink_message_info_t; 165 | 166 | #define _MAV_PAYLOAD(msg) ((const char *)(&((msg)->payload64[0]))) 167 | #define _MAV_PAYLOAD_NON_CONST(msg) ((char *)(&((msg)->payload64[0]))) 168 | 169 | // checksum is immediately after the payload bytes 170 | #define mavlink_ck_a(msg) *((msg)->len + (uint8_t *)_MAV_PAYLOAD_NON_CONST(msg)) 171 | #define mavlink_ck_b(msg) *(((msg)->len+(uint16_t)1) + (uint8_t *)_MAV_PAYLOAD_NON_CONST(msg)) 172 | 173 | typedef enum { 174 | MAVLINK_COMM_0, 175 | MAVLINK_COMM_1, 176 | MAVLINK_COMM_2, 177 | MAVLINK_COMM_3 178 | } mavlink_channel_t; 179 | 180 | /* 181 | * applications can set MAVLINK_COMM_NUM_BUFFERS to the maximum number 182 | * of buffers they will use. If more are used, then the result will be 183 | * a stack overrun 184 | */ 185 | #ifndef MAVLINK_COMM_NUM_BUFFERS 186 | #if (defined linux) | (defined __linux) | (defined __MACH__) | (defined _WIN32) 187 | # define MAVLINK_COMM_NUM_BUFFERS 16 188 | #else 189 | # define MAVLINK_COMM_NUM_BUFFERS 4 190 | #endif 191 | #endif 192 | 193 | typedef enum { 194 | MAVLINK_PARSE_STATE_UNINIT=0, 195 | MAVLINK_PARSE_STATE_IDLE, 196 | MAVLINK_PARSE_STATE_GOT_STX, 197 | MAVLINK_PARSE_STATE_GOT_SEQ, 198 | MAVLINK_PARSE_STATE_GOT_LENGTH, 199 | MAVLINK_PARSE_STATE_GOT_SYSID, 200 | MAVLINK_PARSE_STATE_GOT_COMPID, 201 | MAVLINK_PARSE_STATE_GOT_MSGID, 202 | MAVLINK_PARSE_STATE_GOT_PAYLOAD, 203 | MAVLINK_PARSE_STATE_GOT_CRC1, 204 | MAVLINK_PARSE_STATE_GOT_BAD_CRC1 205 | } mavlink_parse_state_t; ///< The state machine for the comm parser 206 | 207 | typedef enum { 208 | MAVLINK_FRAMING_INCOMPLETE=0, 209 | MAVLINK_FRAMING_OK=1, 210 | MAVLINK_FRAMING_BAD_CRC=2 211 | } mavlink_framing_t; 212 | 213 | typedef struct __mavlink_status { 214 | uint8_t msg_received; ///< Number of received messages 215 | uint8_t buffer_overrun; ///< Number of buffer overruns 216 | uint8_t parse_error; ///< Number of parse errors 217 | mavlink_parse_state_t parse_state; ///< Parsing state machine 218 | uint8_t packet_idx; ///< Index in current packet 219 | uint8_t current_rx_seq; ///< Sequence number of last packet received 220 | uint8_t current_tx_seq; ///< Sequence number of last packet sent 221 | uint16_t packet_rx_success_count; ///< Received packets 222 | uint16_t packet_rx_drop_count; ///< Number of packet drops 223 | } mavlink_status_t; 224 | 225 | #define MAVLINK_BIG_ENDIAN 0 226 | #define MAVLINK_LITTLE_ENDIAN 1 227 | 228 | #endif /* MAVLINK_TYPES_H_ */ 229 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_timesync.h: -------------------------------------------------------------------------------- 1 | // MESSAGE TIMESYNC PACKING 2 | 3 | #define MAVLINK_MSG_ID_TIMESYNC 111 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_timesync_t 6 | { 7 | int64_t tc1; /*< Time sync timestamp 1*/ 8 | int64_t ts1; /*< Time sync timestamp 2*/ 9 | } mavlink_timesync_t; 10 | 11 | #define MAVLINK_MSG_ID_TIMESYNC_LEN 16 12 | #define MAVLINK_MSG_ID_TIMESYNC_MIN_LEN 16 13 | #define MAVLINK_MSG_ID_111_LEN 16 14 | #define MAVLINK_MSG_ID_111_MIN_LEN 16 15 | 16 | #define MAVLINK_MSG_ID_TIMESYNC_CRC 34 17 | #define MAVLINK_MSG_ID_111_CRC 34 18 | 19 | 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_TIMESYNC { \ 23 | 111, \ 24 | "TIMESYNC", \ 25 | 2, \ 26 | { { "tc1", NULL, MAVLINK_TYPE_INT64_T, 0, 0, offsetof(mavlink_timesync_t, tc1) }, \ 27 | { "ts1", NULL, MAVLINK_TYPE_INT64_T, 0, 8, offsetof(mavlink_timesync_t, ts1) }, \ 28 | } \ 29 | } 30 | #else 31 | #define MAVLINK_MESSAGE_INFO_TIMESYNC { \ 32 | "TIMESYNC", \ 33 | 2, \ 34 | { { "tc1", NULL, MAVLINK_TYPE_INT64_T, 0, 0, offsetof(mavlink_timesync_t, tc1) }, \ 35 | { "ts1", NULL, MAVLINK_TYPE_INT64_T, 0, 8, offsetof(mavlink_timesync_t, ts1) }, \ 36 | } \ 37 | } 38 | #endif 39 | 40 | /** 41 | * @brief Pack a timesync message 42 | * @param system_id ID of this system 43 | * @param component_id ID of this component (e.g. 200 for IMU) 44 | * @param msg The MAVLink message to compress the data into 45 | * 46 | * @param tc1 Time sync timestamp 1 47 | * @param ts1 Time sync timestamp 2 48 | * @return length of the message in bytes (excluding serial stream start sign) 49 | */ 50 | static inline uint16_t mavlink_msg_timesync_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 51 | int64_t tc1, int64_t ts1) 52 | { 53 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 54 | char buf[MAVLINK_MSG_ID_TIMESYNC_LEN]; 55 | _mav_put_int64_t(buf, 0, tc1); 56 | _mav_put_int64_t(buf, 8, ts1); 57 | 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TIMESYNC_LEN); 59 | #else 60 | mavlink_timesync_t packet; 61 | packet.tc1 = tc1; 62 | packet.ts1 = ts1; 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TIMESYNC_LEN); 65 | #endif 66 | 67 | msg->msgid = MAVLINK_MSG_ID_TIMESYNC; 68 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TIMESYNC_MIN_LEN, MAVLINK_MSG_ID_TIMESYNC_LEN, MAVLINK_MSG_ID_TIMESYNC_CRC); 69 | } 70 | 71 | /** 72 | * @brief Pack a timesync message on a channel 73 | * @param system_id ID of this system 74 | * @param component_id ID of this component (e.g. 200 for IMU) 75 | * @param chan The MAVLink channel this message will be sent over 76 | * @param msg The MAVLink message to compress the data into 77 | * @param tc1 Time sync timestamp 1 78 | * @param ts1 Time sync timestamp 2 79 | * @return length of the message in bytes (excluding serial stream start sign) 80 | */ 81 | static inline uint16_t mavlink_msg_timesync_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 82 | mavlink_message_t* msg, 83 | int64_t tc1,int64_t ts1) 84 | { 85 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 86 | char buf[MAVLINK_MSG_ID_TIMESYNC_LEN]; 87 | _mav_put_int64_t(buf, 0, tc1); 88 | _mav_put_int64_t(buf, 8, ts1); 89 | 90 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TIMESYNC_LEN); 91 | #else 92 | mavlink_timesync_t packet; 93 | packet.tc1 = tc1; 94 | packet.ts1 = ts1; 95 | 96 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TIMESYNC_LEN); 97 | #endif 98 | 99 | msg->msgid = MAVLINK_MSG_ID_TIMESYNC; 100 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TIMESYNC_MIN_LEN, MAVLINK_MSG_ID_TIMESYNC_LEN, MAVLINK_MSG_ID_TIMESYNC_CRC); 101 | } 102 | 103 | /** 104 | * @brief Encode a timesync struct 105 | * 106 | * @param system_id ID of this system 107 | * @param component_id ID of this component (e.g. 200 for IMU) 108 | * @param msg The MAVLink message to compress the data into 109 | * @param timesync C-struct to read the message contents from 110 | */ 111 | static inline uint16_t mavlink_msg_timesync_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_timesync_t* timesync) 112 | { 113 | return mavlink_msg_timesync_pack(system_id, component_id, msg, timesync->tc1, timesync->ts1); 114 | } 115 | 116 | /** 117 | * @brief Encode a timesync struct on a channel 118 | * 119 | * @param system_id ID of this system 120 | * @param component_id ID of this component (e.g. 200 for IMU) 121 | * @param chan The MAVLink channel this message will be sent over 122 | * @param msg The MAVLink message to compress the data into 123 | * @param timesync C-struct to read the message contents from 124 | */ 125 | static inline uint16_t mavlink_msg_timesync_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_timesync_t* timesync) 126 | { 127 | return mavlink_msg_timesync_pack_chan(system_id, component_id, chan, msg, timesync->tc1, timesync->ts1); 128 | } 129 | 130 | /** 131 | * @brief Send a timesync message 132 | * @param chan MAVLink channel to send the message 133 | * 134 | * @param tc1 Time sync timestamp 1 135 | * @param ts1 Time sync timestamp 2 136 | */ 137 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 138 | 139 | static inline void mavlink_msg_timesync_send(mavlink_channel_t chan, int64_t tc1, int64_t ts1) 140 | { 141 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 142 | char buf[MAVLINK_MSG_ID_TIMESYNC_LEN]; 143 | _mav_put_int64_t(buf, 0, tc1); 144 | _mav_put_int64_t(buf, 8, ts1); 145 | 146 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TIMESYNC, buf, MAVLINK_MSG_ID_TIMESYNC_MIN_LEN, MAVLINK_MSG_ID_TIMESYNC_LEN, MAVLINK_MSG_ID_TIMESYNC_CRC); 147 | #else 148 | mavlink_timesync_t packet; 149 | packet.tc1 = tc1; 150 | packet.ts1 = ts1; 151 | 152 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TIMESYNC, (const char *)&packet, MAVLINK_MSG_ID_TIMESYNC_MIN_LEN, MAVLINK_MSG_ID_TIMESYNC_LEN, MAVLINK_MSG_ID_TIMESYNC_CRC); 153 | #endif 154 | } 155 | 156 | /** 157 | * @brief Send a timesync message 158 | * @param chan MAVLink channel to send the message 159 | * @param struct The MAVLink struct to serialize 160 | */ 161 | static inline void mavlink_msg_timesync_send_struct(mavlink_channel_t chan, const mavlink_timesync_t* timesync) 162 | { 163 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 164 | mavlink_msg_timesync_send(chan, timesync->tc1, timesync->ts1); 165 | #else 166 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TIMESYNC, (const char *)timesync, MAVLINK_MSG_ID_TIMESYNC_MIN_LEN, MAVLINK_MSG_ID_TIMESYNC_LEN, MAVLINK_MSG_ID_TIMESYNC_CRC); 167 | #endif 168 | } 169 | 170 | #if MAVLINK_MSG_ID_TIMESYNC_LEN <= MAVLINK_MAX_PAYLOAD_LEN 171 | /* 172 | This varient of _send() can be used to save stack space by re-using 173 | memory from the receive buffer. The caller provides a 174 | mavlink_message_t which is the size of a full mavlink message. This 175 | is usually the receive buffer for the channel, and allows a reply to an 176 | incoming message with minimum stack space usage. 177 | */ 178 | static inline void mavlink_msg_timesync_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, int64_t tc1, int64_t ts1) 179 | { 180 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 181 | char *buf = (char *)msgbuf; 182 | _mav_put_int64_t(buf, 0, tc1); 183 | _mav_put_int64_t(buf, 8, ts1); 184 | 185 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TIMESYNC, buf, MAVLINK_MSG_ID_TIMESYNC_MIN_LEN, MAVLINK_MSG_ID_TIMESYNC_LEN, MAVLINK_MSG_ID_TIMESYNC_CRC); 186 | #else 187 | mavlink_timesync_t *packet = (mavlink_timesync_t *)msgbuf; 188 | packet->tc1 = tc1; 189 | packet->ts1 = ts1; 190 | 191 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TIMESYNC, (const char *)packet, MAVLINK_MSG_ID_TIMESYNC_MIN_LEN, MAVLINK_MSG_ID_TIMESYNC_LEN, MAVLINK_MSG_ID_TIMESYNC_CRC); 192 | #endif 193 | } 194 | #endif 195 | 196 | #endif 197 | 198 | // MESSAGE TIMESYNC UNPACKING 199 | 200 | 201 | /** 202 | * @brief Get field tc1 from timesync message 203 | * 204 | * @return Time sync timestamp 1 205 | */ 206 | static inline int64_t mavlink_msg_timesync_get_tc1(const mavlink_message_t* msg) 207 | { 208 | return _MAV_RETURN_int64_t(msg, 0); 209 | } 210 | 211 | /** 212 | * @brief Get field ts1 from timesync message 213 | * 214 | * @return Time sync timestamp 2 215 | */ 216 | static inline int64_t mavlink_msg_timesync_get_ts1(const mavlink_message_t* msg) 217 | { 218 | return _MAV_RETURN_int64_t(msg, 8); 219 | } 220 | 221 | /** 222 | * @brief Decode a timesync message into a struct 223 | * 224 | * @param msg The message to decode 225 | * @param timesync C-struct to decode the message contents into 226 | */ 227 | static inline void mavlink_msg_timesync_decode(const mavlink_message_t* msg, mavlink_timesync_t* timesync) 228 | { 229 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 230 | timesync->tc1 = mavlink_msg_timesync_get_tc1(msg); 231 | timesync->ts1 = mavlink_msg_timesync_get_ts1(msg); 232 | #else 233 | uint8_t len = msg->len < MAVLINK_MSG_ID_TIMESYNC_LEN? msg->len : MAVLINK_MSG_ID_TIMESYNC_LEN; 234 | memset(timesync, 0, MAVLINK_MSG_ID_TIMESYNC_LEN); 235 | memcpy(timesync, _MAV_PAYLOAD(msg), len); 236 | #endif 237 | } 238 | -------------------------------------------------------------------------------- /libraries/mavlink/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_PACKED __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_MISSION_ITEM_REACHED_MIN_LEN 2 12 | #define MAVLINK_MSG_ID_46_LEN 2 13 | #define MAVLINK_MSG_ID_46_MIN_LEN 2 14 | 15 | #define MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC 11 16 | #define MAVLINK_MSG_ID_46_CRC 11 17 | 18 | 19 | 20 | #if MAVLINK_COMMAND_24BIT 21 | #define MAVLINK_MESSAGE_INFO_MISSION_ITEM_REACHED { \ 22 | 46, \ 23 | "MISSION_ITEM_REACHED", \ 24 | 1, \ 25 | { { "seq", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_mission_item_reached_t, seq) }, \ 26 | } \ 27 | } 28 | #else 29 | #define MAVLINK_MESSAGE_INFO_MISSION_ITEM_REACHED { \ 30 | "MISSION_ITEM_REACHED", \ 31 | 1, \ 32 | { { "seq", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_mission_item_reached_t, seq) }, \ 33 | } \ 34 | } 35 | #endif 36 | 37 | /** 38 | * @brief Pack a mission_item_reached message 39 | * @param system_id ID of this system 40 | * @param component_id ID of this component (e.g. 200 for IMU) 41 | * @param msg The MAVLink message to compress the data into 42 | * 43 | * @param seq Sequence 44 | * @return length of the message in bytes (excluding serial stream start sign) 45 | */ 46 | static inline uint16_t mavlink_msg_mission_item_reached_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 47 | uint16_t seq) 48 | { 49 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 50 | char buf[MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN]; 51 | _mav_put_uint16_t(buf, 0, seq); 52 | 53 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN); 54 | #else 55 | mavlink_mission_item_reached_t packet; 56 | packet.seq = seq; 57 | 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN); 59 | #endif 60 | 61 | msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM_REACHED; 62 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); 63 | } 64 | 65 | /** 66 | * @brief Pack a mission_item_reached message on a channel 67 | * @param system_id ID of this system 68 | * @param component_id ID of this component (e.g. 200 for IMU) 69 | * @param chan The MAVLink channel this message will be sent over 70 | * @param msg The MAVLink message to compress the data into 71 | * @param seq Sequence 72 | * @return length of the message in bytes (excluding serial stream start sign) 73 | */ 74 | static inline uint16_t mavlink_msg_mission_item_reached_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 75 | mavlink_message_t* msg, 76 | uint16_t seq) 77 | { 78 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 79 | char buf[MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN]; 80 | _mav_put_uint16_t(buf, 0, seq); 81 | 82 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN); 83 | #else 84 | mavlink_mission_item_reached_t packet; 85 | packet.seq = seq; 86 | 87 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN); 88 | #endif 89 | 90 | msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM_REACHED; 91 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); 92 | } 93 | 94 | /** 95 | * @brief Encode a mission_item_reached struct 96 | * 97 | * @param system_id ID of this system 98 | * @param component_id ID of this component (e.g. 200 for IMU) 99 | * @param msg The MAVLink message to compress the data into 100 | * @param mission_item_reached C-struct to read the message contents from 101 | */ 102 | 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) 103 | { 104 | return mavlink_msg_mission_item_reached_pack(system_id, component_id, msg, mission_item_reached->seq); 105 | } 106 | 107 | /** 108 | * @brief Encode a mission_item_reached struct on a channel 109 | * 110 | * @param system_id ID of this system 111 | * @param component_id ID of this component (e.g. 200 for IMU) 112 | * @param chan The MAVLink channel this message will be sent over 113 | * @param msg The MAVLink message to compress the data into 114 | * @param mission_item_reached C-struct to read the message contents from 115 | */ 116 | static inline uint16_t mavlink_msg_mission_item_reached_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_mission_item_reached_t* mission_item_reached) 117 | { 118 | return mavlink_msg_mission_item_reached_pack_chan(system_id, component_id, chan, msg, mission_item_reached->seq); 119 | } 120 | 121 | /** 122 | * @brief Send a mission_item_reached message 123 | * @param chan MAVLink channel to send the message 124 | * 125 | * @param seq Sequence 126 | */ 127 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 128 | 129 | static inline void mavlink_msg_mission_item_reached_send(mavlink_channel_t chan, uint16_t seq) 130 | { 131 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 132 | char buf[MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN]; 133 | _mav_put_uint16_t(buf, 0, seq); 134 | 135 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED, buf, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); 136 | #else 137 | mavlink_mission_item_reached_t packet; 138 | packet.seq = seq; 139 | 140 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED, (const char *)&packet, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); 141 | #endif 142 | } 143 | 144 | /** 145 | * @brief Send a mission_item_reached message 146 | * @param chan MAVLink channel to send the message 147 | * @param struct The MAVLink struct to serialize 148 | */ 149 | static inline void mavlink_msg_mission_item_reached_send_struct(mavlink_channel_t chan, const mavlink_mission_item_reached_t* mission_item_reached) 150 | { 151 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 152 | mavlink_msg_mission_item_reached_send(chan, mission_item_reached->seq); 153 | #else 154 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED, (const char *)mission_item_reached, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); 155 | #endif 156 | } 157 | 158 | #if MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN <= MAVLINK_MAX_PAYLOAD_LEN 159 | /* 160 | This varient of _send() can be used to save stack space by re-using 161 | memory from the receive buffer. The caller provides a 162 | mavlink_message_t which is the size of a full mavlink message. This 163 | is usually the receive buffer for the channel, and allows a reply to an 164 | incoming message with minimum stack space usage. 165 | */ 166 | static inline void mavlink_msg_mission_item_reached_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t seq) 167 | { 168 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 169 | char *buf = (char *)msgbuf; 170 | _mav_put_uint16_t(buf, 0, seq); 171 | 172 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED, buf, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); 173 | #else 174 | mavlink_mission_item_reached_t *packet = (mavlink_mission_item_reached_t *)msgbuf; 175 | packet->seq = seq; 176 | 177 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED, (const char *)packet, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); 178 | #endif 179 | } 180 | #endif 181 | 182 | #endif 183 | 184 | // MESSAGE MISSION_ITEM_REACHED UNPACKING 185 | 186 | 187 | /** 188 | * @brief Get field seq from mission_item_reached message 189 | * 190 | * @return Sequence 191 | */ 192 | static inline uint16_t mavlink_msg_mission_item_reached_get_seq(const mavlink_message_t* msg) 193 | { 194 | return _MAV_RETURN_uint16_t(msg, 0); 195 | } 196 | 197 | /** 198 | * @brief Decode a mission_item_reached message into a struct 199 | * 200 | * @param msg The message to decode 201 | * @param mission_item_reached C-struct to decode the message contents into 202 | */ 203 | static inline void mavlink_msg_mission_item_reached_decode(const mavlink_message_t* msg, mavlink_mission_item_reached_t* mission_item_reached) 204 | { 205 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 206 | mission_item_reached->seq = mavlink_msg_mission_item_reached_get_seq(msg); 207 | #else 208 | uint8_t len = msg->len < MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN? msg->len : MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN; 209 | memset(mission_item_reached, 0, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN); 210 | memcpy(mission_item_reached, _MAV_PAYLOAD(msg), len); 211 | #endif 212 | } 213 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_terrain_check.h: -------------------------------------------------------------------------------- 1 | // MESSAGE TERRAIN_CHECK PACKING 2 | 3 | #define MAVLINK_MSG_ID_TERRAIN_CHECK 135 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_terrain_check_t 6 | { 7 | int32_t lat; /*< Latitude (degrees *10^7)*/ 8 | int32_t lon; /*< Longitude (degrees *10^7)*/ 9 | } mavlink_terrain_check_t; 10 | 11 | #define MAVLINK_MSG_ID_TERRAIN_CHECK_LEN 8 12 | #define MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN 8 13 | #define MAVLINK_MSG_ID_135_LEN 8 14 | #define MAVLINK_MSG_ID_135_MIN_LEN 8 15 | 16 | #define MAVLINK_MSG_ID_TERRAIN_CHECK_CRC 203 17 | #define MAVLINK_MSG_ID_135_CRC 203 18 | 19 | 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_TERRAIN_CHECK { \ 23 | 135, \ 24 | "TERRAIN_CHECK", \ 25 | 2, \ 26 | { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_check_t, lat) }, \ 27 | { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_check_t, lon) }, \ 28 | } \ 29 | } 30 | #else 31 | #define MAVLINK_MESSAGE_INFO_TERRAIN_CHECK { \ 32 | "TERRAIN_CHECK", \ 33 | 2, \ 34 | { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_check_t, lat) }, \ 35 | { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_check_t, lon) }, \ 36 | } \ 37 | } 38 | #endif 39 | 40 | /** 41 | * @brief Pack a terrain_check message 42 | * @param system_id ID of this system 43 | * @param component_id ID of this component (e.g. 200 for IMU) 44 | * @param msg The MAVLink message to compress the data into 45 | * 46 | * @param lat Latitude (degrees *10^7) 47 | * @param lon Longitude (degrees *10^7) 48 | * @return length of the message in bytes (excluding serial stream start sign) 49 | */ 50 | static inline uint16_t mavlink_msg_terrain_check_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 51 | int32_t lat, int32_t lon) 52 | { 53 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 54 | char buf[MAVLINK_MSG_ID_TERRAIN_CHECK_LEN]; 55 | _mav_put_int32_t(buf, 0, lat); 56 | _mav_put_int32_t(buf, 4, lon); 57 | 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN); 59 | #else 60 | mavlink_terrain_check_t packet; 61 | packet.lat = lat; 62 | packet.lon = lon; 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN); 65 | #endif 66 | 67 | msg->msgid = MAVLINK_MSG_ID_TERRAIN_CHECK; 68 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); 69 | } 70 | 71 | /** 72 | * @brief Pack a terrain_check message on a channel 73 | * @param system_id ID of this system 74 | * @param component_id ID of this component (e.g. 200 for IMU) 75 | * @param chan The MAVLink channel this message will be sent over 76 | * @param msg The MAVLink message to compress the data into 77 | * @param lat Latitude (degrees *10^7) 78 | * @param lon Longitude (degrees *10^7) 79 | * @return length of the message in bytes (excluding serial stream start sign) 80 | */ 81 | static inline uint16_t mavlink_msg_terrain_check_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 82 | mavlink_message_t* msg, 83 | int32_t lat,int32_t lon) 84 | { 85 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 86 | char buf[MAVLINK_MSG_ID_TERRAIN_CHECK_LEN]; 87 | _mav_put_int32_t(buf, 0, lat); 88 | _mav_put_int32_t(buf, 4, lon); 89 | 90 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN); 91 | #else 92 | mavlink_terrain_check_t packet; 93 | packet.lat = lat; 94 | packet.lon = lon; 95 | 96 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN); 97 | #endif 98 | 99 | msg->msgid = MAVLINK_MSG_ID_TERRAIN_CHECK; 100 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); 101 | } 102 | 103 | /** 104 | * @brief Encode a terrain_check struct 105 | * 106 | * @param system_id ID of this system 107 | * @param component_id ID of this component (e.g. 200 for IMU) 108 | * @param msg The MAVLink message to compress the data into 109 | * @param terrain_check C-struct to read the message contents from 110 | */ 111 | static inline uint16_t mavlink_msg_terrain_check_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_terrain_check_t* terrain_check) 112 | { 113 | return mavlink_msg_terrain_check_pack(system_id, component_id, msg, terrain_check->lat, terrain_check->lon); 114 | } 115 | 116 | /** 117 | * @brief Encode a terrain_check struct on a channel 118 | * 119 | * @param system_id ID of this system 120 | * @param component_id ID of this component (e.g. 200 for IMU) 121 | * @param chan The MAVLink channel this message will be sent over 122 | * @param msg The MAVLink message to compress the data into 123 | * @param terrain_check C-struct to read the message contents from 124 | */ 125 | static inline uint16_t mavlink_msg_terrain_check_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_terrain_check_t* terrain_check) 126 | { 127 | return mavlink_msg_terrain_check_pack_chan(system_id, component_id, chan, msg, terrain_check->lat, terrain_check->lon); 128 | } 129 | 130 | /** 131 | * @brief Send a terrain_check message 132 | * @param chan MAVLink channel to send the message 133 | * 134 | * @param lat Latitude (degrees *10^7) 135 | * @param lon Longitude (degrees *10^7) 136 | */ 137 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 138 | 139 | static inline void mavlink_msg_terrain_check_send(mavlink_channel_t chan, int32_t lat, int32_t lon) 140 | { 141 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 142 | char buf[MAVLINK_MSG_ID_TERRAIN_CHECK_LEN]; 143 | _mav_put_int32_t(buf, 0, lat); 144 | _mav_put_int32_t(buf, 4, lon); 145 | 146 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_CHECK, buf, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); 147 | #else 148 | mavlink_terrain_check_t packet; 149 | packet.lat = lat; 150 | packet.lon = lon; 151 | 152 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_CHECK, (const char *)&packet, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); 153 | #endif 154 | } 155 | 156 | /** 157 | * @brief Send a terrain_check message 158 | * @param chan MAVLink channel to send the message 159 | * @param struct The MAVLink struct to serialize 160 | */ 161 | static inline void mavlink_msg_terrain_check_send_struct(mavlink_channel_t chan, const mavlink_terrain_check_t* terrain_check) 162 | { 163 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 164 | mavlink_msg_terrain_check_send(chan, terrain_check->lat, terrain_check->lon); 165 | #else 166 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_CHECK, (const char *)terrain_check, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); 167 | #endif 168 | } 169 | 170 | #if MAVLINK_MSG_ID_TERRAIN_CHECK_LEN <= MAVLINK_MAX_PAYLOAD_LEN 171 | /* 172 | This varient of _send() can be used to save stack space by re-using 173 | memory from the receive buffer. The caller provides a 174 | mavlink_message_t which is the size of a full mavlink message. This 175 | is usually the receive buffer for the channel, and allows a reply to an 176 | incoming message with minimum stack space usage. 177 | */ 178 | static inline void mavlink_msg_terrain_check_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, int32_t lat, int32_t lon) 179 | { 180 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 181 | char *buf = (char *)msgbuf; 182 | _mav_put_int32_t(buf, 0, lat); 183 | _mav_put_int32_t(buf, 4, lon); 184 | 185 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_CHECK, buf, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); 186 | #else 187 | mavlink_terrain_check_t *packet = (mavlink_terrain_check_t *)msgbuf; 188 | packet->lat = lat; 189 | packet->lon = lon; 190 | 191 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_CHECK, (const char *)packet, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); 192 | #endif 193 | } 194 | #endif 195 | 196 | #endif 197 | 198 | // MESSAGE TERRAIN_CHECK UNPACKING 199 | 200 | 201 | /** 202 | * @brief Get field lat from terrain_check message 203 | * 204 | * @return Latitude (degrees *10^7) 205 | */ 206 | static inline int32_t mavlink_msg_terrain_check_get_lat(const mavlink_message_t* msg) 207 | { 208 | return _MAV_RETURN_int32_t(msg, 0); 209 | } 210 | 211 | /** 212 | * @brief Get field lon from terrain_check message 213 | * 214 | * @return Longitude (degrees *10^7) 215 | */ 216 | static inline int32_t mavlink_msg_terrain_check_get_lon(const mavlink_message_t* msg) 217 | { 218 | return _MAV_RETURN_int32_t(msg, 4); 219 | } 220 | 221 | /** 222 | * @brief Decode a terrain_check message into a struct 223 | * 224 | * @param msg The message to decode 225 | * @param terrain_check C-struct to decode the message contents into 226 | */ 227 | static inline void mavlink_msg_terrain_check_decode(const mavlink_message_t* msg, mavlink_terrain_check_t* terrain_check) 228 | { 229 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 230 | terrain_check->lat = mavlink_msg_terrain_check_get_lat(msg); 231 | terrain_check->lon = mavlink_msg_terrain_check_get_lon(msg); 232 | #else 233 | uint8_t len = msg->len < MAVLINK_MSG_ID_TERRAIN_CHECK_LEN? msg->len : MAVLINK_MSG_ID_TERRAIN_CHECK_LEN; 234 | memset(terrain_check, 0, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN); 235 | memcpy(terrain_check, _MAV_PAYLOAD(msg), len); 236 | #endif 237 | } 238 | -------------------------------------------------------------------------------- /libraries/mavlink/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_PACKED __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_COMMAND_ACK_MIN_LEN 3 13 | #define MAVLINK_MSG_ID_77_LEN 3 14 | #define MAVLINK_MSG_ID_77_MIN_LEN 3 15 | 16 | #define MAVLINK_MSG_ID_COMMAND_ACK_CRC 143 17 | #define MAVLINK_MSG_ID_77_CRC 143 18 | 19 | 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_COMMAND_ACK { \ 23 | 77, \ 24 | "COMMAND_ACK", \ 25 | 2, \ 26 | { { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_command_ack_t, command) }, \ 27 | { "result", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_command_ack_t, result) }, \ 28 | } \ 29 | } 30 | #else 31 | #define MAVLINK_MESSAGE_INFO_COMMAND_ACK { \ 32 | "COMMAND_ACK", \ 33 | 2, \ 34 | { { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_command_ack_t, command) }, \ 35 | { "result", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_command_ack_t, result) }, \ 36 | } \ 37 | } 38 | #endif 39 | 40 | /** 41 | * @brief Pack a command_ack message 42 | * @param system_id ID of this system 43 | * @param component_id ID of this component (e.g. 200 for IMU) 44 | * @param msg The MAVLink message to compress the data into 45 | * 46 | * @param command Command ID, as defined by MAV_CMD enum. 47 | * @param result See MAV_RESULT enum 48 | * @return length of the message in bytes (excluding serial stream start sign) 49 | */ 50 | static inline uint16_t mavlink_msg_command_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 51 | uint16_t command, uint8_t result) 52 | { 53 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 54 | char buf[MAVLINK_MSG_ID_COMMAND_ACK_LEN]; 55 | _mav_put_uint16_t(buf, 0, command); 56 | _mav_put_uint8_t(buf, 2, result); 57 | 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_ACK_LEN); 59 | #else 60 | mavlink_command_ack_t packet; 61 | packet.command = command; 62 | packet.result = result; 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_ACK_LEN); 65 | #endif 66 | 67 | msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK; 68 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC); 69 | } 70 | 71 | /** 72 | * @brief Pack a command_ack message on a channel 73 | * @param system_id ID of this system 74 | * @param component_id ID of this component (e.g. 200 for IMU) 75 | * @param chan The MAVLink channel this message will be sent over 76 | * @param msg The MAVLink message to compress the data into 77 | * @param command Command ID, as defined by MAV_CMD enum. 78 | * @param result See MAV_RESULT enum 79 | * @return length of the message in bytes (excluding serial stream start sign) 80 | */ 81 | static inline uint16_t mavlink_msg_command_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 82 | mavlink_message_t* msg, 83 | uint16_t command,uint8_t result) 84 | { 85 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 86 | char buf[MAVLINK_MSG_ID_COMMAND_ACK_LEN]; 87 | _mav_put_uint16_t(buf, 0, command); 88 | _mav_put_uint8_t(buf, 2, result); 89 | 90 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_ACK_LEN); 91 | #else 92 | mavlink_command_ack_t packet; 93 | packet.command = command; 94 | packet.result = result; 95 | 96 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_ACK_LEN); 97 | #endif 98 | 99 | msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK; 100 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC); 101 | } 102 | 103 | /** 104 | * @brief Encode a command_ack struct 105 | * 106 | * @param system_id ID of this system 107 | * @param component_id ID of this component (e.g. 200 for IMU) 108 | * @param msg The MAVLink message to compress the data into 109 | * @param command_ack C-struct to read the message contents from 110 | */ 111 | 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) 112 | { 113 | return mavlink_msg_command_ack_pack(system_id, component_id, msg, command_ack->command, command_ack->result); 114 | } 115 | 116 | /** 117 | * @brief Encode a command_ack struct on a channel 118 | * 119 | * @param system_id ID of this system 120 | * @param component_id ID of this component (e.g. 200 for IMU) 121 | * @param chan The MAVLink channel this message will be sent over 122 | * @param msg The MAVLink message to compress the data into 123 | * @param command_ack C-struct to read the message contents from 124 | */ 125 | static inline uint16_t mavlink_msg_command_ack_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_command_ack_t* command_ack) 126 | { 127 | return mavlink_msg_command_ack_pack_chan(system_id, component_id, chan, msg, command_ack->command, command_ack->result); 128 | } 129 | 130 | /** 131 | * @brief Send a command_ack message 132 | * @param chan MAVLink channel to send the message 133 | * 134 | * @param command Command ID, as defined by MAV_CMD enum. 135 | * @param result See MAV_RESULT enum 136 | */ 137 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 138 | 139 | static inline void mavlink_msg_command_ack_send(mavlink_channel_t chan, uint16_t command, uint8_t result) 140 | { 141 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 142 | char buf[MAVLINK_MSG_ID_COMMAND_ACK_LEN]; 143 | _mav_put_uint16_t(buf, 0, command); 144 | _mav_put_uint8_t(buf, 2, result); 145 | 146 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, buf, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC); 147 | #else 148 | mavlink_command_ack_t packet; 149 | packet.command = command; 150 | packet.result = result; 151 | 152 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, (const char *)&packet, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC); 153 | #endif 154 | } 155 | 156 | /** 157 | * @brief Send a command_ack message 158 | * @param chan MAVLink channel to send the message 159 | * @param struct The MAVLink struct to serialize 160 | */ 161 | static inline void mavlink_msg_command_ack_send_struct(mavlink_channel_t chan, const mavlink_command_ack_t* command_ack) 162 | { 163 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 164 | mavlink_msg_command_ack_send(chan, command_ack->command, command_ack->result); 165 | #else 166 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, (const char *)command_ack, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC); 167 | #endif 168 | } 169 | 170 | #if MAVLINK_MSG_ID_COMMAND_ACK_LEN <= MAVLINK_MAX_PAYLOAD_LEN 171 | /* 172 | This varient of _send() can be used to save stack space by re-using 173 | memory from the receive buffer. The caller provides a 174 | mavlink_message_t which is the size of a full mavlink message. This 175 | is usually the receive buffer for the channel, and allows a reply to an 176 | incoming message with minimum stack space usage. 177 | */ 178 | static inline void mavlink_msg_command_ack_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t command, uint8_t result) 179 | { 180 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 181 | char *buf = (char *)msgbuf; 182 | _mav_put_uint16_t(buf, 0, command); 183 | _mav_put_uint8_t(buf, 2, result); 184 | 185 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, buf, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC); 186 | #else 187 | mavlink_command_ack_t *packet = (mavlink_command_ack_t *)msgbuf; 188 | packet->command = command; 189 | packet->result = result; 190 | 191 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, (const char *)packet, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC); 192 | #endif 193 | } 194 | #endif 195 | 196 | #endif 197 | 198 | // MESSAGE COMMAND_ACK UNPACKING 199 | 200 | 201 | /** 202 | * @brief Get field command from command_ack message 203 | * 204 | * @return Command ID, as defined by MAV_CMD enum. 205 | */ 206 | static inline uint16_t mavlink_msg_command_ack_get_command(const mavlink_message_t* msg) 207 | { 208 | return _MAV_RETURN_uint16_t(msg, 0); 209 | } 210 | 211 | /** 212 | * @brief Get field result from command_ack message 213 | * 214 | * @return See MAV_RESULT enum 215 | */ 216 | static inline uint8_t mavlink_msg_command_ack_get_result(const mavlink_message_t* msg) 217 | { 218 | return _MAV_RETURN_uint8_t(msg, 2); 219 | } 220 | 221 | /** 222 | * @brief Decode a command_ack message into a struct 223 | * 224 | * @param msg The message to decode 225 | * @param command_ack C-struct to decode the message contents into 226 | */ 227 | static inline void mavlink_msg_command_ack_decode(const mavlink_message_t* msg, mavlink_command_ack_t* command_ack) 228 | { 229 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 230 | command_ack->command = mavlink_msg_command_ack_get_command(msg); 231 | command_ack->result = mavlink_msg_command_ack_get_result(msg); 232 | #else 233 | uint8_t len = msg->len < MAVLINK_MSG_ID_COMMAND_ACK_LEN? msg->len : MAVLINK_MSG_ID_COMMAND_ACK_LEN; 234 | memset(command_ack, 0, MAVLINK_MSG_ID_COMMAND_ACK_LEN); 235 | memcpy(command_ack, _MAV_PAYLOAD(msg), len); 236 | #endif 237 | } 238 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_log_erase.h: -------------------------------------------------------------------------------- 1 | // MESSAGE LOG_ERASE PACKING 2 | 3 | #define MAVLINK_MSG_ID_LOG_ERASE 121 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_log_erase_t 6 | { 7 | uint8_t target_system; /*< System ID*/ 8 | uint8_t target_component; /*< Component ID*/ 9 | } mavlink_log_erase_t; 10 | 11 | #define MAVLINK_MSG_ID_LOG_ERASE_LEN 2 12 | #define MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN 2 13 | #define MAVLINK_MSG_ID_121_LEN 2 14 | #define MAVLINK_MSG_ID_121_MIN_LEN 2 15 | 16 | #define MAVLINK_MSG_ID_LOG_ERASE_CRC 237 17 | #define MAVLINK_MSG_ID_121_CRC 237 18 | 19 | 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_LOG_ERASE { \ 23 | 121, \ 24 | "LOG_ERASE", \ 25 | 2, \ 26 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_log_erase_t, target_system) }, \ 27 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_log_erase_t, target_component) }, \ 28 | } \ 29 | } 30 | #else 31 | #define MAVLINK_MESSAGE_INFO_LOG_ERASE { \ 32 | "LOG_ERASE", \ 33 | 2, \ 34 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_log_erase_t, target_system) }, \ 35 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_log_erase_t, target_component) }, \ 36 | } \ 37 | } 38 | #endif 39 | 40 | /** 41 | * @brief Pack a log_erase message 42 | * @param system_id ID of this system 43 | * @param component_id ID of this component (e.g. 200 for IMU) 44 | * @param msg The MAVLink message to compress the data into 45 | * 46 | * @param target_system System ID 47 | * @param target_component Component ID 48 | * @return length of the message in bytes (excluding serial stream start sign) 49 | */ 50 | static inline uint16_t mavlink_msg_log_erase_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 51 | uint8_t target_system, uint8_t target_component) 52 | { 53 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 54 | char buf[MAVLINK_MSG_ID_LOG_ERASE_LEN]; 55 | _mav_put_uint8_t(buf, 0, target_system); 56 | _mav_put_uint8_t(buf, 1, target_component); 57 | 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_ERASE_LEN); 59 | #else 60 | mavlink_log_erase_t packet; 61 | packet.target_system = target_system; 62 | packet.target_component = target_component; 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_ERASE_LEN); 65 | #endif 66 | 67 | msg->msgid = MAVLINK_MSG_ID_LOG_ERASE; 68 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); 69 | } 70 | 71 | /** 72 | * @brief Pack a log_erase message on a channel 73 | * @param system_id ID of this system 74 | * @param component_id ID of this component (e.g. 200 for IMU) 75 | * @param chan The MAVLink channel this message will be sent over 76 | * @param msg The MAVLink message to compress the data into 77 | * @param target_system System ID 78 | * @param target_component Component ID 79 | * @return length of the message in bytes (excluding serial stream start sign) 80 | */ 81 | static inline uint16_t mavlink_msg_log_erase_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 82 | mavlink_message_t* msg, 83 | uint8_t target_system,uint8_t target_component) 84 | { 85 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 86 | char buf[MAVLINK_MSG_ID_LOG_ERASE_LEN]; 87 | _mav_put_uint8_t(buf, 0, target_system); 88 | _mav_put_uint8_t(buf, 1, target_component); 89 | 90 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_ERASE_LEN); 91 | #else 92 | mavlink_log_erase_t packet; 93 | packet.target_system = target_system; 94 | packet.target_component = target_component; 95 | 96 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_ERASE_LEN); 97 | #endif 98 | 99 | msg->msgid = MAVLINK_MSG_ID_LOG_ERASE; 100 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); 101 | } 102 | 103 | /** 104 | * @brief Encode a log_erase struct 105 | * 106 | * @param system_id ID of this system 107 | * @param component_id ID of this component (e.g. 200 for IMU) 108 | * @param msg The MAVLink message to compress the data into 109 | * @param log_erase C-struct to read the message contents from 110 | */ 111 | static inline uint16_t mavlink_msg_log_erase_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_log_erase_t* log_erase) 112 | { 113 | return mavlink_msg_log_erase_pack(system_id, component_id, msg, log_erase->target_system, log_erase->target_component); 114 | } 115 | 116 | /** 117 | * @brief Encode a log_erase struct on a channel 118 | * 119 | * @param system_id ID of this system 120 | * @param component_id ID of this component (e.g. 200 for IMU) 121 | * @param chan The MAVLink channel this message will be sent over 122 | * @param msg The MAVLink message to compress the data into 123 | * @param log_erase C-struct to read the message contents from 124 | */ 125 | static inline uint16_t mavlink_msg_log_erase_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_log_erase_t* log_erase) 126 | { 127 | return mavlink_msg_log_erase_pack_chan(system_id, component_id, chan, msg, log_erase->target_system, log_erase->target_component); 128 | } 129 | 130 | /** 131 | * @brief Send a log_erase message 132 | * @param chan MAVLink channel to send the message 133 | * 134 | * @param target_system System ID 135 | * @param target_component Component ID 136 | */ 137 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 138 | 139 | static inline void mavlink_msg_log_erase_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 140 | { 141 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 142 | char buf[MAVLINK_MSG_ID_LOG_ERASE_LEN]; 143 | _mav_put_uint8_t(buf, 0, target_system); 144 | _mav_put_uint8_t(buf, 1, target_component); 145 | 146 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ERASE, buf, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); 147 | #else 148 | mavlink_log_erase_t packet; 149 | packet.target_system = target_system; 150 | packet.target_component = target_component; 151 | 152 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ERASE, (const char *)&packet, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); 153 | #endif 154 | } 155 | 156 | /** 157 | * @brief Send a log_erase message 158 | * @param chan MAVLink channel to send the message 159 | * @param struct The MAVLink struct to serialize 160 | */ 161 | static inline void mavlink_msg_log_erase_send_struct(mavlink_channel_t chan, const mavlink_log_erase_t* log_erase) 162 | { 163 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 164 | mavlink_msg_log_erase_send(chan, log_erase->target_system, log_erase->target_component); 165 | #else 166 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ERASE, (const char *)log_erase, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); 167 | #endif 168 | } 169 | 170 | #if MAVLINK_MSG_ID_LOG_ERASE_LEN <= MAVLINK_MAX_PAYLOAD_LEN 171 | /* 172 | This varient of _send() can be used to save stack space by re-using 173 | memory from the receive buffer. The caller provides a 174 | mavlink_message_t which is the size of a full mavlink message. This 175 | is usually the receive buffer for the channel, and allows a reply to an 176 | incoming message with minimum stack space usage. 177 | */ 178 | static inline void mavlink_msg_log_erase_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 179 | { 180 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 181 | char *buf = (char *)msgbuf; 182 | _mav_put_uint8_t(buf, 0, target_system); 183 | _mav_put_uint8_t(buf, 1, target_component); 184 | 185 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ERASE, buf, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); 186 | #else 187 | mavlink_log_erase_t *packet = (mavlink_log_erase_t *)msgbuf; 188 | packet->target_system = target_system; 189 | packet->target_component = target_component; 190 | 191 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ERASE, (const char *)packet, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); 192 | #endif 193 | } 194 | #endif 195 | 196 | #endif 197 | 198 | // MESSAGE LOG_ERASE UNPACKING 199 | 200 | 201 | /** 202 | * @brief Get field target_system from log_erase message 203 | * 204 | * @return System ID 205 | */ 206 | static inline uint8_t mavlink_msg_log_erase_get_target_system(const mavlink_message_t* msg) 207 | { 208 | return _MAV_RETURN_uint8_t(msg, 0); 209 | } 210 | 211 | /** 212 | * @brief Get field target_component from log_erase message 213 | * 214 | * @return Component ID 215 | */ 216 | static inline uint8_t mavlink_msg_log_erase_get_target_component(const mavlink_message_t* msg) 217 | { 218 | return _MAV_RETURN_uint8_t(msg, 1); 219 | } 220 | 221 | /** 222 | * @brief Decode a log_erase message into a struct 223 | * 224 | * @param msg The message to decode 225 | * @param log_erase C-struct to decode the message contents into 226 | */ 227 | static inline void mavlink_msg_log_erase_decode(const mavlink_message_t* msg, mavlink_log_erase_t* log_erase) 228 | { 229 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 230 | log_erase->target_system = mavlink_msg_log_erase_get_target_system(msg); 231 | log_erase->target_component = mavlink_msg_log_erase_get_target_component(msg); 232 | #else 233 | uint8_t len = msg->len < MAVLINK_MSG_ID_LOG_ERASE_LEN? msg->len : MAVLINK_MSG_ID_LOG_ERASE_LEN; 234 | memset(log_erase, 0, MAVLINK_MSG_ID_LOG_ERASE_LEN); 235 | memcpy(log_erase, _MAV_PAYLOAD(msg), len); 236 | #endif 237 | } 238 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_camera_trigger.h: -------------------------------------------------------------------------------- 1 | // MESSAGE CAMERA_TRIGGER PACKING 2 | 3 | #define MAVLINK_MSG_ID_CAMERA_TRIGGER 112 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_camera_trigger_t 6 | { 7 | uint64_t time_usec; /*< Timestamp for the image frame in microseconds*/ 8 | uint32_t seq; /*< Image frame sequence*/ 9 | } mavlink_camera_trigger_t; 10 | 11 | #define MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN 12 12 | #define MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN 12 13 | #define MAVLINK_MSG_ID_112_LEN 12 14 | #define MAVLINK_MSG_ID_112_MIN_LEN 12 15 | 16 | #define MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC 174 17 | #define MAVLINK_MSG_ID_112_CRC 174 18 | 19 | 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_CAMERA_TRIGGER { \ 23 | 112, \ 24 | "CAMERA_TRIGGER", \ 25 | 2, \ 26 | { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_camera_trigger_t, time_usec) }, \ 27 | { "seq", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_camera_trigger_t, seq) }, \ 28 | } \ 29 | } 30 | #else 31 | #define MAVLINK_MESSAGE_INFO_CAMERA_TRIGGER { \ 32 | "CAMERA_TRIGGER", \ 33 | 2, \ 34 | { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_camera_trigger_t, time_usec) }, \ 35 | { "seq", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_camera_trigger_t, seq) }, \ 36 | } \ 37 | } 38 | #endif 39 | 40 | /** 41 | * @brief Pack a camera_trigger message 42 | * @param system_id ID of this system 43 | * @param component_id ID of this component (e.g. 200 for IMU) 44 | * @param msg The MAVLink message to compress the data into 45 | * 46 | * @param time_usec Timestamp for the image frame in microseconds 47 | * @param seq Image frame sequence 48 | * @return length of the message in bytes (excluding serial stream start sign) 49 | */ 50 | static inline uint16_t mavlink_msg_camera_trigger_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 51 | uint64_t time_usec, uint32_t seq) 52 | { 53 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 54 | char buf[MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN]; 55 | _mav_put_uint64_t(buf, 0, time_usec); 56 | _mav_put_uint32_t(buf, 8, seq); 57 | 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN); 59 | #else 60 | mavlink_camera_trigger_t packet; 61 | packet.time_usec = time_usec; 62 | packet.seq = seq; 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN); 65 | #endif 66 | 67 | msg->msgid = MAVLINK_MSG_ID_CAMERA_TRIGGER; 68 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); 69 | } 70 | 71 | /** 72 | * @brief Pack a camera_trigger message on a channel 73 | * @param system_id ID of this system 74 | * @param component_id ID of this component (e.g. 200 for IMU) 75 | * @param chan The MAVLink channel this message will be sent over 76 | * @param msg The MAVLink message to compress the data into 77 | * @param time_usec Timestamp for the image frame in microseconds 78 | * @param seq Image frame sequence 79 | * @return length of the message in bytes (excluding serial stream start sign) 80 | */ 81 | static inline uint16_t mavlink_msg_camera_trigger_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 82 | mavlink_message_t* msg, 83 | uint64_t time_usec,uint32_t seq) 84 | { 85 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 86 | char buf[MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN]; 87 | _mav_put_uint64_t(buf, 0, time_usec); 88 | _mav_put_uint32_t(buf, 8, seq); 89 | 90 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN); 91 | #else 92 | mavlink_camera_trigger_t packet; 93 | packet.time_usec = time_usec; 94 | packet.seq = seq; 95 | 96 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN); 97 | #endif 98 | 99 | msg->msgid = MAVLINK_MSG_ID_CAMERA_TRIGGER; 100 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); 101 | } 102 | 103 | /** 104 | * @brief Encode a camera_trigger struct 105 | * 106 | * @param system_id ID of this system 107 | * @param component_id ID of this component (e.g. 200 for IMU) 108 | * @param msg The MAVLink message to compress the data into 109 | * @param camera_trigger C-struct to read the message contents from 110 | */ 111 | static inline uint16_t mavlink_msg_camera_trigger_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_camera_trigger_t* camera_trigger) 112 | { 113 | return mavlink_msg_camera_trigger_pack(system_id, component_id, msg, camera_trigger->time_usec, camera_trigger->seq); 114 | } 115 | 116 | /** 117 | * @brief Encode a camera_trigger struct on a channel 118 | * 119 | * @param system_id ID of this system 120 | * @param component_id ID of this component (e.g. 200 for IMU) 121 | * @param chan The MAVLink channel this message will be sent over 122 | * @param msg The MAVLink message to compress the data into 123 | * @param camera_trigger C-struct to read the message contents from 124 | */ 125 | static inline uint16_t mavlink_msg_camera_trigger_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_camera_trigger_t* camera_trigger) 126 | { 127 | return mavlink_msg_camera_trigger_pack_chan(system_id, component_id, chan, msg, camera_trigger->time_usec, camera_trigger->seq); 128 | } 129 | 130 | /** 131 | * @brief Send a camera_trigger message 132 | * @param chan MAVLink channel to send the message 133 | * 134 | * @param time_usec Timestamp for the image frame in microseconds 135 | * @param seq Image frame sequence 136 | */ 137 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 138 | 139 | static inline void mavlink_msg_camera_trigger_send(mavlink_channel_t chan, uint64_t time_usec, uint32_t seq) 140 | { 141 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 142 | char buf[MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN]; 143 | _mav_put_uint64_t(buf, 0, time_usec); 144 | _mav_put_uint32_t(buf, 8, seq); 145 | 146 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CAMERA_TRIGGER, buf, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); 147 | #else 148 | mavlink_camera_trigger_t packet; 149 | packet.time_usec = time_usec; 150 | packet.seq = seq; 151 | 152 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CAMERA_TRIGGER, (const char *)&packet, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); 153 | #endif 154 | } 155 | 156 | /** 157 | * @brief Send a camera_trigger message 158 | * @param chan MAVLink channel to send the message 159 | * @param struct The MAVLink struct to serialize 160 | */ 161 | static inline void mavlink_msg_camera_trigger_send_struct(mavlink_channel_t chan, const mavlink_camera_trigger_t* camera_trigger) 162 | { 163 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 164 | mavlink_msg_camera_trigger_send(chan, camera_trigger->time_usec, camera_trigger->seq); 165 | #else 166 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CAMERA_TRIGGER, (const char *)camera_trigger, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); 167 | #endif 168 | } 169 | 170 | #if MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN <= MAVLINK_MAX_PAYLOAD_LEN 171 | /* 172 | This varient of _send() can be used to save stack space by re-using 173 | memory from the receive buffer. The caller provides a 174 | mavlink_message_t which is the size of a full mavlink message. This 175 | is usually the receive buffer for the channel, and allows a reply to an 176 | incoming message with minimum stack space usage. 177 | */ 178 | static inline void mavlink_msg_camera_trigger_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, uint32_t seq) 179 | { 180 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 181 | char *buf = (char *)msgbuf; 182 | _mav_put_uint64_t(buf, 0, time_usec); 183 | _mav_put_uint32_t(buf, 8, seq); 184 | 185 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CAMERA_TRIGGER, buf, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); 186 | #else 187 | mavlink_camera_trigger_t *packet = (mavlink_camera_trigger_t *)msgbuf; 188 | packet->time_usec = time_usec; 189 | packet->seq = seq; 190 | 191 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CAMERA_TRIGGER, (const char *)packet, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); 192 | #endif 193 | } 194 | #endif 195 | 196 | #endif 197 | 198 | // MESSAGE CAMERA_TRIGGER UNPACKING 199 | 200 | 201 | /** 202 | * @brief Get field time_usec from camera_trigger message 203 | * 204 | * @return Timestamp for the image frame in microseconds 205 | */ 206 | static inline uint64_t mavlink_msg_camera_trigger_get_time_usec(const mavlink_message_t* msg) 207 | { 208 | return _MAV_RETURN_uint64_t(msg, 0); 209 | } 210 | 211 | /** 212 | * @brief Get field seq from camera_trigger message 213 | * 214 | * @return Image frame sequence 215 | */ 216 | static inline uint32_t mavlink_msg_camera_trigger_get_seq(const mavlink_message_t* msg) 217 | { 218 | return _MAV_RETURN_uint32_t(msg, 8); 219 | } 220 | 221 | /** 222 | * @brief Decode a camera_trigger message into a struct 223 | * 224 | * @param msg The message to decode 225 | * @param camera_trigger C-struct to decode the message contents into 226 | */ 227 | static inline void mavlink_msg_camera_trigger_decode(const mavlink_message_t* msg, mavlink_camera_trigger_t* camera_trigger) 228 | { 229 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 230 | camera_trigger->time_usec = mavlink_msg_camera_trigger_get_time_usec(msg); 231 | camera_trigger->seq = mavlink_msg_camera_trigger_get_seq(msg); 232 | #else 233 | uint8_t len = msg->len < MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN? msg->len : MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN; 234 | memset(camera_trigger, 0, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN); 235 | memcpy(camera_trigger, _MAV_PAYLOAD(msg), len); 236 | #endif 237 | } 238 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_statustext.h: -------------------------------------------------------------------------------- 1 | // MESSAGE STATUSTEXT PACKING 2 | 3 | #define MAVLINK_MSG_ID_STATUSTEXT 253 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_statustext_t 6 | { 7 | uint8_t severity; /*< Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.*/ 8 | char text[50]; /*< Status text message, without null termination character*/ 9 | } mavlink_statustext_t; 10 | 11 | #define MAVLINK_MSG_ID_STATUSTEXT_LEN 51 12 | #define MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN 51 13 | #define MAVLINK_MSG_ID_253_LEN 51 14 | #define MAVLINK_MSG_ID_253_MIN_LEN 51 15 | 16 | #define MAVLINK_MSG_ID_STATUSTEXT_CRC 83 17 | #define MAVLINK_MSG_ID_253_CRC 83 18 | 19 | #define MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN 50 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_STATUSTEXT { \ 23 | 253, \ 24 | "STATUSTEXT", \ 25 | 2, \ 26 | { { "severity", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_statustext_t, severity) }, \ 27 | { "text", NULL, MAVLINK_TYPE_CHAR, 50, 1, offsetof(mavlink_statustext_t, text) }, \ 28 | } \ 29 | } 30 | #else 31 | #define MAVLINK_MESSAGE_INFO_STATUSTEXT { \ 32 | "STATUSTEXT", \ 33 | 2, \ 34 | { { "severity", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_statustext_t, severity) }, \ 35 | { "text", NULL, MAVLINK_TYPE_CHAR, 50, 1, offsetof(mavlink_statustext_t, text) }, \ 36 | } \ 37 | } 38 | #endif 39 | 40 | /** 41 | * @brief Pack a statustext message 42 | * @param system_id ID of this system 43 | * @param component_id ID of this component (e.g. 200 for IMU) 44 | * @param msg The MAVLink message to compress the data into 45 | * 46 | * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY. 47 | * @param text Status text message, without null termination character 48 | * @return length of the message in bytes (excluding serial stream start sign) 49 | */ 50 | static inline uint16_t mavlink_msg_statustext_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 51 | uint8_t severity, const char *text) 52 | { 53 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 54 | char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN]; 55 | _mav_put_uint8_t(buf, 0, severity); 56 | _mav_put_char_array(buf, 1, text, 50); 57 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUSTEXT_LEN); 58 | #else 59 | mavlink_statustext_t packet; 60 | packet.severity = severity; 61 | mav_array_memcpy(packet.text, text, sizeof(char)*50); 62 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUSTEXT_LEN); 63 | #endif 64 | 65 | msg->msgid = MAVLINK_MSG_ID_STATUSTEXT; 66 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC); 67 | } 68 | 69 | /** 70 | * @brief Pack a statustext message on a channel 71 | * @param system_id ID of this system 72 | * @param component_id ID of this component (e.g. 200 for IMU) 73 | * @param chan The MAVLink channel this message will be sent over 74 | * @param msg The MAVLink message to compress the data into 75 | * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY. 76 | * @param text Status text message, without null termination character 77 | * @return length of the message in bytes (excluding serial stream start sign) 78 | */ 79 | static inline uint16_t mavlink_msg_statustext_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 80 | mavlink_message_t* msg, 81 | uint8_t severity,const char *text) 82 | { 83 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 84 | char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN]; 85 | _mav_put_uint8_t(buf, 0, severity); 86 | _mav_put_char_array(buf, 1, text, 50); 87 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUSTEXT_LEN); 88 | #else 89 | mavlink_statustext_t packet; 90 | packet.severity = severity; 91 | mav_array_memcpy(packet.text, text, sizeof(char)*50); 92 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUSTEXT_LEN); 93 | #endif 94 | 95 | msg->msgid = MAVLINK_MSG_ID_STATUSTEXT; 96 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC); 97 | } 98 | 99 | /** 100 | * @brief Encode a statustext struct 101 | * 102 | * @param system_id ID of this system 103 | * @param component_id ID of this component (e.g. 200 for IMU) 104 | * @param msg The MAVLink message to compress the data into 105 | * @param statustext C-struct to read the message contents from 106 | */ 107 | static inline uint16_t mavlink_msg_statustext_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_statustext_t* statustext) 108 | { 109 | return mavlink_msg_statustext_pack(system_id, component_id, msg, statustext->severity, statustext->text); 110 | } 111 | 112 | /** 113 | * @brief Encode a statustext struct on a channel 114 | * 115 | * @param system_id ID of this system 116 | * @param component_id ID of this component (e.g. 200 for IMU) 117 | * @param chan The MAVLink channel this message will be sent over 118 | * @param msg The MAVLink message to compress the data into 119 | * @param statustext C-struct to read the message contents from 120 | */ 121 | static inline uint16_t mavlink_msg_statustext_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_statustext_t* statustext) 122 | { 123 | return mavlink_msg_statustext_pack_chan(system_id, component_id, chan, msg, statustext->severity, statustext->text); 124 | } 125 | 126 | /** 127 | * @brief Send a statustext message 128 | * @param chan MAVLink channel to send the message 129 | * 130 | * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY. 131 | * @param text Status text message, without null termination character 132 | */ 133 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 134 | 135 | static inline void mavlink_msg_statustext_send(mavlink_channel_t chan, uint8_t severity, const char *text) 136 | { 137 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 138 | char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN]; 139 | _mav_put_uint8_t(buf, 0, severity); 140 | _mav_put_char_array(buf, 1, text, 50); 141 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, buf, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC); 142 | #else 143 | mavlink_statustext_t packet; 144 | packet.severity = severity; 145 | mav_array_memcpy(packet.text, text, sizeof(char)*50); 146 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, (const char *)&packet, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC); 147 | #endif 148 | } 149 | 150 | /** 151 | * @brief Send a statustext message 152 | * @param chan MAVLink channel to send the message 153 | * @param struct The MAVLink struct to serialize 154 | */ 155 | static inline void mavlink_msg_statustext_send_struct(mavlink_channel_t chan, const mavlink_statustext_t* statustext) 156 | { 157 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 158 | mavlink_msg_statustext_send(chan, statustext->severity, statustext->text); 159 | #else 160 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, (const char *)statustext, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC); 161 | #endif 162 | } 163 | 164 | #if MAVLINK_MSG_ID_STATUSTEXT_LEN <= MAVLINK_MAX_PAYLOAD_LEN 165 | /* 166 | This varient of _send() can be used to save stack space by re-using 167 | memory from the receive buffer. The caller provides a 168 | mavlink_message_t which is the size of a full mavlink message. This 169 | is usually the receive buffer for the channel, and allows a reply to an 170 | incoming message with minimum stack space usage. 171 | */ 172 | static inline void mavlink_msg_statustext_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t severity, const char *text) 173 | { 174 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 175 | char *buf = (char *)msgbuf; 176 | _mav_put_uint8_t(buf, 0, severity); 177 | _mav_put_char_array(buf, 1, text, 50); 178 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, buf, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC); 179 | #else 180 | mavlink_statustext_t *packet = (mavlink_statustext_t *)msgbuf; 181 | packet->severity = severity; 182 | mav_array_memcpy(packet->text, text, sizeof(char)*50); 183 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, (const char *)packet, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC); 184 | #endif 185 | } 186 | #endif 187 | 188 | #endif 189 | 190 | // MESSAGE STATUSTEXT UNPACKING 191 | 192 | 193 | /** 194 | * @brief Get field severity from statustext message 195 | * 196 | * @return Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY. 197 | */ 198 | static inline uint8_t mavlink_msg_statustext_get_severity(const mavlink_message_t* msg) 199 | { 200 | return _MAV_RETURN_uint8_t(msg, 0); 201 | } 202 | 203 | /** 204 | * @brief Get field text from statustext message 205 | * 206 | * @return Status text message, without null termination character 207 | */ 208 | static inline uint16_t mavlink_msg_statustext_get_text(const mavlink_message_t* msg, char *text) 209 | { 210 | return _MAV_RETURN_char_array(msg, text, 50, 1); 211 | } 212 | 213 | /** 214 | * @brief Decode a statustext message into a struct 215 | * 216 | * @param msg The message to decode 217 | * @param statustext C-struct to decode the message contents into 218 | */ 219 | static inline void mavlink_msg_statustext_decode(const mavlink_message_t* msg, mavlink_statustext_t* statustext) 220 | { 221 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 222 | statustext->severity = mavlink_msg_statustext_get_severity(msg); 223 | mavlink_msg_statustext_get_text(msg, statustext->text); 224 | #else 225 | uint8_t len = msg->len < MAVLINK_MSG_ID_STATUSTEXT_LEN? msg->len : MAVLINK_MSG_ID_STATUSTEXT_LEN; 226 | memset(statustext, 0, MAVLINK_MSG_ID_STATUSTEXT_LEN); 227 | memcpy(statustext, _MAV_PAYLOAD(msg), len); 228 | #endif 229 | } 230 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_debug.h: -------------------------------------------------------------------------------- 1 | // MESSAGE DEBUG PACKING 2 | 3 | #define MAVLINK_MSG_ID_DEBUG 254 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_debug_t 6 | { 7 | uint32_t time_boot_ms; /*< Timestamp (milliseconds since system boot)*/ 8 | float value; /*< DEBUG value*/ 9 | uint8_t ind; /*< index of debug variable*/ 10 | } mavlink_debug_t; 11 | 12 | #define MAVLINK_MSG_ID_DEBUG_LEN 9 13 | #define MAVLINK_MSG_ID_DEBUG_MIN_LEN 9 14 | #define MAVLINK_MSG_ID_254_LEN 9 15 | #define MAVLINK_MSG_ID_254_MIN_LEN 9 16 | 17 | #define MAVLINK_MSG_ID_DEBUG_CRC 46 18 | #define MAVLINK_MSG_ID_254_CRC 46 19 | 20 | 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_DEBUG { \ 24 | 254, \ 25 | "DEBUG", \ 26 | 3, \ 27 | { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_debug_t, time_boot_ms) }, \ 28 | { "value", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_debug_t, value) }, \ 29 | { "ind", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_debug_t, ind) }, \ 30 | } \ 31 | } 32 | #else 33 | #define MAVLINK_MESSAGE_INFO_DEBUG { \ 34 | "DEBUG", \ 35 | 3, \ 36 | { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_debug_t, time_boot_ms) }, \ 37 | { "value", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_debug_t, value) }, \ 38 | { "ind", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_debug_t, ind) }, \ 39 | } \ 40 | } 41 | #endif 42 | 43 | /** 44 | * @brief Pack a debug message 45 | * @param system_id ID of this system 46 | * @param component_id ID of this component (e.g. 200 for IMU) 47 | * @param msg The MAVLink message to compress the data into 48 | * 49 | * @param time_boot_ms Timestamp (milliseconds since system boot) 50 | * @param ind index of debug variable 51 | * @param value DEBUG value 52 | * @return length of the message in bytes (excluding serial stream start sign) 53 | */ 54 | static inline uint16_t mavlink_msg_debug_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 55 | uint32_t time_boot_ms, uint8_t ind, float value) 56 | { 57 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 58 | char buf[MAVLINK_MSG_ID_DEBUG_LEN]; 59 | _mav_put_uint32_t(buf, 0, time_boot_ms); 60 | _mav_put_float(buf, 4, value); 61 | _mav_put_uint8_t(buf, 8, ind); 62 | 63 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEBUG_LEN); 64 | #else 65 | mavlink_debug_t packet; 66 | packet.time_boot_ms = time_boot_ms; 67 | packet.value = value; 68 | packet.ind = ind; 69 | 70 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEBUG_LEN); 71 | #endif 72 | 73 | msg->msgid = MAVLINK_MSG_ID_DEBUG; 74 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); 75 | } 76 | 77 | /** 78 | * @brief Pack a debug message on a channel 79 | * @param system_id ID of this system 80 | * @param component_id ID of this component (e.g. 200 for IMU) 81 | * @param chan The MAVLink channel this message will be sent over 82 | * @param msg The MAVLink message to compress the data into 83 | * @param time_boot_ms Timestamp (milliseconds since system boot) 84 | * @param ind index of debug variable 85 | * @param value DEBUG value 86 | * @return length of the message in bytes (excluding serial stream start sign) 87 | */ 88 | static inline uint16_t mavlink_msg_debug_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 89 | mavlink_message_t* msg, 90 | uint32_t time_boot_ms,uint8_t ind,float value) 91 | { 92 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 93 | char buf[MAVLINK_MSG_ID_DEBUG_LEN]; 94 | _mav_put_uint32_t(buf, 0, time_boot_ms); 95 | _mav_put_float(buf, 4, value); 96 | _mav_put_uint8_t(buf, 8, ind); 97 | 98 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEBUG_LEN); 99 | #else 100 | mavlink_debug_t packet; 101 | packet.time_boot_ms = time_boot_ms; 102 | packet.value = value; 103 | packet.ind = ind; 104 | 105 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEBUG_LEN); 106 | #endif 107 | 108 | msg->msgid = MAVLINK_MSG_ID_DEBUG; 109 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); 110 | } 111 | 112 | /** 113 | * @brief Encode a debug struct 114 | * 115 | * @param system_id ID of this system 116 | * @param component_id ID of this component (e.g. 200 for IMU) 117 | * @param msg The MAVLink message to compress the data into 118 | * @param debug C-struct to read the message contents from 119 | */ 120 | 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) 121 | { 122 | return mavlink_msg_debug_pack(system_id, component_id, msg, debug->time_boot_ms, debug->ind, debug->value); 123 | } 124 | 125 | /** 126 | * @brief Encode a debug struct on a channel 127 | * 128 | * @param system_id ID of this system 129 | * @param component_id ID of this component (e.g. 200 for IMU) 130 | * @param chan The MAVLink channel this message will be sent over 131 | * @param msg The MAVLink message to compress the data into 132 | * @param debug C-struct to read the message contents from 133 | */ 134 | static inline uint16_t mavlink_msg_debug_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_debug_t* debug) 135 | { 136 | return mavlink_msg_debug_pack_chan(system_id, component_id, chan, msg, debug->time_boot_ms, debug->ind, debug->value); 137 | } 138 | 139 | /** 140 | * @brief Send a debug message 141 | * @param chan MAVLink channel to send the message 142 | * 143 | * @param time_boot_ms Timestamp (milliseconds since system boot) 144 | * @param ind index of debug variable 145 | * @param value DEBUG value 146 | */ 147 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 148 | 149 | static inline void mavlink_msg_debug_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t ind, float value) 150 | { 151 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 152 | char buf[MAVLINK_MSG_ID_DEBUG_LEN]; 153 | _mav_put_uint32_t(buf, 0, time_boot_ms); 154 | _mav_put_float(buf, 4, value); 155 | _mav_put_uint8_t(buf, 8, ind); 156 | 157 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, buf, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); 158 | #else 159 | mavlink_debug_t packet; 160 | packet.time_boot_ms = time_boot_ms; 161 | packet.value = value; 162 | packet.ind = ind; 163 | 164 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, (const char *)&packet, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); 165 | #endif 166 | } 167 | 168 | /** 169 | * @brief Send a debug message 170 | * @param chan MAVLink channel to send the message 171 | * @param struct The MAVLink struct to serialize 172 | */ 173 | static inline void mavlink_msg_debug_send_struct(mavlink_channel_t chan, const mavlink_debug_t* debug) 174 | { 175 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 176 | mavlink_msg_debug_send(chan, debug->time_boot_ms, debug->ind, debug->value); 177 | #else 178 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, (const char *)debug, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); 179 | #endif 180 | } 181 | 182 | #if MAVLINK_MSG_ID_DEBUG_LEN <= MAVLINK_MAX_PAYLOAD_LEN 183 | /* 184 | This varient of _send() can be used to save stack space by re-using 185 | memory from the receive buffer. The caller provides a 186 | mavlink_message_t which is the size of a full mavlink message. This 187 | is usually the receive buffer for the channel, and allows a reply to an 188 | incoming message with minimum stack space usage. 189 | */ 190 | static inline void mavlink_msg_debug_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t ind, float value) 191 | { 192 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 193 | char *buf = (char *)msgbuf; 194 | _mav_put_uint32_t(buf, 0, time_boot_ms); 195 | _mav_put_float(buf, 4, value); 196 | _mav_put_uint8_t(buf, 8, ind); 197 | 198 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, buf, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); 199 | #else 200 | mavlink_debug_t *packet = (mavlink_debug_t *)msgbuf; 201 | packet->time_boot_ms = time_boot_ms; 202 | packet->value = value; 203 | packet->ind = ind; 204 | 205 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, (const char *)packet, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); 206 | #endif 207 | } 208 | #endif 209 | 210 | #endif 211 | 212 | // MESSAGE DEBUG UNPACKING 213 | 214 | 215 | /** 216 | * @brief Get field time_boot_ms from debug message 217 | * 218 | * @return Timestamp (milliseconds since system boot) 219 | */ 220 | static inline uint32_t mavlink_msg_debug_get_time_boot_ms(const mavlink_message_t* msg) 221 | { 222 | return _MAV_RETURN_uint32_t(msg, 0); 223 | } 224 | 225 | /** 226 | * @brief Get field ind from debug message 227 | * 228 | * @return index of debug variable 229 | */ 230 | static inline uint8_t mavlink_msg_debug_get_ind(const mavlink_message_t* msg) 231 | { 232 | return _MAV_RETURN_uint8_t(msg, 8); 233 | } 234 | 235 | /** 236 | * @brief Get field value from debug message 237 | * 238 | * @return DEBUG value 239 | */ 240 | static inline float mavlink_msg_debug_get_value(const mavlink_message_t* msg) 241 | { 242 | return _MAV_RETURN_float(msg, 4); 243 | } 244 | 245 | /** 246 | * @brief Decode a debug message into a struct 247 | * 248 | * @param msg The message to decode 249 | * @param debug C-struct to decode the message contents into 250 | */ 251 | static inline void mavlink_msg_debug_decode(const mavlink_message_t* msg, mavlink_debug_t* debug) 252 | { 253 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 254 | debug->time_boot_ms = mavlink_msg_debug_get_time_boot_ms(msg); 255 | debug->value = mavlink_msg_debug_get_value(msg); 256 | debug->ind = mavlink_msg_debug_get_ind(msg); 257 | #else 258 | uint8_t len = msg->len < MAVLINK_MSG_ID_DEBUG_LEN? msg->len : MAVLINK_MSG_ID_DEBUG_LEN; 259 | memset(debug, 0, MAVLINK_MSG_ID_DEBUG_LEN); 260 | memcpy(debug, _MAV_PAYLOAD(msg), len); 261 | #endif 262 | } 263 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_log_request_end.h: -------------------------------------------------------------------------------- 1 | // MESSAGE LOG_REQUEST_END PACKING 2 | 3 | #define MAVLINK_MSG_ID_LOG_REQUEST_END 122 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_log_request_end_t 6 | { 7 | uint8_t target_system; /*< System ID*/ 8 | uint8_t target_component; /*< Component ID*/ 9 | } mavlink_log_request_end_t; 10 | 11 | #define MAVLINK_MSG_ID_LOG_REQUEST_END_LEN 2 12 | #define MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN 2 13 | #define MAVLINK_MSG_ID_122_LEN 2 14 | #define MAVLINK_MSG_ID_122_MIN_LEN 2 15 | 16 | #define MAVLINK_MSG_ID_LOG_REQUEST_END_CRC 203 17 | #define MAVLINK_MSG_ID_122_CRC 203 18 | 19 | 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_LOG_REQUEST_END { \ 23 | 122, \ 24 | "LOG_REQUEST_END", \ 25 | 2, \ 26 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_log_request_end_t, target_system) }, \ 27 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_log_request_end_t, target_component) }, \ 28 | } \ 29 | } 30 | #else 31 | #define MAVLINK_MESSAGE_INFO_LOG_REQUEST_END { \ 32 | "LOG_REQUEST_END", \ 33 | 2, \ 34 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_log_request_end_t, target_system) }, \ 35 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_log_request_end_t, target_component) }, \ 36 | } \ 37 | } 38 | #endif 39 | 40 | /** 41 | * @brief Pack a log_request_end message 42 | * @param system_id ID of this system 43 | * @param component_id ID of this component (e.g. 200 for IMU) 44 | * @param msg The MAVLink message to compress the data into 45 | * 46 | * @param target_system System ID 47 | * @param target_component Component ID 48 | * @return length of the message in bytes (excluding serial stream start sign) 49 | */ 50 | static inline uint16_t mavlink_msg_log_request_end_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 51 | uint8_t target_system, uint8_t target_component) 52 | { 53 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 54 | char buf[MAVLINK_MSG_ID_LOG_REQUEST_END_LEN]; 55 | _mav_put_uint8_t(buf, 0, target_system); 56 | _mav_put_uint8_t(buf, 1, target_component); 57 | 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN); 59 | #else 60 | mavlink_log_request_end_t packet; 61 | packet.target_system = target_system; 62 | packet.target_component = target_component; 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN); 65 | #endif 66 | 67 | msg->msgid = MAVLINK_MSG_ID_LOG_REQUEST_END; 68 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); 69 | } 70 | 71 | /** 72 | * @brief Pack a log_request_end message on a channel 73 | * @param system_id ID of this system 74 | * @param component_id ID of this component (e.g. 200 for IMU) 75 | * @param chan The MAVLink channel this message will be sent over 76 | * @param msg The MAVLink message to compress the data into 77 | * @param target_system System ID 78 | * @param target_component Component ID 79 | * @return length of the message in bytes (excluding serial stream start sign) 80 | */ 81 | static inline uint16_t mavlink_msg_log_request_end_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 82 | mavlink_message_t* msg, 83 | uint8_t target_system,uint8_t target_component) 84 | { 85 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 86 | char buf[MAVLINK_MSG_ID_LOG_REQUEST_END_LEN]; 87 | _mav_put_uint8_t(buf, 0, target_system); 88 | _mav_put_uint8_t(buf, 1, target_component); 89 | 90 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN); 91 | #else 92 | mavlink_log_request_end_t packet; 93 | packet.target_system = target_system; 94 | packet.target_component = target_component; 95 | 96 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN); 97 | #endif 98 | 99 | msg->msgid = MAVLINK_MSG_ID_LOG_REQUEST_END; 100 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); 101 | } 102 | 103 | /** 104 | * @brief Encode a log_request_end struct 105 | * 106 | * @param system_id ID of this system 107 | * @param component_id ID of this component (e.g. 200 for IMU) 108 | * @param msg The MAVLink message to compress the data into 109 | * @param log_request_end C-struct to read the message contents from 110 | */ 111 | static inline uint16_t mavlink_msg_log_request_end_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_log_request_end_t* log_request_end) 112 | { 113 | return mavlink_msg_log_request_end_pack(system_id, component_id, msg, log_request_end->target_system, log_request_end->target_component); 114 | } 115 | 116 | /** 117 | * @brief Encode a log_request_end struct on a channel 118 | * 119 | * @param system_id ID of this system 120 | * @param component_id ID of this component (e.g. 200 for IMU) 121 | * @param chan The MAVLink channel this message will be sent over 122 | * @param msg The MAVLink message to compress the data into 123 | * @param log_request_end C-struct to read the message contents from 124 | */ 125 | static inline uint16_t mavlink_msg_log_request_end_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_log_request_end_t* log_request_end) 126 | { 127 | return mavlink_msg_log_request_end_pack_chan(system_id, component_id, chan, msg, log_request_end->target_system, log_request_end->target_component); 128 | } 129 | 130 | /** 131 | * @brief Send a log_request_end message 132 | * @param chan MAVLink channel to send the message 133 | * 134 | * @param target_system System ID 135 | * @param target_component Component ID 136 | */ 137 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 138 | 139 | static inline void mavlink_msg_log_request_end_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 140 | { 141 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 142 | char buf[MAVLINK_MSG_ID_LOG_REQUEST_END_LEN]; 143 | _mav_put_uint8_t(buf, 0, target_system); 144 | _mav_put_uint8_t(buf, 1, target_component); 145 | 146 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_REQUEST_END, buf, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); 147 | #else 148 | mavlink_log_request_end_t packet; 149 | packet.target_system = target_system; 150 | packet.target_component = target_component; 151 | 152 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_REQUEST_END, (const char *)&packet, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); 153 | #endif 154 | } 155 | 156 | /** 157 | * @brief Send a log_request_end message 158 | * @param chan MAVLink channel to send the message 159 | * @param struct The MAVLink struct to serialize 160 | */ 161 | static inline void mavlink_msg_log_request_end_send_struct(mavlink_channel_t chan, const mavlink_log_request_end_t* log_request_end) 162 | { 163 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 164 | mavlink_msg_log_request_end_send(chan, log_request_end->target_system, log_request_end->target_component); 165 | #else 166 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_REQUEST_END, (const char *)log_request_end, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); 167 | #endif 168 | } 169 | 170 | #if MAVLINK_MSG_ID_LOG_REQUEST_END_LEN <= MAVLINK_MAX_PAYLOAD_LEN 171 | /* 172 | This varient of _send() can be used to save stack space by re-using 173 | memory from the receive buffer. The caller provides a 174 | mavlink_message_t which is the size of a full mavlink message. This 175 | is usually the receive buffer for the channel, and allows a reply to an 176 | incoming message with minimum stack space usage. 177 | */ 178 | static inline void mavlink_msg_log_request_end_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 179 | { 180 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 181 | char *buf = (char *)msgbuf; 182 | _mav_put_uint8_t(buf, 0, target_system); 183 | _mav_put_uint8_t(buf, 1, target_component); 184 | 185 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_REQUEST_END, buf, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); 186 | #else 187 | mavlink_log_request_end_t *packet = (mavlink_log_request_end_t *)msgbuf; 188 | packet->target_system = target_system; 189 | packet->target_component = target_component; 190 | 191 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_REQUEST_END, (const char *)packet, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); 192 | #endif 193 | } 194 | #endif 195 | 196 | #endif 197 | 198 | // MESSAGE LOG_REQUEST_END UNPACKING 199 | 200 | 201 | /** 202 | * @brief Get field target_system from log_request_end message 203 | * 204 | * @return System ID 205 | */ 206 | static inline uint8_t mavlink_msg_log_request_end_get_target_system(const mavlink_message_t* msg) 207 | { 208 | return _MAV_RETURN_uint8_t(msg, 0); 209 | } 210 | 211 | /** 212 | * @brief Get field target_component from log_request_end message 213 | * 214 | * @return Component ID 215 | */ 216 | static inline uint8_t mavlink_msg_log_request_end_get_target_component(const mavlink_message_t* msg) 217 | { 218 | return _MAV_RETURN_uint8_t(msg, 1); 219 | } 220 | 221 | /** 222 | * @brief Decode a log_request_end message into a struct 223 | * 224 | * @param msg The message to decode 225 | * @param log_request_end C-struct to decode the message contents into 226 | */ 227 | static inline void mavlink_msg_log_request_end_decode(const mavlink_message_t* msg, mavlink_log_request_end_t* log_request_end) 228 | { 229 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 230 | log_request_end->target_system = mavlink_msg_log_request_end_get_target_system(msg); 231 | log_request_end->target_component = mavlink_msg_log_request_end_get_target_component(msg); 232 | #else 233 | uint8_t len = msg->len < MAVLINK_MSG_ID_LOG_REQUEST_END_LEN? msg->len : MAVLINK_MSG_ID_LOG_REQUEST_END_LEN; 234 | memset(log_request_end, 0, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN); 235 | memcpy(log_request_end, _MAV_PAYLOAD(msg), len); 236 | #endif 237 | } 238 | -------------------------------------------------------------------------------- /libraries/mavlink/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_PACKED __mavlink_system_time_t 6 | { 7 | uint64_t time_unix_usec; /*< Timestamp of the master clock in microseconds since UNIX epoch.*/ 8 | uint32_t time_boot_ms; /*< Timestamp of the component clock since boot time in milliseconds.*/ 9 | } mavlink_system_time_t; 10 | 11 | #define MAVLINK_MSG_ID_SYSTEM_TIME_LEN 12 12 | #define MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN 12 13 | #define MAVLINK_MSG_ID_2_LEN 12 14 | #define MAVLINK_MSG_ID_2_MIN_LEN 12 15 | 16 | #define MAVLINK_MSG_ID_SYSTEM_TIME_CRC 137 17 | #define MAVLINK_MSG_ID_2_CRC 137 18 | 19 | 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_SYSTEM_TIME { \ 23 | 2, \ 24 | "SYSTEM_TIME", \ 25 | 2, \ 26 | { { "time_unix_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_system_time_t, time_unix_usec) }, \ 27 | { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_system_time_t, time_boot_ms) }, \ 28 | } \ 29 | } 30 | #else 31 | #define MAVLINK_MESSAGE_INFO_SYSTEM_TIME { \ 32 | "SYSTEM_TIME", \ 33 | 2, \ 34 | { { "time_unix_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_system_time_t, time_unix_usec) }, \ 35 | { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_system_time_t, time_boot_ms) }, \ 36 | } \ 37 | } 38 | #endif 39 | 40 | /** 41 | * @brief Pack a system_time message 42 | * @param system_id ID of this system 43 | * @param component_id ID of this component (e.g. 200 for IMU) 44 | * @param msg The MAVLink message to compress the data into 45 | * 46 | * @param time_unix_usec Timestamp of the master clock in microseconds since UNIX epoch. 47 | * @param time_boot_ms Timestamp of the component clock since boot time in milliseconds. 48 | * @return length of the message in bytes (excluding serial stream start sign) 49 | */ 50 | static inline uint16_t mavlink_msg_system_time_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 51 | uint64_t time_unix_usec, uint32_t time_boot_ms) 52 | { 53 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 54 | char buf[MAVLINK_MSG_ID_SYSTEM_TIME_LEN]; 55 | _mav_put_uint64_t(buf, 0, time_unix_usec); 56 | _mav_put_uint32_t(buf, 8, time_boot_ms); 57 | 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYSTEM_TIME_LEN); 59 | #else 60 | mavlink_system_time_t packet; 61 | packet.time_unix_usec = time_unix_usec; 62 | packet.time_boot_ms = time_boot_ms; 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYSTEM_TIME_LEN); 65 | #endif 66 | 67 | msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME; 68 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); 69 | } 70 | 71 | /** 72 | * @brief Pack a system_time message on a channel 73 | * @param system_id ID of this system 74 | * @param component_id ID of this component (e.g. 200 for IMU) 75 | * @param chan The MAVLink channel this message will be sent over 76 | * @param msg The MAVLink message to compress the data into 77 | * @param time_unix_usec Timestamp of the master clock in microseconds since UNIX epoch. 78 | * @param time_boot_ms Timestamp of the component clock since boot time in milliseconds. 79 | * @return length of the message in bytes (excluding serial stream start sign) 80 | */ 81 | static inline uint16_t mavlink_msg_system_time_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 82 | mavlink_message_t* msg, 83 | uint64_t time_unix_usec,uint32_t time_boot_ms) 84 | { 85 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 86 | char buf[MAVLINK_MSG_ID_SYSTEM_TIME_LEN]; 87 | _mav_put_uint64_t(buf, 0, time_unix_usec); 88 | _mav_put_uint32_t(buf, 8, time_boot_ms); 89 | 90 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYSTEM_TIME_LEN); 91 | #else 92 | mavlink_system_time_t packet; 93 | packet.time_unix_usec = time_unix_usec; 94 | packet.time_boot_ms = time_boot_ms; 95 | 96 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYSTEM_TIME_LEN); 97 | #endif 98 | 99 | msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME; 100 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); 101 | } 102 | 103 | /** 104 | * @brief Encode a system_time struct 105 | * 106 | * @param system_id ID of this system 107 | * @param component_id ID of this component (e.g. 200 for IMU) 108 | * @param msg The MAVLink message to compress the data into 109 | * @param system_time C-struct to read the message contents from 110 | */ 111 | 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) 112 | { 113 | return mavlink_msg_system_time_pack(system_id, component_id, msg, system_time->time_unix_usec, system_time->time_boot_ms); 114 | } 115 | 116 | /** 117 | * @brief Encode a system_time struct on a channel 118 | * 119 | * @param system_id ID of this system 120 | * @param component_id ID of this component (e.g. 200 for IMU) 121 | * @param chan The MAVLink channel this message will be sent over 122 | * @param msg The MAVLink message to compress the data into 123 | * @param system_time C-struct to read the message contents from 124 | */ 125 | static inline uint16_t mavlink_msg_system_time_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_system_time_t* system_time) 126 | { 127 | return mavlink_msg_system_time_pack_chan(system_id, component_id, chan, msg, system_time->time_unix_usec, system_time->time_boot_ms); 128 | } 129 | 130 | /** 131 | * @brief Send a system_time message 132 | * @param chan MAVLink channel to send the message 133 | * 134 | * @param time_unix_usec Timestamp of the master clock in microseconds since UNIX epoch. 135 | * @param time_boot_ms Timestamp of the component clock since boot time in milliseconds. 136 | */ 137 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 138 | 139 | static inline void mavlink_msg_system_time_send(mavlink_channel_t chan, uint64_t time_unix_usec, uint32_t time_boot_ms) 140 | { 141 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 142 | char buf[MAVLINK_MSG_ID_SYSTEM_TIME_LEN]; 143 | _mav_put_uint64_t(buf, 0, time_unix_usec); 144 | _mav_put_uint32_t(buf, 8, time_boot_ms); 145 | 146 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, buf, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); 147 | #else 148 | mavlink_system_time_t packet; 149 | packet.time_unix_usec = time_unix_usec; 150 | packet.time_boot_ms = time_boot_ms; 151 | 152 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)&packet, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); 153 | #endif 154 | } 155 | 156 | /** 157 | * @brief Send a system_time message 158 | * @param chan MAVLink channel to send the message 159 | * @param struct The MAVLink struct to serialize 160 | */ 161 | static inline void mavlink_msg_system_time_send_struct(mavlink_channel_t chan, const mavlink_system_time_t* system_time) 162 | { 163 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 164 | mavlink_msg_system_time_send(chan, system_time->time_unix_usec, system_time->time_boot_ms); 165 | #else 166 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)system_time, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); 167 | #endif 168 | } 169 | 170 | #if MAVLINK_MSG_ID_SYSTEM_TIME_LEN <= MAVLINK_MAX_PAYLOAD_LEN 171 | /* 172 | This varient of _send() can be used to save stack space by re-using 173 | memory from the receive buffer. The caller provides a 174 | mavlink_message_t which is the size of a full mavlink message. This 175 | is usually the receive buffer for the channel, and allows a reply to an 176 | incoming message with minimum stack space usage. 177 | */ 178 | static inline void mavlink_msg_system_time_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_unix_usec, uint32_t time_boot_ms) 179 | { 180 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 181 | char *buf = (char *)msgbuf; 182 | _mav_put_uint64_t(buf, 0, time_unix_usec); 183 | _mav_put_uint32_t(buf, 8, time_boot_ms); 184 | 185 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, buf, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); 186 | #else 187 | mavlink_system_time_t *packet = (mavlink_system_time_t *)msgbuf; 188 | packet->time_unix_usec = time_unix_usec; 189 | packet->time_boot_ms = time_boot_ms; 190 | 191 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)packet, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); 192 | #endif 193 | } 194 | #endif 195 | 196 | #endif 197 | 198 | // MESSAGE SYSTEM_TIME UNPACKING 199 | 200 | 201 | /** 202 | * @brief Get field time_unix_usec from system_time message 203 | * 204 | * @return Timestamp of the master clock in microseconds since UNIX epoch. 205 | */ 206 | static inline uint64_t mavlink_msg_system_time_get_time_unix_usec(const mavlink_message_t* msg) 207 | { 208 | return _MAV_RETURN_uint64_t(msg, 0); 209 | } 210 | 211 | /** 212 | * @brief Get field time_boot_ms from system_time message 213 | * 214 | * @return Timestamp of the component clock since boot time in milliseconds. 215 | */ 216 | static inline uint32_t mavlink_msg_system_time_get_time_boot_ms(const mavlink_message_t* msg) 217 | { 218 | return _MAV_RETURN_uint32_t(msg, 8); 219 | } 220 | 221 | /** 222 | * @brief Decode a system_time message into a struct 223 | * 224 | * @param msg The message to decode 225 | * @param system_time C-struct to decode the message contents into 226 | */ 227 | static inline void mavlink_msg_system_time_decode(const mavlink_message_t* msg, mavlink_system_time_t* system_time) 228 | { 229 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 230 | system_time->time_unix_usec = mavlink_msg_system_time_get_time_unix_usec(msg); 231 | system_time->time_boot_ms = mavlink_msg_system_time_get_time_boot_ms(msg); 232 | #else 233 | uint8_t len = msg->len < MAVLINK_MSG_ID_SYSTEM_TIME_LEN? msg->len : MAVLINK_MSG_ID_SYSTEM_TIME_LEN; 234 | memset(system_time, 0, MAVLINK_MSG_ID_SYSTEM_TIME_LEN); 235 | memcpy(system_time, _MAV_PAYLOAD(msg), len); 236 | #endif 237 | } 238 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_encapsulated_data.h: -------------------------------------------------------------------------------- 1 | // MESSAGE ENCAPSULATED_DATA PACKING 2 | 3 | #define MAVLINK_MSG_ID_ENCAPSULATED_DATA 131 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_encapsulated_data_t 6 | { 7 | uint16_t seqnr; /*< sequence number (starting with 0 on every transmission)*/ 8 | uint8_t data[253]; /*< image data bytes*/ 9 | } mavlink_encapsulated_data_t; 10 | 11 | #define MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN 255 12 | #define MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN 255 13 | #define MAVLINK_MSG_ID_131_LEN 255 14 | #define MAVLINK_MSG_ID_131_MIN_LEN 255 15 | 16 | #define MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC 223 17 | #define MAVLINK_MSG_ID_131_CRC 223 18 | 19 | #define MAVLINK_MSG_ENCAPSULATED_DATA_FIELD_DATA_LEN 253 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_ENCAPSULATED_DATA { \ 23 | 131, \ 24 | "ENCAPSULATED_DATA", \ 25 | 2, \ 26 | { { "seqnr", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_encapsulated_data_t, seqnr) }, \ 27 | { "data", NULL, MAVLINK_TYPE_UINT8_T, 253, 2, offsetof(mavlink_encapsulated_data_t, data) }, \ 28 | } \ 29 | } 30 | #else 31 | #define MAVLINK_MESSAGE_INFO_ENCAPSULATED_DATA { \ 32 | "ENCAPSULATED_DATA", \ 33 | 2, \ 34 | { { "seqnr", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_encapsulated_data_t, seqnr) }, \ 35 | { "data", NULL, MAVLINK_TYPE_UINT8_T, 253, 2, offsetof(mavlink_encapsulated_data_t, data) }, \ 36 | } \ 37 | } 38 | #endif 39 | 40 | /** 41 | * @brief Pack a encapsulated_data message 42 | * @param system_id ID of this system 43 | * @param component_id ID of this component (e.g. 200 for IMU) 44 | * @param msg The MAVLink message to compress the data into 45 | * 46 | * @param seqnr sequence number (starting with 0 on every transmission) 47 | * @param data image data bytes 48 | * @return length of the message in bytes (excluding serial stream start sign) 49 | */ 50 | static inline uint16_t mavlink_msg_encapsulated_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 51 | uint16_t seqnr, const uint8_t *data) 52 | { 53 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 54 | char buf[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN]; 55 | _mav_put_uint16_t(buf, 0, seqnr); 56 | _mav_put_uint8_t_array(buf, 2, data, 253); 57 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); 58 | #else 59 | mavlink_encapsulated_data_t packet; 60 | packet.seqnr = seqnr; 61 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*253); 62 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); 63 | #endif 64 | 65 | msg->msgid = MAVLINK_MSG_ID_ENCAPSULATED_DATA; 66 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); 67 | } 68 | 69 | /** 70 | * @brief Pack a encapsulated_data message on a channel 71 | * @param system_id ID of this system 72 | * @param component_id ID of this component (e.g. 200 for IMU) 73 | * @param chan The MAVLink channel this message will be sent over 74 | * @param msg The MAVLink message to compress the data into 75 | * @param seqnr sequence number (starting with 0 on every transmission) 76 | * @param data image data bytes 77 | * @return length of the message in bytes (excluding serial stream start sign) 78 | */ 79 | static inline uint16_t mavlink_msg_encapsulated_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 80 | mavlink_message_t* msg, 81 | uint16_t seqnr,const uint8_t *data) 82 | { 83 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 84 | char buf[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN]; 85 | _mav_put_uint16_t(buf, 0, seqnr); 86 | _mav_put_uint8_t_array(buf, 2, data, 253); 87 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); 88 | #else 89 | mavlink_encapsulated_data_t packet; 90 | packet.seqnr = seqnr; 91 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*253); 92 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); 93 | #endif 94 | 95 | msg->msgid = MAVLINK_MSG_ID_ENCAPSULATED_DATA; 96 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); 97 | } 98 | 99 | /** 100 | * @brief Encode a encapsulated_data struct 101 | * 102 | * @param system_id ID of this system 103 | * @param component_id ID of this component (e.g. 200 for IMU) 104 | * @param msg The MAVLink message to compress the data into 105 | * @param encapsulated_data C-struct to read the message contents from 106 | */ 107 | static inline uint16_t mavlink_msg_encapsulated_data_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_encapsulated_data_t* encapsulated_data) 108 | { 109 | return mavlink_msg_encapsulated_data_pack(system_id, component_id, msg, encapsulated_data->seqnr, encapsulated_data->data); 110 | } 111 | 112 | /** 113 | * @brief Encode a encapsulated_data struct on a channel 114 | * 115 | * @param system_id ID of this system 116 | * @param component_id ID of this component (e.g. 200 for IMU) 117 | * @param chan The MAVLink channel this message will be sent over 118 | * @param msg The MAVLink message to compress the data into 119 | * @param encapsulated_data C-struct to read the message contents from 120 | */ 121 | static inline uint16_t mavlink_msg_encapsulated_data_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_encapsulated_data_t* encapsulated_data) 122 | { 123 | return mavlink_msg_encapsulated_data_pack_chan(system_id, component_id, chan, msg, encapsulated_data->seqnr, encapsulated_data->data); 124 | } 125 | 126 | /** 127 | * @brief Send a encapsulated_data message 128 | * @param chan MAVLink channel to send the message 129 | * 130 | * @param seqnr sequence number (starting with 0 on every transmission) 131 | * @param data image data bytes 132 | */ 133 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 134 | 135 | static inline void mavlink_msg_encapsulated_data_send(mavlink_channel_t chan, uint16_t seqnr, const uint8_t *data) 136 | { 137 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 138 | char buf[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN]; 139 | _mav_put_uint16_t(buf, 0, seqnr); 140 | _mav_put_uint8_t_array(buf, 2, data, 253); 141 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); 142 | #else 143 | mavlink_encapsulated_data_t packet; 144 | packet.seqnr = seqnr; 145 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*253); 146 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, (const char *)&packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); 147 | #endif 148 | } 149 | 150 | /** 151 | * @brief Send a encapsulated_data message 152 | * @param chan MAVLink channel to send the message 153 | * @param struct The MAVLink struct to serialize 154 | */ 155 | static inline void mavlink_msg_encapsulated_data_send_struct(mavlink_channel_t chan, const mavlink_encapsulated_data_t* encapsulated_data) 156 | { 157 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 158 | mavlink_msg_encapsulated_data_send(chan, encapsulated_data->seqnr, encapsulated_data->data); 159 | #else 160 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, (const char *)encapsulated_data, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); 161 | #endif 162 | } 163 | 164 | #if MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN 165 | /* 166 | This varient of _send() can be used to save stack space by re-using 167 | memory from the receive buffer. The caller provides a 168 | mavlink_message_t which is the size of a full mavlink message. This 169 | is usually the receive buffer for the channel, and allows a reply to an 170 | incoming message with minimum stack space usage. 171 | */ 172 | static inline void mavlink_msg_encapsulated_data_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t seqnr, const uint8_t *data) 173 | { 174 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 175 | char *buf = (char *)msgbuf; 176 | _mav_put_uint16_t(buf, 0, seqnr); 177 | _mav_put_uint8_t_array(buf, 2, data, 253); 178 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); 179 | #else 180 | mavlink_encapsulated_data_t *packet = (mavlink_encapsulated_data_t *)msgbuf; 181 | packet->seqnr = seqnr; 182 | mav_array_memcpy(packet->data, data, sizeof(uint8_t)*253); 183 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, (const char *)packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); 184 | #endif 185 | } 186 | #endif 187 | 188 | #endif 189 | 190 | // MESSAGE ENCAPSULATED_DATA UNPACKING 191 | 192 | 193 | /** 194 | * @brief Get field seqnr from encapsulated_data message 195 | * 196 | * @return sequence number (starting with 0 on every transmission) 197 | */ 198 | static inline uint16_t mavlink_msg_encapsulated_data_get_seqnr(const mavlink_message_t* msg) 199 | { 200 | return _MAV_RETURN_uint16_t(msg, 0); 201 | } 202 | 203 | /** 204 | * @brief Get field data from encapsulated_data message 205 | * 206 | * @return image data bytes 207 | */ 208 | static inline uint16_t mavlink_msg_encapsulated_data_get_data(const mavlink_message_t* msg, uint8_t *data) 209 | { 210 | return _MAV_RETURN_uint8_t_array(msg, data, 253, 2); 211 | } 212 | 213 | /** 214 | * @brief Decode a encapsulated_data message into a struct 215 | * 216 | * @param msg The message to decode 217 | * @param encapsulated_data C-struct to decode the message contents into 218 | */ 219 | static inline void mavlink_msg_encapsulated_data_decode(const mavlink_message_t* msg, mavlink_encapsulated_data_t* encapsulated_data) 220 | { 221 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 222 | encapsulated_data->seqnr = mavlink_msg_encapsulated_data_get_seqnr(msg); 223 | mavlink_msg_encapsulated_data_get_data(msg, encapsulated_data->data); 224 | #else 225 | uint8_t len = msg->len < MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN? msg->len : MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN; 226 | memset(encapsulated_data, 0, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); 227 | memcpy(encapsulated_data, _MAV_PAYLOAD(msg), len); 228 | #endif 229 | } 230 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_mission_clear_all.h: -------------------------------------------------------------------------------- 1 | // MESSAGE MISSION_CLEAR_ALL PACKING 2 | 3 | #define MAVLINK_MSG_ID_MISSION_CLEAR_ALL 45 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_mission_clear_all_t 6 | { 7 | uint8_t target_system; /*< System ID*/ 8 | uint8_t target_component; /*< Component ID*/ 9 | } mavlink_mission_clear_all_t; 10 | 11 | #define MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN 2 12 | #define MAVLINK_MSG_ID_MISSION_CLEAR_ALL_MIN_LEN 2 13 | #define MAVLINK_MSG_ID_45_LEN 2 14 | #define MAVLINK_MSG_ID_45_MIN_LEN 2 15 | 16 | #define MAVLINK_MSG_ID_MISSION_CLEAR_ALL_CRC 232 17 | #define MAVLINK_MSG_ID_45_CRC 232 18 | 19 | 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_MISSION_CLEAR_ALL { \ 23 | 45, \ 24 | "MISSION_CLEAR_ALL", \ 25 | 2, \ 26 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_mission_clear_all_t, target_system) }, \ 27 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_mission_clear_all_t, target_component) }, \ 28 | } \ 29 | } 30 | #else 31 | #define MAVLINK_MESSAGE_INFO_MISSION_CLEAR_ALL { \ 32 | "MISSION_CLEAR_ALL", \ 33 | 2, \ 34 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_mission_clear_all_t, target_system) }, \ 35 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_mission_clear_all_t, target_component) }, \ 36 | } \ 37 | } 38 | #endif 39 | 40 | /** 41 | * @brief Pack a mission_clear_all message 42 | * @param system_id ID of this system 43 | * @param component_id ID of this component (e.g. 200 for IMU) 44 | * @param msg The MAVLink message to compress the data into 45 | * 46 | * @param target_system System ID 47 | * @param target_component Component ID 48 | * @return length of the message in bytes (excluding serial stream start sign) 49 | */ 50 | static inline uint16_t mavlink_msg_mission_clear_all_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 51 | uint8_t target_system, uint8_t target_component) 52 | { 53 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 54 | char buf[MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN]; 55 | _mav_put_uint8_t(buf, 0, target_system); 56 | _mav_put_uint8_t(buf, 1, target_component); 57 | 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN); 59 | #else 60 | mavlink_mission_clear_all_t packet; 61 | packet.target_system = target_system; 62 | packet.target_component = target_component; 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN); 65 | #endif 66 | 67 | msg->msgid = MAVLINK_MSG_ID_MISSION_CLEAR_ALL; 68 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_MIN_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_CRC); 69 | } 70 | 71 | /** 72 | * @brief Pack a mission_clear_all message on a channel 73 | * @param system_id ID of this system 74 | * @param component_id ID of this component (e.g. 200 for IMU) 75 | * @param chan The MAVLink channel this message will be sent over 76 | * @param msg The MAVLink message to compress the data into 77 | * @param target_system System ID 78 | * @param target_component Component ID 79 | * @return length of the message in bytes (excluding serial stream start sign) 80 | */ 81 | static inline uint16_t mavlink_msg_mission_clear_all_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 82 | mavlink_message_t* msg, 83 | uint8_t target_system,uint8_t target_component) 84 | { 85 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 86 | char buf[MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN]; 87 | _mav_put_uint8_t(buf, 0, target_system); 88 | _mav_put_uint8_t(buf, 1, target_component); 89 | 90 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN); 91 | #else 92 | mavlink_mission_clear_all_t packet; 93 | packet.target_system = target_system; 94 | packet.target_component = target_component; 95 | 96 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN); 97 | #endif 98 | 99 | msg->msgid = MAVLINK_MSG_ID_MISSION_CLEAR_ALL; 100 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_MIN_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_CRC); 101 | } 102 | 103 | /** 104 | * @brief Encode a mission_clear_all struct 105 | * 106 | * @param system_id ID of this system 107 | * @param component_id ID of this component (e.g. 200 for IMU) 108 | * @param msg The MAVLink message to compress the data into 109 | * @param mission_clear_all C-struct to read the message contents from 110 | */ 111 | static inline uint16_t mavlink_msg_mission_clear_all_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mission_clear_all_t* mission_clear_all) 112 | { 113 | return mavlink_msg_mission_clear_all_pack(system_id, component_id, msg, mission_clear_all->target_system, mission_clear_all->target_component); 114 | } 115 | 116 | /** 117 | * @brief Encode a mission_clear_all struct on a channel 118 | * 119 | * @param system_id ID of this system 120 | * @param component_id ID of this component (e.g. 200 for IMU) 121 | * @param chan The MAVLink channel this message will be sent over 122 | * @param msg The MAVLink message to compress the data into 123 | * @param mission_clear_all C-struct to read the message contents from 124 | */ 125 | static inline uint16_t mavlink_msg_mission_clear_all_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_mission_clear_all_t* mission_clear_all) 126 | { 127 | return mavlink_msg_mission_clear_all_pack_chan(system_id, component_id, chan, msg, mission_clear_all->target_system, mission_clear_all->target_component); 128 | } 129 | 130 | /** 131 | * @brief Send a mission_clear_all message 132 | * @param chan MAVLink channel to send the message 133 | * 134 | * @param target_system System ID 135 | * @param target_component Component ID 136 | */ 137 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 138 | 139 | static inline void mavlink_msg_mission_clear_all_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 140 | { 141 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 142 | char buf[MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN]; 143 | _mav_put_uint8_t(buf, 0, target_system); 144 | _mav_put_uint8_t(buf, 1, target_component); 145 | 146 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_CLEAR_ALL, buf, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_MIN_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_CRC); 147 | #else 148 | mavlink_mission_clear_all_t packet; 149 | packet.target_system = target_system; 150 | packet.target_component = target_component; 151 | 152 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_CLEAR_ALL, (const char *)&packet, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_MIN_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_CRC); 153 | #endif 154 | } 155 | 156 | /** 157 | * @brief Send a mission_clear_all message 158 | * @param chan MAVLink channel to send the message 159 | * @param struct The MAVLink struct to serialize 160 | */ 161 | static inline void mavlink_msg_mission_clear_all_send_struct(mavlink_channel_t chan, const mavlink_mission_clear_all_t* mission_clear_all) 162 | { 163 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 164 | mavlink_msg_mission_clear_all_send(chan, mission_clear_all->target_system, mission_clear_all->target_component); 165 | #else 166 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_CLEAR_ALL, (const char *)mission_clear_all, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_MIN_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_CRC); 167 | #endif 168 | } 169 | 170 | #if MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN <= MAVLINK_MAX_PAYLOAD_LEN 171 | /* 172 | This varient of _send() can be used to save stack space by re-using 173 | memory from the receive buffer. The caller provides a 174 | mavlink_message_t which is the size of a full mavlink message. This 175 | is usually the receive buffer for the channel, and allows a reply to an 176 | incoming message with minimum stack space usage. 177 | */ 178 | static inline void mavlink_msg_mission_clear_all_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 179 | { 180 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 181 | char *buf = (char *)msgbuf; 182 | _mav_put_uint8_t(buf, 0, target_system); 183 | _mav_put_uint8_t(buf, 1, target_component); 184 | 185 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_CLEAR_ALL, buf, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_MIN_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_CRC); 186 | #else 187 | mavlink_mission_clear_all_t *packet = (mavlink_mission_clear_all_t *)msgbuf; 188 | packet->target_system = target_system; 189 | packet->target_component = target_component; 190 | 191 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_CLEAR_ALL, (const char *)packet, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_MIN_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_CRC); 192 | #endif 193 | } 194 | #endif 195 | 196 | #endif 197 | 198 | // MESSAGE MISSION_CLEAR_ALL UNPACKING 199 | 200 | 201 | /** 202 | * @brief Get field target_system from mission_clear_all message 203 | * 204 | * @return System ID 205 | */ 206 | static inline uint8_t mavlink_msg_mission_clear_all_get_target_system(const mavlink_message_t* msg) 207 | { 208 | return _MAV_RETURN_uint8_t(msg, 0); 209 | } 210 | 211 | /** 212 | * @brief Get field target_component from mission_clear_all message 213 | * 214 | * @return Component ID 215 | */ 216 | static inline uint8_t mavlink_msg_mission_clear_all_get_target_component(const mavlink_message_t* msg) 217 | { 218 | return _MAV_RETURN_uint8_t(msg, 1); 219 | } 220 | 221 | /** 222 | * @brief Decode a mission_clear_all message into a struct 223 | * 224 | * @param msg The message to decode 225 | * @param mission_clear_all C-struct to decode the message contents into 226 | */ 227 | static inline void mavlink_msg_mission_clear_all_decode(const mavlink_message_t* msg, mavlink_mission_clear_all_t* mission_clear_all) 228 | { 229 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 230 | mission_clear_all->target_system = mavlink_msg_mission_clear_all_get_target_system(msg); 231 | mission_clear_all->target_component = mavlink_msg_mission_clear_all_get_target_component(msg); 232 | #else 233 | uint8_t len = msg->len < MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN? msg->len : MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN; 234 | memset(mission_clear_all, 0, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN); 235 | memcpy(mission_clear_all, _MAV_PAYLOAD(msg), len); 236 | #endif 237 | } 238 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_param_request_list.h: -------------------------------------------------------------------------------- 1 | // MESSAGE PARAM_REQUEST_LIST PACKING 2 | 3 | #define MAVLINK_MSG_ID_PARAM_REQUEST_LIST 21 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_param_request_list_t 6 | { 7 | uint8_t target_system; /*< System ID*/ 8 | uint8_t target_component; /*< Component ID*/ 9 | } mavlink_param_request_list_t; 10 | 11 | #define MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN 2 12 | #define MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN 2 13 | #define MAVLINK_MSG_ID_21_LEN 2 14 | #define MAVLINK_MSG_ID_21_MIN_LEN 2 15 | 16 | #define MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC 159 17 | #define MAVLINK_MSG_ID_21_CRC 159 18 | 19 | 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_PARAM_REQUEST_LIST { \ 23 | 21, \ 24 | "PARAM_REQUEST_LIST", \ 25 | 2, \ 26 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_param_request_list_t, target_system) }, \ 27 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_param_request_list_t, target_component) }, \ 28 | } \ 29 | } 30 | #else 31 | #define MAVLINK_MESSAGE_INFO_PARAM_REQUEST_LIST { \ 32 | "PARAM_REQUEST_LIST", \ 33 | 2, \ 34 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_param_request_list_t, target_system) }, \ 35 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_param_request_list_t, target_component) }, \ 36 | } \ 37 | } 38 | #endif 39 | 40 | /** 41 | * @brief Pack a param_request_list message 42 | * @param system_id ID of this system 43 | * @param component_id ID of this component (e.g. 200 for IMU) 44 | * @param msg The MAVLink message to compress the data into 45 | * 46 | * @param target_system System ID 47 | * @param target_component Component ID 48 | * @return length of the message in bytes (excluding serial stream start sign) 49 | */ 50 | static inline uint16_t mavlink_msg_param_request_list_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 51 | uint8_t target_system, uint8_t target_component) 52 | { 53 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 54 | char buf[MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN]; 55 | _mav_put_uint8_t(buf, 0, target_system); 56 | _mav_put_uint8_t(buf, 1, target_component); 57 | 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN); 59 | #else 60 | mavlink_param_request_list_t packet; 61 | packet.target_system = target_system; 62 | packet.target_component = target_component; 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN); 65 | #endif 66 | 67 | msg->msgid = MAVLINK_MSG_ID_PARAM_REQUEST_LIST; 68 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); 69 | } 70 | 71 | /** 72 | * @brief Pack a param_request_list message on a channel 73 | * @param system_id ID of this system 74 | * @param component_id ID of this component (e.g. 200 for IMU) 75 | * @param chan The MAVLink channel this message will be sent over 76 | * @param msg The MAVLink message to compress the data into 77 | * @param target_system System ID 78 | * @param target_component Component ID 79 | * @return length of the message in bytes (excluding serial stream start sign) 80 | */ 81 | static inline uint16_t mavlink_msg_param_request_list_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 82 | mavlink_message_t* msg, 83 | uint8_t target_system,uint8_t target_component) 84 | { 85 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 86 | char buf[MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN]; 87 | _mav_put_uint8_t(buf, 0, target_system); 88 | _mav_put_uint8_t(buf, 1, target_component); 89 | 90 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN); 91 | #else 92 | mavlink_param_request_list_t packet; 93 | packet.target_system = target_system; 94 | packet.target_component = target_component; 95 | 96 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN); 97 | #endif 98 | 99 | msg->msgid = MAVLINK_MSG_ID_PARAM_REQUEST_LIST; 100 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); 101 | } 102 | 103 | /** 104 | * @brief Encode a param_request_list struct 105 | * 106 | * @param system_id ID of this system 107 | * @param component_id ID of this component (e.g. 200 for IMU) 108 | * @param msg The MAVLink message to compress the data into 109 | * @param param_request_list C-struct to read the message contents from 110 | */ 111 | static inline uint16_t mavlink_msg_param_request_list_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_param_request_list_t* param_request_list) 112 | { 113 | return mavlink_msg_param_request_list_pack(system_id, component_id, msg, param_request_list->target_system, param_request_list->target_component); 114 | } 115 | 116 | /** 117 | * @brief Encode a param_request_list struct on a channel 118 | * 119 | * @param system_id ID of this system 120 | * @param component_id ID of this component (e.g. 200 for IMU) 121 | * @param chan The MAVLink channel this message will be sent over 122 | * @param msg The MAVLink message to compress the data into 123 | * @param param_request_list C-struct to read the message contents from 124 | */ 125 | static inline uint16_t mavlink_msg_param_request_list_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_param_request_list_t* param_request_list) 126 | { 127 | return mavlink_msg_param_request_list_pack_chan(system_id, component_id, chan, msg, param_request_list->target_system, param_request_list->target_component); 128 | } 129 | 130 | /** 131 | * @brief Send a param_request_list message 132 | * @param chan MAVLink channel to send the message 133 | * 134 | * @param target_system System ID 135 | * @param target_component Component ID 136 | */ 137 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 138 | 139 | static inline void mavlink_msg_param_request_list_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 140 | { 141 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 142 | char buf[MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN]; 143 | _mav_put_uint8_t(buf, 0, target_system); 144 | _mav_put_uint8_t(buf, 1, target_component); 145 | 146 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_LIST, buf, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); 147 | #else 148 | mavlink_param_request_list_t packet; 149 | packet.target_system = target_system; 150 | packet.target_component = target_component; 151 | 152 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_LIST, (const char *)&packet, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); 153 | #endif 154 | } 155 | 156 | /** 157 | * @brief Send a param_request_list message 158 | * @param chan MAVLink channel to send the message 159 | * @param struct The MAVLink struct to serialize 160 | */ 161 | static inline void mavlink_msg_param_request_list_send_struct(mavlink_channel_t chan, const mavlink_param_request_list_t* param_request_list) 162 | { 163 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 164 | mavlink_msg_param_request_list_send(chan, param_request_list->target_system, param_request_list->target_component); 165 | #else 166 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_LIST, (const char *)param_request_list, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); 167 | #endif 168 | } 169 | 170 | #if MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN <= MAVLINK_MAX_PAYLOAD_LEN 171 | /* 172 | This varient of _send() can be used to save stack space by re-using 173 | memory from the receive buffer. The caller provides a 174 | mavlink_message_t which is the size of a full mavlink message. This 175 | is usually the receive buffer for the channel, and allows a reply to an 176 | incoming message with minimum stack space usage. 177 | */ 178 | static inline void mavlink_msg_param_request_list_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 179 | { 180 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 181 | char *buf = (char *)msgbuf; 182 | _mav_put_uint8_t(buf, 0, target_system); 183 | _mav_put_uint8_t(buf, 1, target_component); 184 | 185 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_LIST, buf, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); 186 | #else 187 | mavlink_param_request_list_t *packet = (mavlink_param_request_list_t *)msgbuf; 188 | packet->target_system = target_system; 189 | packet->target_component = target_component; 190 | 191 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_LIST, (const char *)packet, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); 192 | #endif 193 | } 194 | #endif 195 | 196 | #endif 197 | 198 | // MESSAGE PARAM_REQUEST_LIST UNPACKING 199 | 200 | 201 | /** 202 | * @brief Get field target_system from param_request_list message 203 | * 204 | * @return System ID 205 | */ 206 | static inline uint8_t mavlink_msg_param_request_list_get_target_system(const mavlink_message_t* msg) 207 | { 208 | return _MAV_RETURN_uint8_t(msg, 0); 209 | } 210 | 211 | /** 212 | * @brief Get field target_component from param_request_list message 213 | * 214 | * @return Component ID 215 | */ 216 | static inline uint8_t mavlink_msg_param_request_list_get_target_component(const mavlink_message_t* msg) 217 | { 218 | return _MAV_RETURN_uint8_t(msg, 1); 219 | } 220 | 221 | /** 222 | * @brief Decode a param_request_list message into a struct 223 | * 224 | * @param msg The message to decode 225 | * @param param_request_list C-struct to decode the message contents into 226 | */ 227 | static inline void mavlink_msg_param_request_list_decode(const mavlink_message_t* msg, mavlink_param_request_list_t* param_request_list) 228 | { 229 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 230 | param_request_list->target_system = mavlink_msg_param_request_list_get_target_system(msg); 231 | param_request_list->target_component = mavlink_msg_param_request_list_get_target_component(msg); 232 | #else 233 | uint8_t len = msg->len < MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN? msg->len : MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN; 234 | memset(param_request_list, 0, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN); 235 | memcpy(param_request_list, _MAV_PAYLOAD(msg), len); 236 | #endif 237 | } 238 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_mission_request_list.h: -------------------------------------------------------------------------------- 1 | // MESSAGE MISSION_REQUEST_LIST PACKING 2 | 3 | #define MAVLINK_MSG_ID_MISSION_REQUEST_LIST 43 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_mission_request_list_t 6 | { 7 | uint8_t target_system; /*< System ID*/ 8 | uint8_t target_component; /*< Component ID*/ 9 | } mavlink_mission_request_list_t; 10 | 11 | #define MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN 2 12 | #define MAVLINK_MSG_ID_MISSION_REQUEST_LIST_MIN_LEN 2 13 | #define MAVLINK_MSG_ID_43_LEN 2 14 | #define MAVLINK_MSG_ID_43_MIN_LEN 2 15 | 16 | #define MAVLINK_MSG_ID_MISSION_REQUEST_LIST_CRC 132 17 | #define MAVLINK_MSG_ID_43_CRC 132 18 | 19 | 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_MISSION_REQUEST_LIST { \ 23 | 43, \ 24 | "MISSION_REQUEST_LIST", \ 25 | 2, \ 26 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_mission_request_list_t, target_system) }, \ 27 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_mission_request_list_t, target_component) }, \ 28 | } \ 29 | } 30 | #else 31 | #define MAVLINK_MESSAGE_INFO_MISSION_REQUEST_LIST { \ 32 | "MISSION_REQUEST_LIST", \ 33 | 2, \ 34 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_mission_request_list_t, target_system) }, \ 35 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_mission_request_list_t, target_component) }, \ 36 | } \ 37 | } 38 | #endif 39 | 40 | /** 41 | * @brief Pack a mission_request_list message 42 | * @param system_id ID of this system 43 | * @param component_id ID of this component (e.g. 200 for IMU) 44 | * @param msg The MAVLink message to compress the data into 45 | * 46 | * @param target_system System ID 47 | * @param target_component Component ID 48 | * @return length of the message in bytes (excluding serial stream start sign) 49 | */ 50 | static inline uint16_t mavlink_msg_mission_request_list_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 51 | uint8_t target_system, uint8_t target_component) 52 | { 53 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 54 | char buf[MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN]; 55 | _mav_put_uint8_t(buf, 0, target_system); 56 | _mav_put_uint8_t(buf, 1, target_component); 57 | 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN); 59 | #else 60 | mavlink_mission_request_list_t packet; 61 | packet.target_system = target_system; 62 | packet.target_component = target_component; 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN); 65 | #endif 66 | 67 | msg->msgid = MAVLINK_MSG_ID_MISSION_REQUEST_LIST; 68 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_CRC); 69 | } 70 | 71 | /** 72 | * @brief Pack a mission_request_list message on a channel 73 | * @param system_id ID of this system 74 | * @param component_id ID of this component (e.g. 200 for IMU) 75 | * @param chan The MAVLink channel this message will be sent over 76 | * @param msg The MAVLink message to compress the data into 77 | * @param target_system System ID 78 | * @param target_component Component ID 79 | * @return length of the message in bytes (excluding serial stream start sign) 80 | */ 81 | static inline uint16_t mavlink_msg_mission_request_list_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 82 | mavlink_message_t* msg, 83 | uint8_t target_system,uint8_t target_component) 84 | { 85 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 86 | char buf[MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN]; 87 | _mav_put_uint8_t(buf, 0, target_system); 88 | _mav_put_uint8_t(buf, 1, target_component); 89 | 90 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN); 91 | #else 92 | mavlink_mission_request_list_t packet; 93 | packet.target_system = target_system; 94 | packet.target_component = target_component; 95 | 96 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN); 97 | #endif 98 | 99 | msg->msgid = MAVLINK_MSG_ID_MISSION_REQUEST_LIST; 100 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_CRC); 101 | } 102 | 103 | /** 104 | * @brief Encode a mission_request_list struct 105 | * 106 | * @param system_id ID of this system 107 | * @param component_id ID of this component (e.g. 200 for IMU) 108 | * @param msg The MAVLink message to compress the data into 109 | * @param mission_request_list C-struct to read the message contents from 110 | */ 111 | static inline uint16_t mavlink_msg_mission_request_list_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mission_request_list_t* mission_request_list) 112 | { 113 | return mavlink_msg_mission_request_list_pack(system_id, component_id, msg, mission_request_list->target_system, mission_request_list->target_component); 114 | } 115 | 116 | /** 117 | * @brief Encode a mission_request_list struct on a channel 118 | * 119 | * @param system_id ID of this system 120 | * @param component_id ID of this component (e.g. 200 for IMU) 121 | * @param chan The MAVLink channel this message will be sent over 122 | * @param msg The MAVLink message to compress the data into 123 | * @param mission_request_list C-struct to read the message contents from 124 | */ 125 | static inline uint16_t mavlink_msg_mission_request_list_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_mission_request_list_t* mission_request_list) 126 | { 127 | return mavlink_msg_mission_request_list_pack_chan(system_id, component_id, chan, msg, mission_request_list->target_system, mission_request_list->target_component); 128 | } 129 | 130 | /** 131 | * @brief Send a mission_request_list message 132 | * @param chan MAVLink channel to send the message 133 | * 134 | * @param target_system System ID 135 | * @param target_component Component ID 136 | */ 137 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 138 | 139 | static inline void mavlink_msg_mission_request_list_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 140 | { 141 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 142 | char buf[MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN]; 143 | _mav_put_uint8_t(buf, 0, target_system); 144 | _mav_put_uint8_t(buf, 1, target_component); 145 | 146 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_REQUEST_LIST, buf, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_CRC); 147 | #else 148 | mavlink_mission_request_list_t packet; 149 | packet.target_system = target_system; 150 | packet.target_component = target_component; 151 | 152 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_REQUEST_LIST, (const char *)&packet, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_CRC); 153 | #endif 154 | } 155 | 156 | /** 157 | * @brief Send a mission_request_list message 158 | * @param chan MAVLink channel to send the message 159 | * @param struct The MAVLink struct to serialize 160 | */ 161 | static inline void mavlink_msg_mission_request_list_send_struct(mavlink_channel_t chan, const mavlink_mission_request_list_t* mission_request_list) 162 | { 163 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 164 | mavlink_msg_mission_request_list_send(chan, mission_request_list->target_system, mission_request_list->target_component); 165 | #else 166 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_REQUEST_LIST, (const char *)mission_request_list, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_CRC); 167 | #endif 168 | } 169 | 170 | #if MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN <= MAVLINK_MAX_PAYLOAD_LEN 171 | /* 172 | This varient of _send() can be used to save stack space by re-using 173 | memory from the receive buffer. The caller provides a 174 | mavlink_message_t which is the size of a full mavlink message. This 175 | is usually the receive buffer for the channel, and allows a reply to an 176 | incoming message with minimum stack space usage. 177 | */ 178 | static inline void mavlink_msg_mission_request_list_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 179 | { 180 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 181 | char *buf = (char *)msgbuf; 182 | _mav_put_uint8_t(buf, 0, target_system); 183 | _mav_put_uint8_t(buf, 1, target_component); 184 | 185 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_REQUEST_LIST, buf, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_CRC); 186 | #else 187 | mavlink_mission_request_list_t *packet = (mavlink_mission_request_list_t *)msgbuf; 188 | packet->target_system = target_system; 189 | packet->target_component = target_component; 190 | 191 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_REQUEST_LIST, (const char *)packet, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_CRC); 192 | #endif 193 | } 194 | #endif 195 | 196 | #endif 197 | 198 | // MESSAGE MISSION_REQUEST_LIST UNPACKING 199 | 200 | 201 | /** 202 | * @brief Get field target_system from mission_request_list message 203 | * 204 | * @return System ID 205 | */ 206 | static inline uint8_t mavlink_msg_mission_request_list_get_target_system(const mavlink_message_t* msg) 207 | { 208 | return _MAV_RETURN_uint8_t(msg, 0); 209 | } 210 | 211 | /** 212 | * @brief Get field target_component from mission_request_list message 213 | * 214 | * @return Component ID 215 | */ 216 | static inline uint8_t mavlink_msg_mission_request_list_get_target_component(const mavlink_message_t* msg) 217 | { 218 | return _MAV_RETURN_uint8_t(msg, 1); 219 | } 220 | 221 | /** 222 | * @brief Decode a mission_request_list message into a struct 223 | * 224 | * @param msg The message to decode 225 | * @param mission_request_list C-struct to decode the message contents into 226 | */ 227 | static inline void mavlink_msg_mission_request_list_decode(const mavlink_message_t* msg, mavlink_mission_request_list_t* mission_request_list) 228 | { 229 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 230 | mission_request_list->target_system = mavlink_msg_mission_request_list_get_target_system(msg); 231 | mission_request_list->target_component = mavlink_msg_mission_request_list_get_target_component(msg); 232 | #else 233 | uint8_t len = msg->len < MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN? msg->len : MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN; 234 | memset(mission_request_list, 0, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN); 235 | memcpy(mission_request_list, _MAV_PAYLOAD(msg), len); 236 | #endif 237 | } 238 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_power_status.h: -------------------------------------------------------------------------------- 1 | // MESSAGE POWER_STATUS PACKING 2 | 3 | #define MAVLINK_MSG_ID_POWER_STATUS 125 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_power_status_t 6 | { 7 | uint16_t Vcc; /*< 5V rail voltage in millivolts*/ 8 | uint16_t Vservo; /*< servo rail voltage in millivolts*/ 9 | uint16_t flags; /*< power supply status flags (see MAV_POWER_STATUS enum)*/ 10 | } mavlink_power_status_t; 11 | 12 | #define MAVLINK_MSG_ID_POWER_STATUS_LEN 6 13 | #define MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN 6 14 | #define MAVLINK_MSG_ID_125_LEN 6 15 | #define MAVLINK_MSG_ID_125_MIN_LEN 6 16 | 17 | #define MAVLINK_MSG_ID_POWER_STATUS_CRC 203 18 | #define MAVLINK_MSG_ID_125_CRC 203 19 | 20 | 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_POWER_STATUS { \ 24 | 125, \ 25 | "POWER_STATUS", \ 26 | 3, \ 27 | { { "Vcc", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_power_status_t, Vcc) }, \ 28 | { "Vservo", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_power_status_t, Vservo) }, \ 29 | { "flags", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_power_status_t, flags) }, \ 30 | } \ 31 | } 32 | #else 33 | #define MAVLINK_MESSAGE_INFO_POWER_STATUS { \ 34 | "POWER_STATUS", \ 35 | 3, \ 36 | { { "Vcc", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_power_status_t, Vcc) }, \ 37 | { "Vservo", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_power_status_t, Vservo) }, \ 38 | { "flags", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_power_status_t, flags) }, \ 39 | } \ 40 | } 41 | #endif 42 | 43 | /** 44 | * @brief Pack a power_status message 45 | * @param system_id ID of this system 46 | * @param component_id ID of this component (e.g. 200 for IMU) 47 | * @param msg The MAVLink message to compress the data into 48 | * 49 | * @param Vcc 5V rail voltage in millivolts 50 | * @param Vservo servo rail voltage in millivolts 51 | * @param flags power supply status flags (see MAV_POWER_STATUS enum) 52 | * @return length of the message in bytes (excluding serial stream start sign) 53 | */ 54 | static inline uint16_t mavlink_msg_power_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 55 | uint16_t Vcc, uint16_t Vservo, uint16_t flags) 56 | { 57 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 58 | char buf[MAVLINK_MSG_ID_POWER_STATUS_LEN]; 59 | _mav_put_uint16_t(buf, 0, Vcc); 60 | _mav_put_uint16_t(buf, 2, Vservo); 61 | _mav_put_uint16_t(buf, 4, flags); 62 | 63 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_POWER_STATUS_LEN); 64 | #else 65 | mavlink_power_status_t packet; 66 | packet.Vcc = Vcc; 67 | packet.Vservo = Vservo; 68 | packet.flags = flags; 69 | 70 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_POWER_STATUS_LEN); 71 | #endif 72 | 73 | msg->msgid = MAVLINK_MSG_ID_POWER_STATUS; 74 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); 75 | } 76 | 77 | /** 78 | * @brief Pack a power_status message on a channel 79 | * @param system_id ID of this system 80 | * @param component_id ID of this component (e.g. 200 for IMU) 81 | * @param chan The MAVLink channel this message will be sent over 82 | * @param msg The MAVLink message to compress the data into 83 | * @param Vcc 5V rail voltage in millivolts 84 | * @param Vservo servo rail voltage in millivolts 85 | * @param flags power supply status flags (see MAV_POWER_STATUS enum) 86 | * @return length of the message in bytes (excluding serial stream start sign) 87 | */ 88 | static inline uint16_t mavlink_msg_power_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 89 | mavlink_message_t* msg, 90 | uint16_t Vcc,uint16_t Vservo,uint16_t flags) 91 | { 92 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 93 | char buf[MAVLINK_MSG_ID_POWER_STATUS_LEN]; 94 | _mav_put_uint16_t(buf, 0, Vcc); 95 | _mav_put_uint16_t(buf, 2, Vservo); 96 | _mav_put_uint16_t(buf, 4, flags); 97 | 98 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_POWER_STATUS_LEN); 99 | #else 100 | mavlink_power_status_t packet; 101 | packet.Vcc = Vcc; 102 | packet.Vservo = Vservo; 103 | packet.flags = flags; 104 | 105 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_POWER_STATUS_LEN); 106 | #endif 107 | 108 | msg->msgid = MAVLINK_MSG_ID_POWER_STATUS; 109 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); 110 | } 111 | 112 | /** 113 | * @brief Encode a power_status struct 114 | * 115 | * @param system_id ID of this system 116 | * @param component_id ID of this component (e.g. 200 for IMU) 117 | * @param msg The MAVLink message to compress the data into 118 | * @param power_status C-struct to read the message contents from 119 | */ 120 | static inline uint16_t mavlink_msg_power_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_power_status_t* power_status) 121 | { 122 | return mavlink_msg_power_status_pack(system_id, component_id, msg, power_status->Vcc, power_status->Vservo, power_status->flags); 123 | } 124 | 125 | /** 126 | * @brief Encode a power_status struct on a channel 127 | * 128 | * @param system_id ID of this system 129 | * @param component_id ID of this component (e.g. 200 for IMU) 130 | * @param chan The MAVLink channel this message will be sent over 131 | * @param msg The MAVLink message to compress the data into 132 | * @param power_status C-struct to read the message contents from 133 | */ 134 | static inline uint16_t mavlink_msg_power_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_power_status_t* power_status) 135 | { 136 | return mavlink_msg_power_status_pack_chan(system_id, component_id, chan, msg, power_status->Vcc, power_status->Vservo, power_status->flags); 137 | } 138 | 139 | /** 140 | * @brief Send a power_status message 141 | * @param chan MAVLink channel to send the message 142 | * 143 | * @param Vcc 5V rail voltage in millivolts 144 | * @param Vservo servo rail voltage in millivolts 145 | * @param flags power supply status flags (see MAV_POWER_STATUS enum) 146 | */ 147 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 148 | 149 | static inline void mavlink_msg_power_status_send(mavlink_channel_t chan, uint16_t Vcc, uint16_t Vservo, uint16_t flags) 150 | { 151 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 152 | char buf[MAVLINK_MSG_ID_POWER_STATUS_LEN]; 153 | _mav_put_uint16_t(buf, 0, Vcc); 154 | _mav_put_uint16_t(buf, 2, Vservo); 155 | _mav_put_uint16_t(buf, 4, flags); 156 | 157 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_POWER_STATUS, buf, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); 158 | #else 159 | mavlink_power_status_t packet; 160 | packet.Vcc = Vcc; 161 | packet.Vservo = Vservo; 162 | packet.flags = flags; 163 | 164 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_POWER_STATUS, (const char *)&packet, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); 165 | #endif 166 | } 167 | 168 | /** 169 | * @brief Send a power_status message 170 | * @param chan MAVLink channel to send the message 171 | * @param struct The MAVLink struct to serialize 172 | */ 173 | static inline void mavlink_msg_power_status_send_struct(mavlink_channel_t chan, const mavlink_power_status_t* power_status) 174 | { 175 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 176 | mavlink_msg_power_status_send(chan, power_status->Vcc, power_status->Vservo, power_status->flags); 177 | #else 178 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_POWER_STATUS, (const char *)power_status, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); 179 | #endif 180 | } 181 | 182 | #if MAVLINK_MSG_ID_POWER_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN 183 | /* 184 | This varient of _send() can be used to save stack space by re-using 185 | memory from the receive buffer. The caller provides a 186 | mavlink_message_t which is the size of a full mavlink message. This 187 | is usually the receive buffer for the channel, and allows a reply to an 188 | incoming message with minimum stack space usage. 189 | */ 190 | static inline void mavlink_msg_power_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t Vcc, uint16_t Vservo, uint16_t flags) 191 | { 192 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 193 | char *buf = (char *)msgbuf; 194 | _mav_put_uint16_t(buf, 0, Vcc); 195 | _mav_put_uint16_t(buf, 2, Vservo); 196 | _mav_put_uint16_t(buf, 4, flags); 197 | 198 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_POWER_STATUS, buf, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); 199 | #else 200 | mavlink_power_status_t *packet = (mavlink_power_status_t *)msgbuf; 201 | packet->Vcc = Vcc; 202 | packet->Vservo = Vservo; 203 | packet->flags = flags; 204 | 205 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_POWER_STATUS, (const char *)packet, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); 206 | #endif 207 | } 208 | #endif 209 | 210 | #endif 211 | 212 | // MESSAGE POWER_STATUS UNPACKING 213 | 214 | 215 | /** 216 | * @brief Get field Vcc from power_status message 217 | * 218 | * @return 5V rail voltage in millivolts 219 | */ 220 | static inline uint16_t mavlink_msg_power_status_get_Vcc(const mavlink_message_t* msg) 221 | { 222 | return _MAV_RETURN_uint16_t(msg, 0); 223 | } 224 | 225 | /** 226 | * @brief Get field Vservo from power_status message 227 | * 228 | * @return servo rail voltage in millivolts 229 | */ 230 | static inline uint16_t mavlink_msg_power_status_get_Vservo(const mavlink_message_t* msg) 231 | { 232 | return _MAV_RETURN_uint16_t(msg, 2); 233 | } 234 | 235 | /** 236 | * @brief Get field flags from power_status message 237 | * 238 | * @return power supply status flags (see MAV_POWER_STATUS enum) 239 | */ 240 | static inline uint16_t mavlink_msg_power_status_get_flags(const mavlink_message_t* msg) 241 | { 242 | return _MAV_RETURN_uint16_t(msg, 4); 243 | } 244 | 245 | /** 246 | * @brief Decode a power_status message into a struct 247 | * 248 | * @param msg The message to decode 249 | * @param power_status C-struct to decode the message contents into 250 | */ 251 | static inline void mavlink_msg_power_status_decode(const mavlink_message_t* msg, mavlink_power_status_t* power_status) 252 | { 253 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 254 | power_status->Vcc = mavlink_msg_power_status_get_Vcc(msg); 255 | power_status->Vservo = mavlink_msg_power_status_get_Vservo(msg); 256 | power_status->flags = mavlink_msg_power_status_get_flags(msg); 257 | #else 258 | uint8_t len = msg->len < MAVLINK_MSG_ID_POWER_STATUS_LEN? msg->len : MAVLINK_MSG_ID_POWER_STATUS_LEN; 259 | memset(power_status, 0, MAVLINK_MSG_ID_POWER_STATUS_LEN); 260 | memcpy(power_status, _MAV_PAYLOAD(msg), len); 261 | #endif 262 | } 263 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_gps_rtcm_data.h: -------------------------------------------------------------------------------- 1 | // MESSAGE GPS_RTCM_DATA PACKING 2 | 3 | #define MAVLINK_MSG_ID_GPS_RTCM_DATA 233 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_gps_rtcm_data_t 6 | { 7 | uint8_t flags; /*< LSB: 1 means message is fragmented*/ 8 | uint8_t len; /*< data length*/ 9 | uint8_t data[180]; /*< RTCM message (may be fragmented)*/ 10 | } mavlink_gps_rtcm_data_t; 11 | 12 | #define MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN 182 13 | #define MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN 182 14 | #define MAVLINK_MSG_ID_233_LEN 182 15 | #define MAVLINK_MSG_ID_233_MIN_LEN 182 16 | 17 | #define MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC 35 18 | #define MAVLINK_MSG_ID_233_CRC 35 19 | 20 | #define MAVLINK_MSG_GPS_RTCM_DATA_FIELD_DATA_LEN 180 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_GPS_RTCM_DATA { \ 24 | 233, \ 25 | "GPS_RTCM_DATA", \ 26 | 3, \ 27 | { { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_gps_rtcm_data_t, flags) }, \ 28 | { "len", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_gps_rtcm_data_t, len) }, \ 29 | { "data", NULL, MAVLINK_TYPE_UINT8_T, 180, 2, offsetof(mavlink_gps_rtcm_data_t, data) }, \ 30 | } \ 31 | } 32 | #else 33 | #define MAVLINK_MESSAGE_INFO_GPS_RTCM_DATA { \ 34 | "GPS_RTCM_DATA", \ 35 | 3, \ 36 | { { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_gps_rtcm_data_t, flags) }, \ 37 | { "len", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_gps_rtcm_data_t, len) }, \ 38 | { "data", NULL, MAVLINK_TYPE_UINT8_T, 180, 2, offsetof(mavlink_gps_rtcm_data_t, data) }, \ 39 | } \ 40 | } 41 | #endif 42 | 43 | /** 44 | * @brief Pack a gps_rtcm_data message 45 | * @param system_id ID of this system 46 | * @param component_id ID of this component (e.g. 200 for IMU) 47 | * @param msg The MAVLink message to compress the data into 48 | * 49 | * @param flags LSB: 1 means message is fragmented 50 | * @param len data length 51 | * @param data RTCM message (may be fragmented) 52 | * @return length of the message in bytes (excluding serial stream start sign) 53 | */ 54 | static inline uint16_t mavlink_msg_gps_rtcm_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 55 | uint8_t flags, uint8_t len, const uint8_t *data) 56 | { 57 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 58 | char buf[MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN]; 59 | _mav_put_uint8_t(buf, 0, flags); 60 | _mav_put_uint8_t(buf, 1, len); 61 | _mav_put_uint8_t_array(buf, 2, data, 180); 62 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN); 63 | #else 64 | mavlink_gps_rtcm_data_t packet; 65 | packet.flags = flags; 66 | packet.len = len; 67 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*180); 68 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN); 69 | #endif 70 | 71 | msg->msgid = MAVLINK_MSG_ID_GPS_RTCM_DATA; 72 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC); 73 | } 74 | 75 | /** 76 | * @brief Pack a gps_rtcm_data message on a channel 77 | * @param system_id ID of this system 78 | * @param component_id ID of this component (e.g. 200 for IMU) 79 | * @param chan The MAVLink channel this message will be sent over 80 | * @param msg The MAVLink message to compress the data into 81 | * @param flags LSB: 1 means message is fragmented 82 | * @param len data length 83 | * @param data RTCM message (may be fragmented) 84 | * @return length of the message in bytes (excluding serial stream start sign) 85 | */ 86 | static inline uint16_t mavlink_msg_gps_rtcm_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 87 | mavlink_message_t* msg, 88 | uint8_t flags,uint8_t len,const uint8_t *data) 89 | { 90 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 91 | char buf[MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN]; 92 | _mav_put_uint8_t(buf, 0, flags); 93 | _mav_put_uint8_t(buf, 1, len); 94 | _mav_put_uint8_t_array(buf, 2, data, 180); 95 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN); 96 | #else 97 | mavlink_gps_rtcm_data_t packet; 98 | packet.flags = flags; 99 | packet.len = len; 100 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*180); 101 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN); 102 | #endif 103 | 104 | msg->msgid = MAVLINK_MSG_ID_GPS_RTCM_DATA; 105 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC); 106 | } 107 | 108 | /** 109 | * @brief Encode a gps_rtcm_data struct 110 | * 111 | * @param system_id ID of this system 112 | * @param component_id ID of this component (e.g. 200 for IMU) 113 | * @param msg The MAVLink message to compress the data into 114 | * @param gps_rtcm_data C-struct to read the message contents from 115 | */ 116 | static inline uint16_t mavlink_msg_gps_rtcm_data_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_gps_rtcm_data_t* gps_rtcm_data) 117 | { 118 | return mavlink_msg_gps_rtcm_data_pack(system_id, component_id, msg, gps_rtcm_data->flags, gps_rtcm_data->len, gps_rtcm_data->data); 119 | } 120 | 121 | /** 122 | * @brief Encode a gps_rtcm_data struct on a channel 123 | * 124 | * @param system_id ID of this system 125 | * @param component_id ID of this component (e.g. 200 for IMU) 126 | * @param chan The MAVLink channel this message will be sent over 127 | * @param msg The MAVLink message to compress the data into 128 | * @param gps_rtcm_data C-struct to read the message contents from 129 | */ 130 | static inline uint16_t mavlink_msg_gps_rtcm_data_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_gps_rtcm_data_t* gps_rtcm_data) 131 | { 132 | return mavlink_msg_gps_rtcm_data_pack_chan(system_id, component_id, chan, msg, gps_rtcm_data->flags, gps_rtcm_data->len, gps_rtcm_data->data); 133 | } 134 | 135 | /** 136 | * @brief Send a gps_rtcm_data message 137 | * @param chan MAVLink channel to send the message 138 | * 139 | * @param flags LSB: 1 means message is fragmented 140 | * @param len data length 141 | * @param data RTCM message (may be fragmented) 142 | */ 143 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 144 | 145 | static inline void mavlink_msg_gps_rtcm_data_send(mavlink_channel_t chan, uint8_t flags, uint8_t len, const uint8_t *data) 146 | { 147 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 148 | char buf[MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN]; 149 | _mav_put_uint8_t(buf, 0, flags); 150 | _mav_put_uint8_t(buf, 1, len); 151 | _mav_put_uint8_t_array(buf, 2, data, 180); 152 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTCM_DATA, buf, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC); 153 | #else 154 | mavlink_gps_rtcm_data_t packet; 155 | packet.flags = flags; 156 | packet.len = len; 157 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*180); 158 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTCM_DATA, (const char *)&packet, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC); 159 | #endif 160 | } 161 | 162 | /** 163 | * @brief Send a gps_rtcm_data message 164 | * @param chan MAVLink channel to send the message 165 | * @param struct The MAVLink struct to serialize 166 | */ 167 | static inline void mavlink_msg_gps_rtcm_data_send_struct(mavlink_channel_t chan, const mavlink_gps_rtcm_data_t* gps_rtcm_data) 168 | { 169 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 170 | mavlink_msg_gps_rtcm_data_send(chan, gps_rtcm_data->flags, gps_rtcm_data->len, gps_rtcm_data->data); 171 | #else 172 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTCM_DATA, (const char *)gps_rtcm_data, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC); 173 | #endif 174 | } 175 | 176 | #if MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN 177 | /* 178 | This varient of _send() can be used to save stack space by re-using 179 | memory from the receive buffer. The caller provides a 180 | mavlink_message_t which is the size of a full mavlink message. This 181 | is usually the receive buffer for the channel, and allows a reply to an 182 | incoming message with minimum stack space usage. 183 | */ 184 | static inline void mavlink_msg_gps_rtcm_data_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t flags, uint8_t len, const uint8_t *data) 185 | { 186 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 187 | char *buf = (char *)msgbuf; 188 | _mav_put_uint8_t(buf, 0, flags); 189 | _mav_put_uint8_t(buf, 1, len); 190 | _mav_put_uint8_t_array(buf, 2, data, 180); 191 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTCM_DATA, buf, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC); 192 | #else 193 | mavlink_gps_rtcm_data_t *packet = (mavlink_gps_rtcm_data_t *)msgbuf; 194 | packet->flags = flags; 195 | packet->len = len; 196 | mav_array_memcpy(packet->data, data, sizeof(uint8_t)*180); 197 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTCM_DATA, (const char *)packet, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC); 198 | #endif 199 | } 200 | #endif 201 | 202 | #endif 203 | 204 | // MESSAGE GPS_RTCM_DATA UNPACKING 205 | 206 | 207 | /** 208 | * @brief Get field flags from gps_rtcm_data message 209 | * 210 | * @return LSB: 1 means message is fragmented 211 | */ 212 | static inline uint8_t mavlink_msg_gps_rtcm_data_get_flags(const mavlink_message_t* msg) 213 | { 214 | return _MAV_RETURN_uint8_t(msg, 0); 215 | } 216 | 217 | /** 218 | * @brief Get field len from gps_rtcm_data message 219 | * 220 | * @return data length 221 | */ 222 | static inline uint8_t mavlink_msg_gps_rtcm_data_get_len(const mavlink_message_t* msg) 223 | { 224 | return _MAV_RETURN_uint8_t(msg, 1); 225 | } 226 | 227 | /** 228 | * @brief Get field data from gps_rtcm_data message 229 | * 230 | * @return RTCM message (may be fragmented) 231 | */ 232 | static inline uint16_t mavlink_msg_gps_rtcm_data_get_data(const mavlink_message_t* msg, uint8_t *data) 233 | { 234 | return _MAV_RETURN_uint8_t_array(msg, data, 180, 2); 235 | } 236 | 237 | /** 238 | * @brief Decode a gps_rtcm_data message into a struct 239 | * 240 | * @param msg The message to decode 241 | * @param gps_rtcm_data C-struct to decode the message contents into 242 | */ 243 | static inline void mavlink_msg_gps_rtcm_data_decode(const mavlink_message_t* msg, mavlink_gps_rtcm_data_t* gps_rtcm_data) 244 | { 245 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 246 | gps_rtcm_data->flags = mavlink_msg_gps_rtcm_data_get_flags(msg); 247 | gps_rtcm_data->len = mavlink_msg_gps_rtcm_data_get_len(msg); 248 | mavlink_msg_gps_rtcm_data_get_data(msg, gps_rtcm_data->data); 249 | #else 250 | uint8_t len = msg->len < MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN? msg->len : MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN; 251 | memset(gps_rtcm_data, 0, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN); 252 | memcpy(gps_rtcm_data, _MAV_PAYLOAD(msg), len); 253 | #endif 254 | } 255 | -------------------------------------------------------------------------------- /libraries/mavlink/common/mavlink_msg_mission_ack.h: -------------------------------------------------------------------------------- 1 | // MESSAGE MISSION_ACK PACKING 2 | 3 | #define MAVLINK_MSG_ID_MISSION_ACK 47 4 | 5 | typedef struct MAVLINK_PACKED __mavlink_mission_ack_t 6 | { 7 | uint8_t target_system; /*< System ID*/ 8 | uint8_t target_component; /*< Component ID*/ 9 | uint8_t type; /*< See MAV_MISSION_RESULT enum*/ 10 | } mavlink_mission_ack_t; 11 | 12 | #define MAVLINK_MSG_ID_MISSION_ACK_LEN 3 13 | #define MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN 3 14 | #define MAVLINK_MSG_ID_47_LEN 3 15 | #define MAVLINK_MSG_ID_47_MIN_LEN 3 16 | 17 | #define MAVLINK_MSG_ID_MISSION_ACK_CRC 153 18 | #define MAVLINK_MSG_ID_47_CRC 153 19 | 20 | 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_MISSION_ACK { \ 24 | 47, \ 25 | "MISSION_ACK", \ 26 | 3, \ 27 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_mission_ack_t, target_system) }, \ 28 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_mission_ack_t, target_component) }, \ 29 | { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_mission_ack_t, type) }, \ 30 | } \ 31 | } 32 | #else 33 | #define MAVLINK_MESSAGE_INFO_MISSION_ACK { \ 34 | "MISSION_ACK", \ 35 | 3, \ 36 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_mission_ack_t, target_system) }, \ 37 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_mission_ack_t, target_component) }, \ 38 | { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_mission_ack_t, type) }, \ 39 | } \ 40 | } 41 | #endif 42 | 43 | /** 44 | * @brief Pack a mission_ack message 45 | * @param system_id ID of this system 46 | * @param component_id ID of this component (e.g. 200 for IMU) 47 | * @param msg The MAVLink message to compress the data into 48 | * 49 | * @param target_system System ID 50 | * @param target_component Component ID 51 | * @param type See MAV_MISSION_RESULT enum 52 | * @return length of the message in bytes (excluding serial stream start sign) 53 | */ 54 | static inline uint16_t mavlink_msg_mission_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 55 | uint8_t target_system, uint8_t target_component, uint8_t type) 56 | { 57 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 58 | char buf[MAVLINK_MSG_ID_MISSION_ACK_LEN]; 59 | _mav_put_uint8_t(buf, 0, target_system); 60 | _mav_put_uint8_t(buf, 1, target_component); 61 | _mav_put_uint8_t(buf, 2, type); 62 | 63 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ACK_LEN); 64 | #else 65 | mavlink_mission_ack_t packet; 66 | packet.target_system = target_system; 67 | packet.target_component = target_component; 68 | packet.type = type; 69 | 70 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ACK_LEN); 71 | #endif 72 | 73 | msg->msgid = MAVLINK_MSG_ID_MISSION_ACK; 74 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC); 75 | } 76 | 77 | /** 78 | * @brief Pack a mission_ack message on a channel 79 | * @param system_id ID of this system 80 | * @param component_id ID of this component (e.g. 200 for IMU) 81 | * @param chan The MAVLink channel this message will be sent over 82 | * @param msg The MAVLink message to compress the data into 83 | * @param target_system System ID 84 | * @param target_component Component ID 85 | * @param type See MAV_MISSION_RESULT enum 86 | * @return length of the message in bytes (excluding serial stream start sign) 87 | */ 88 | static inline uint16_t mavlink_msg_mission_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 89 | mavlink_message_t* msg, 90 | uint8_t target_system,uint8_t target_component,uint8_t type) 91 | { 92 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 93 | char buf[MAVLINK_MSG_ID_MISSION_ACK_LEN]; 94 | _mav_put_uint8_t(buf, 0, target_system); 95 | _mav_put_uint8_t(buf, 1, target_component); 96 | _mav_put_uint8_t(buf, 2, type); 97 | 98 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ACK_LEN); 99 | #else 100 | mavlink_mission_ack_t packet; 101 | packet.target_system = target_system; 102 | packet.target_component = target_component; 103 | packet.type = type; 104 | 105 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ACK_LEN); 106 | #endif 107 | 108 | msg->msgid = MAVLINK_MSG_ID_MISSION_ACK; 109 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC); 110 | } 111 | 112 | /** 113 | * @brief Encode a mission_ack struct 114 | * 115 | * @param system_id ID of this system 116 | * @param component_id ID of this component (e.g. 200 for IMU) 117 | * @param msg The MAVLink message to compress the data into 118 | * @param mission_ack C-struct to read the message contents from 119 | */ 120 | static inline uint16_t mavlink_msg_mission_ack_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mission_ack_t* mission_ack) 121 | { 122 | return mavlink_msg_mission_ack_pack(system_id, component_id, msg, mission_ack->target_system, mission_ack->target_component, mission_ack->type); 123 | } 124 | 125 | /** 126 | * @brief Encode a mission_ack struct on a channel 127 | * 128 | * @param system_id ID of this system 129 | * @param component_id ID of this component (e.g. 200 for IMU) 130 | * @param chan The MAVLink channel this message will be sent over 131 | * @param msg The MAVLink message to compress the data into 132 | * @param mission_ack C-struct to read the message contents from 133 | */ 134 | static inline uint16_t mavlink_msg_mission_ack_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_mission_ack_t* mission_ack) 135 | { 136 | return mavlink_msg_mission_ack_pack_chan(system_id, component_id, chan, msg, mission_ack->target_system, mission_ack->target_component, mission_ack->type); 137 | } 138 | 139 | /** 140 | * @brief Send a mission_ack message 141 | * @param chan MAVLink channel to send the message 142 | * 143 | * @param target_system System ID 144 | * @param target_component Component ID 145 | * @param type See MAV_MISSION_RESULT enum 146 | */ 147 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 148 | 149 | static inline void mavlink_msg_mission_ack_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t type) 150 | { 151 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 152 | char buf[MAVLINK_MSG_ID_MISSION_ACK_LEN]; 153 | _mav_put_uint8_t(buf, 0, target_system); 154 | _mav_put_uint8_t(buf, 1, target_component); 155 | _mav_put_uint8_t(buf, 2, type); 156 | 157 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, buf, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC); 158 | #else 159 | mavlink_mission_ack_t packet; 160 | packet.target_system = target_system; 161 | packet.target_component = target_component; 162 | packet.type = type; 163 | 164 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, (const char *)&packet, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC); 165 | #endif 166 | } 167 | 168 | /** 169 | * @brief Send a mission_ack message 170 | * @param chan MAVLink channel to send the message 171 | * @param struct The MAVLink struct to serialize 172 | */ 173 | static inline void mavlink_msg_mission_ack_send_struct(mavlink_channel_t chan, const mavlink_mission_ack_t* mission_ack) 174 | { 175 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 176 | mavlink_msg_mission_ack_send(chan, mission_ack->target_system, mission_ack->target_component, mission_ack->type); 177 | #else 178 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, (const char *)mission_ack, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC); 179 | #endif 180 | } 181 | 182 | #if MAVLINK_MSG_ID_MISSION_ACK_LEN <= MAVLINK_MAX_PAYLOAD_LEN 183 | /* 184 | This varient of _send() can be used to save stack space by re-using 185 | memory from the receive buffer. The caller provides a 186 | mavlink_message_t which is the size of a full mavlink message. This 187 | is usually the receive buffer for the channel, and allows a reply to an 188 | incoming message with minimum stack space usage. 189 | */ 190 | static inline void mavlink_msg_mission_ack_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t type) 191 | { 192 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 193 | char *buf = (char *)msgbuf; 194 | _mav_put_uint8_t(buf, 0, target_system); 195 | _mav_put_uint8_t(buf, 1, target_component); 196 | _mav_put_uint8_t(buf, 2, type); 197 | 198 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, buf, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC); 199 | #else 200 | mavlink_mission_ack_t *packet = (mavlink_mission_ack_t *)msgbuf; 201 | packet->target_system = target_system; 202 | packet->target_component = target_component; 203 | packet->type = type; 204 | 205 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, (const char *)packet, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC); 206 | #endif 207 | } 208 | #endif 209 | 210 | #endif 211 | 212 | // MESSAGE MISSION_ACK UNPACKING 213 | 214 | 215 | /** 216 | * @brief Get field target_system from mission_ack message 217 | * 218 | * @return System ID 219 | */ 220 | static inline uint8_t mavlink_msg_mission_ack_get_target_system(const mavlink_message_t* msg) 221 | { 222 | return _MAV_RETURN_uint8_t(msg, 0); 223 | } 224 | 225 | /** 226 | * @brief Get field target_component from mission_ack message 227 | * 228 | * @return Component ID 229 | */ 230 | static inline uint8_t mavlink_msg_mission_ack_get_target_component(const mavlink_message_t* msg) 231 | { 232 | return _MAV_RETURN_uint8_t(msg, 1); 233 | } 234 | 235 | /** 236 | * @brief Get field type from mission_ack message 237 | * 238 | * @return See MAV_MISSION_RESULT enum 239 | */ 240 | static inline uint8_t mavlink_msg_mission_ack_get_type(const mavlink_message_t* msg) 241 | { 242 | return _MAV_RETURN_uint8_t(msg, 2); 243 | } 244 | 245 | /** 246 | * @brief Decode a mission_ack message into a struct 247 | * 248 | * @param msg The message to decode 249 | * @param mission_ack C-struct to decode the message contents into 250 | */ 251 | static inline void mavlink_msg_mission_ack_decode(const mavlink_message_t* msg, mavlink_mission_ack_t* mission_ack) 252 | { 253 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 254 | mission_ack->target_system = mavlink_msg_mission_ack_get_target_system(msg); 255 | mission_ack->target_component = mavlink_msg_mission_ack_get_target_component(msg); 256 | mission_ack->type = mavlink_msg_mission_ack_get_type(msg); 257 | #else 258 | uint8_t len = msg->len < MAVLINK_MSG_ID_MISSION_ACK_LEN? msg->len : MAVLINK_MSG_ID_MISSION_ACK_LEN; 259 | memset(mission_ack, 0, MAVLINK_MSG_ID_MISSION_ACK_LEN); 260 | memcpy(mission_ack, _MAV_PAYLOAD(msg), len); 261 | #endif 262 | } 263 | --------------------------------------------------------------------------------