MAVLink arduino send command

Hi, i’m trying to send a reboot command to my pixhawk via arduino.
I’m using a teensy 3.2 and i can read all the data sent from the pixhawk but it seems my function is no compiling.
i’ve tryed to dig out some info from the mavlink v1 library, but i’m not so good to undenstrand all.
thanks a lot

reboot.txt (903 Bytes)

reboot.txt:

void reboot(){

  //TARGET DRONE
  uint8_t target_system = 1; // Target drone id
  uint8_t target_component = 0; // Target component, 0 = all
  uint16_t command = MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN; // Specific command for PX4
  uint8_t confirmation = 0; 
  float param1 = 1; 
  float param2 = 0; 
  float param3 = 0; 
  float param4 = 0; 
  float param5 = 0; 
  float param6 = 0; 
  float param7 = 0;

  // Initialize the required buffers
  mavlink_command_long_t msg;
  uint8_t buf[MAVLINK_MAX_PACKET_LEN];

  // Pack the message
 uint16_t mavlink_msg_command_long_pack( 255, 1, &msg, target_system, target_component, command, confirmation, param1, param2, param3, param4, param5, param6, param7);

  // Copy the message to the send buffer
  uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);
  // Send the message (.write sends as bytes)
  SerialMAV.write(buf, len);

}

Please post code in code tags ( </> )…Learn how to use the forum!

xarin94:
but it seems my function is no compiling.

So you get a compile error? If so, post the full error message.

And post your full code.

sorry for my crappy explanation and the text not properly attached
this is the message

hud_v4.3.ino:481:54: error: cannot convert 'mavlink_command_long_t* {aka __mavlink_command_long_t*}' to 'const mavlink_message_t* {aka const __mavlink_message*}' for argument '2' to 'uint16_t mavlink_msg_to_send_buffer(uint8_t*, const mavlink_message_t*)'
uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);

the complete program is way to long to be attached, but the function heartbeat is working very well and is very similar for syntax.

if anyone needs it, this cuncrion works, for oter command only change the intestation of command: in this case
MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN

void reboot(){

  //TARGET DRONE
  uint8_t target_system = 1; // Target drone id
  uint8_t target_component = 0; // Target component, 0 = all
  uint16_t command = MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN; // Specific command for PX4
  uint8_t confirmation = 0; 
  float param1 = 1; 
  float param2 = 0; 
  float param3 = 0; 
  float param4 = 0; 
  float param5 = 0; 
  float param6 = 0; 
  float param7 = 0;

  // Initialize the required buffers
  mavlink_message_t msg;
  uint8_t buf[MAVLINK_MAX_PACKET_LEN];

 mavlink_msg_command_long_pack( 1, 255, &msg, target_system, target_component, command, confirmation, param1, param2, param3, param4, param5, param6, param7);

  // Copy the message to the send buffer
  uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);
  // Send the message (.write sends as bytes)
  SerialMAV.write(buf, len);

}