ADSB_Vehicle MavLink message does not get sent

Hello everybody,

I am trying to send a custom ADSB_Vehicle message from my raspberry Pi to my Pixhawk4 via Telem2 port using the mavgen C library. I can perfectly request data streams, send and receive GLOBAL_POSITION_INT and HEARTBEAT messages.

But when i try to send a ADSB_Vehicle message it seem so never exit the raspberry pi. I cant see it on the mavlink inspector nor the simple “show every received mavlink packet” script on the pi.

I have tried things like adding changing system and component id or adding1Hz heartbeat messages.
I have a µAvionix ping that i tried to mimic the behavior of, without luck.

Thanks for your help!

Code:

#include <mavlink.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>

mavlink_message_t msg;

int main()
{
        char *portname = "/dev/ttyS0";
        uint16_t len = 0;
        int mavLinkStream = open(portname, O_RDWR | O_NOCTTY | O_NDELAY); ///dev/ttyUSB0  oder  /dev/ttyS0
        sleep(1);
        if (mavLinkStream == -1)
        {
                printf("[ERROR] UART open()\n");
        }
        else
        {
                printf(" UART ist open() \n");
        }
        struct termios options;
        tcgetattr(mavLinkStream, &options);
        options.c_cflag = B57600 | CS8 | CLOCAL | CREAD;
        options.c_iflag = IGNPAR;
        options.c_oflag = 0;
        options.c_lflag = 0;
        tcflush(mavLinkStream, TCIFLUSH);
        tcsetattr(mavLinkStream, TCSANOW, &options);
        sleep(1);

        char buf[40];
        //request gps data stream
        //mavlink_msg_message_interval_pack(1, 1, &msg,MAVLINK_MSG_ID_GLOBAL_POSITION_INT, 10000);      //Cleaner solution, does not work however.
        //mavlink_msg_request_data_stream_pack(27,27, &msg, 1, 1, 0, 1, 1);       //request data stream All(0) (depricated function but works)
        //len = mavlink_msg_to_send_buffer(buf, &msg);
        //write (mavLinkStream, buf, len);

        len = mavlink_msg_adsb_vehicle_pack(1, 1, &msg, 4251708, 495795456, 197686112, 0, 741400, 16000, 10000, 1200, "aaaaaaaa", 3, 1, 415, 0);
        //len=mavlink_msg_global_position_int_pack(255,0,&msg,1234,47,11,260,10,0,0,0,UINT16_MAX);        //this line works
        char bufsend[len];
        printf("message prepared: ID %d length: %d", msg.msgid, len);
        len = mavlink_msg_to_send_buffer(bufsend, &msg);
        write(mavLinkStream, bufsend, len);

        return 0;
}