Able to set GUIDED mode, unable to ARM despite arming checks apparently done (log supplied)

I am trying to control the SITL drone using my C Mavlink program.

I have a serial passthrough setup with socat:

user@pc:~$ socat -d -d pty,raw,echo=0,b57600 pty,raw,echo=0,b57600
2021/12/07 17:54:14 socat[17144] N PTY is /dev/pts/3
2021/12/07 17:54:14 socat[17144] N PTY is /dev/pts/6
2021/12/07 17:54:14 socat[17144] N starting data transfer loop with FDs [5,5] and [7,7]

I have SITL running as follows:

python3 Tools/autotest/sim_vehicle.py -v ArduCopter -f quad -L KSFO --console --map -A "--serial2=uart:/dev/pts/3"

SIM_VEHICLE: Using defaults from (/home/user/ardupilot/Tools/autotest/default_params/copter.parm)
SIM_VEHICLE: Run ArduCopter
SIM_VEHICLE: "/home/user/ardupilot/Tools/autotest/run_in_terminal_window.sh" "ArduCopter" "/home/user/ardupilot/build/sitl/bin/arducopter" "-S" "--model" "+" "--speedup" "1" "--slave" "0" "--serial2=uart:/dev/pts/3" "--defaults" "/home/user/ardupilot/Tools/autotest/default_params/copter.parm" "-I0" "--home" "37.619373,-122.376637,5.3,118.0"
SIM_VEHICLE: Run MavProxy
SIM_VEHICLE: "mavproxy.py" "--out" "127.0.0.1:14550" "--out" "127.0.0.1:14551" "--master" "tcp:127.0.0.1:5760" "--sitl" "127.0.0.1:5501" "--map" "--console"
RiTW: Starting ArduCopter : /home/user/ardupilot/build/sitl/bin/arducopter -S --model + --speedup 1 --slave 0 --serial2=uart:/dev/pts/3 --defaults /home/user/ardupilot/Tools/autotest/default_params/copter.parm -I0 --home 37.619373,-122.376637,5.3,118.0
Connect tcp:127.0.0.1:5760 source_system=255
Loaded module console
Loaded module map
Log Directory: 
Telemetry log: mav.tlog
Waiting for heartbeat from tcp:127.0.0.1:5760
MAV> STABILIZE> Received 1283 parameters (ftp)
Saved 1283 parameters to mav.parm

GUIDED>

My program sees the initial flight mode of STABILIZE and then sets the mode to GUIDED and observes the successful change to GUIDED received back from the virtual drone. The problem is, when I then try to arm the drone, I get back MAV_RESULT_FAILED.

log_2_2021-12-7-17-58-15.bin (570.5 KB)

Please can anyone more experienced than I see why this is not working? As a side note, I have no problems doing this on a real drone. Thanks.

I now have this working over a local UDP connection, however I would have preferred to test with a serial link.

My current theory is that socat is buffering data so as soon as my C program connects to the pseudo ts, it gets spammed with the buffered data.

1 Like

hii, can you help me i am trying to arm the arducopter using a C program but i couldn’t find the exact file where binary data stream is sent to arducopter to arm/disarm.