Mavlink Decoding

Hi,I am trying to decode mavlink message sent from GCS. This is the code I am using. The autopilot board is based on PSoC5 processor.void comm_receive(){mavlink_message_t msg;mavlink_status_t status;p=UART_2_GetRxBufferSize();for(q=0;q

charc= UART_2_GetChar();if(mavlink_parse_char(MAVLINK_COMM_0, charc, &msg, &status)){switch(msg.msgid){case (0xAD):{UART_1_PutString("Data Stream ");UART_1_PutCRLF(0X0D);}case (0xA6):{UART_1_PutString("Radio ");UART_1_PutCRLF(0X0D);}case MAVLINK_MSG_ID_MISSION_ACK:{UART_1_PutString("Mission ack ");UART_1_PutCRLF(0X0D);}case MAVLINK_MSG_ID_PARAM_VALUE:{UART_1_PutString("Param value ");UART_1_PutCRLF(0X0D);}default:break;}}}packet_drops += status.packet_rx_drop_count;}while debugging, the if(mavlink_parse_char()) is always false and is not going to switch case part. Can anyone tell whats wrong in my code & what does mavlink_parse_char() returns.

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Hello,

     

    It seems that I'm faced with the same problems like Priya.

    The function call mavlink_parse_char() never Returns true.

    If i try add some debug Information to the code (see the attached file) i get following results:

    .........

    0 139 0
    0 127 0
    0 127 0
    0 152 0
    0 127 0
    0 156 0
    0 127 0
    0 153 0
    0 127 0
    0 141 0
    0 127 0
    0 142 0
    0 127 0
    0 127 0
    0 148 0
    0 127 0
    0 153 0

    .........

    This tell me, that i receive Messages of the length 127-156 Bytes.

    So why mavlink_parse_char() return false?

    Can anyone help me??

     

     

     

     

     

    mavlink_test.ino

  • hi, now i am able to receive and decode the packet from GCS. In hyperterminal its printing "heart beat" and "parameter request" according to the packets received. But now i am trying to send mission_count packet on detection of Mission_request_list.

    void comm_recv()
    {
    uint8_t buf[MAVLINK_MAX_PACKET_LEN];
    uint16_t len;
    mavlink_status_t status;
    mavlink_message_t msg;

    p=UART_2_GetRxBufferSize();


    if(UART_2_GetRxBufferSize()>0)
    {


    charc= UART_2_GetChar();

    if((mavlink_parse_char(MAVLINK_COMM_0, charc, &msg, &status)))
    {
    if(msg.msgid==0x00)
    {
    UART_1_PutString("Heart Beat ");

    }
    if(msg.msgid==MAVLINK_MSG_ID_PARAM_VALUE)
    {
    UART_1_PutString("Param Value ");
    }

    if(msg.msgid==MAVLINK_MSG_ID_MISSION_ACK)
    {
    UART_1_PutString("Mission Ack ");
    }
    if(msg.msgid==0xA6)
    {
    UART_1_PutString("Radio ");
    }
    if(msg.msgid==21)
    {
    UART_1_PutString("Para_Req_list ");
    }

    if(msg.msgid==43)
    {
    UART_1_PutString("Mission_Req_list ");
    mavlink_mission_request_list_t packet;
    mavlink_msg_mission_request_list_decode(&msg, &packet);


    mavlink_msg_mission_count_pack(1, 200, &msg,1, 200, 3);
    len = mavlink_msg_to_send_buffer(buf, &msg);
    UART_2_PutArray(buf, len);


    }

    if(msg.msgid==43)
    {
    UART_1_PutString("Mission_Req ");


    }

    }


    }

    packet_drops += status.packet_rx_drop_count;

    }

    But the mission_count packet is not being send. what is the problem??
  • q=0; q less than p; q++
  • oops , the code i pasted here is broken while pasting. My actual for loop is.
    for(q=0;q

  • Thanks but I couldnt find that option in mission planner. But when i am reading the telemetry link i am continuously getting radio message( #0xA6. I am not doing mavlink connection to mission planner for the time being). So using the mavlink_parse_char() atleast i should be able to decode that packet right?? status->msg_received is always zero.
  • I think i saw a checkbox in mission planner called debug mavlink messages. Might want to try.

This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…