# Flight controller transmit custom mavlink message to QGC station

**URL:** <https://discuss.px4.io/t/flight-controller-transmit-custom-mavlink-message-to-qgc-station/337>\
**Category:** Uncategorized\
**Created:** [April 18, 2016, 12:10pm UTC](https://discuss.px4.io/t/flight-controller-transmit-custom-mavlink-message-to-qgc-station/337 "2016-04-18T12:10:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![viewshell](https://discuss.px4.io/letter_avatar_proxy/v4/letter/v/8dc957/32.png) [@viewshell](https://discuss.px4.io/u/viewshell)\
**Post date:** [April 18, 2016, 12:10pm UTC](https://discuss.px4.io/t/flight-controller-transmit-custom-mavlink-message-to-qgc-station/337/1 "2016-04-18T12:10:28Z")

</div>

**I transmit a custom mavlink message from px4 flight controller to qgc station, but the message received by qgc is wrong.**  
The mavlink protocal version is v1.0.  
My custom mavlink message is as follows :

 ![](https://discuss.px4.io/uploads/default/original/1X/505fa3686b15810a5b85d391102a8c01c3f51ae6.png)  
The custom mavlink message includes the **common.xml**. And I use **mavgenerate.py** tool to generate C style mavlink message code.

Now there is a strange phenomenon. It is the QGC station can received the custom mavlink message. But **“MAVLink Inspector” and “Analyze” widgets** can’t recongnize correctly data values of **“PWM\_INPUT”** item.  
What I can confirm are as follows :  
**(1) From the end of PX4/Firmware :**  
mavlink\_msg\_pwm\_input.h : Add this header file into mavlink/v1.0/comon folder and include this file in the common.h file.  
mavlink\_messages.cpp : **Class MavlinkStreamPWMINPUT** defined by referencing **Class MavlinkStreamAttitude** is a custom class.  
mavlink\_messages.cpp : Transmit data by invoking **send()** method in **Class MavlinkStreamPWMINPUT.**  
mavlink\_messages.cpp : All the members of pwm\_input(time\_boot\_ms, pulse\_width, period) print correct data values.  
mavlink\_main.cpp : I also configure the transmission speed throuth invoking **configure\_stream(“PWMINPUT”, Hz.0f)** method according to different **MAVLINK\_MODE\_xx in task\_main method .**

 ![](https://discuss.px4.io/uploads/default/original/1X/56c7d7a3e599712d0221e1487a7623927a3dfa88.png)  
 ![](https://discuss.px4.io/uploads/default/original/1X/759858038249e92fea02c8bdab7ad75e23f2313f.png)  
 ![](https://discuss.px4.io/uploads/default/original/1X/0229139c5660294e24a6e2b046257b327a6c9e8e.png)

**(2) From the end of QGC station :**  
mavlink\_msg\_pwm\_input.h : Add this header file into **mavlink/v1.0/comon/** folder and include this file in the **common.h** file.  
After including the pwm\_input related header file, **MAVLink Inspector and Analyze widgets** can recongnize the PWM\_INPUT mavlink message but can’t analyze correct member data values.  
UAS.cc : The specific performance of PWM\_INPUT.time\_boot\_ms, PWM\_INPUT.pulse\_width, PWM\_INPUT.period print incorrect data values(As follows).

 ![](https://discuss.px4.io/uploads/default/original/1X/5199cc8d8497828f647ace7189f5d0f8a97fdef0.png)

**By preliminary observation and judgment, the qDebug values of the pwm\_input’s members and the data shown via MAVLink Inspector and Analyze are the same.**

**What is the wrong? Can you tell me the reason? Thanks very much!**

---

<div class="post-metadata">

**Author:** ![viewshell](https://discuss.px4.io/letter_avatar_proxy/v4/letter/v/8dc957/32.png) [@viewshell](https://discuss.px4.io/u/viewshell)\
**Post date:** [April 18, 2016, 2:56pm UTC](https://discuss.px4.io/t/flight-controller-transmit-custom-mavlink-message-to-qgc-station/337/2 "2016-04-18T14:56:45Z")

</div>

I have referenced [mavlink\_and\_uorb\_custom\_message](https://pixhawk.org/dev/mavlink_and_uorb_custom_message). But the problem isn’t related to that directly.

---

<div class="post-metadata">

**Author:** ![viewshell](https://discuss.px4.io/letter_avatar_proxy/v4/letter/v/8dc957/32.png) [@viewshell](https://discuss.px4.io/u/viewshell)\
**Post date:** [April 19, 2016, 10:55am UTC](https://discuss.px4.io/t/flight-controller-transmit-custom-mavlink-message-to-qgc-station/337/3 "2016-04-19T10:55:05Z")

</div>

The actual situation is as follows:

 ![](https://discuss.px4.io/uploads/default/original/1X/a53ba64483656cd511e87444015c731f95c0b911.png)

 ![](https://discuss.px4.io/uploads/default/original/1X/aab6dd2f1612fb8cf13b519f84561915ce5e80b4.png)

The members of pwm\_input get wrong values.

The reason for above result is that I only set the **MAVLINK\_MESSAGE\_INFO** without setting **MAVLINK\_MESSAGE\_CRCS** and **MAVLINK\_MESSAGE\_LENGTHS**.

 ![](https://discuss.px4.io/uploads/default/original/1X/15a321d14e6ac4df5b2ef3c3052a5acad94791be.PNG)

After I set all the **MAVLINK\_MESSAGE\_INFO, MAVLINK\_MESSAGE\_CRCS and MAVLINK\_MESSAGE\_LENGTHS** valus(create by mavgenerate.py) about the position **PWM\_INPUT**. The result is as follows. **But there isn’t any information about PWM\_INPUT.**

 ![](https://discuss.px4.io/uploads/default/original/1X/2c30eec744e18bc7986dddff4bfd0c8bfae63625.PNG)

What could I do to solve the problem? Could you tell me?
