Cannot send command_long

I am trying a custom gcs written in swift using the Mavlink c library.I can manage to send the request data stream command, but I can't seem to get command_long workingHere is an example for sending the arm command.func sendData(){var message = mavlink_message_t()mavlink_msg_command_long_pack(255, 0, &message, 1, 0, 400, 0, 1, 0, 0, 0, 0, 0, 0)let length = Int(mavlink_msg_get_send_buffer_length(&message))var bytes = [UInt8](count:length, repeatedValue: 0)mavlink_msg_to_send_buffer(&bytes, &message)let sendData = NSData(bytes: (bytes as [UInt8]), length: length)bluetooth.write(sendData)}Also when sending the command for requesting data stream, I have to add 1 to get the correct data, eg to get sys_status stream I use Id of 2 not 1.Thanks

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

Join diydrones

Email me when people reply –

Replies

  • I'm looking for the same thing. I'm working to make the arduino listen and decode the APM's telemtry, using the mavlinks library. The reading part is easy, but the writing part... 
    The only command that I had sucess was the "mavlink_msg_request_param_list", where I get a status text saying two informations.
    I'm looking for the command long or data stream with the correct method.

    I tried: 
    --------
    mavlink_msg_data_stream_pack(1, 1,&sendMSG,0,1000, 1);

    uint16_t len = mavlink_msg_to_send_buffer(buf, &sendMSG);
    Serial1.write(buf,len);

    --------

    But I get no answer, and also tried 255 and 0 on the system_id parameter, 190, 1 and 0 on the componet, but no sucess.

This reply was deleted.

Activity

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