I am trying to arm the APM using mavlink via a c++ code. It is a modified version of the send_quad_commands written by Lorenz.
int fd = serial_fd;
char buf[300];
mavlink_command_long_t arm_command_msg;
mavlink_message_t arm_msg;
arm_command_msg.command = 40;
arm_command_msg.target_system = 1;
arm_command_msg.target_component = 250;
arm_command_msg.confirmation = 0;
arm_command_msg.param1 = 1;
arm_command_msg.param2 = 0;
arm_command_msg.param3 = 0;
arm_command_msg.param4 = 0;
arm_command_msg.param5 = 0;
arm_command_msg.param6 = 0;
arm_command_msg.param7 = 0;
mavlink_msg_command_long_encode(1, 250, &arm_msg, &arm_command_msg);
unsigned len = mavlink_msg_to_send_buffer((uint8_t*)buf, &arm_msg);
write(fd, buf, len);
That is the code that i have now. It sends some sort of command to the apm (It beeps everytime i call the code). However it doesnt seem to arm the apm. I am not sure what is going wrong. Any help is highly appreciated