Hi, I’m very new to Mission Planner and want to explore mavlink communication between my code and SITL. I’ve started Mission Planner on my Windows host, ran a Quad sim from the UI - everything works. The console shows ports 5760, 5762, 5763 are open as serial ports, and that serial port 0 is connected to (I guess by the UI):
Setting SIM_SPEEDUP=1.000000
Suggested EK3_DRAG_BCOEF_* = 16.288, EK3_DRAG_MCOEF = 0.209
Home: -35.363352 149.165241 alt=587.060000m hdg=0.000000
Starting sketch 'ArduCopter'
Starting SITL input
Using Irlock at port : 9005
bind port 5760 for 0
Serial port 0 on TCP port 5760
Loaded defaults from C:\Users\xxxx\Mission Planner\sitl\default_params/copter.parm
bind port 5762 for 2
Serial port 2 on TCP port 5762
bind port 5763 for 3
Serial port 3 on TCP port 5763
Smoothing reset at 0.001
validate_structures:498: Validating structures
Loaded defaults from C:\Users\xxxx\Mission Planner\sitl\default_params/copter.parm
New connection on serial port 0
I am now trying to connect to port 5762 with my Python mavlink code but connect
method never returns, it waits forever:
from mavsdk import System
import asyncio
async def run():
drone = System('localhost', 5762)
await drone.connect('tcp://localhost:5762')
if __name__ == '__main__':
asyncio.run(run())
While waiting, SITL console shows the connection attempt being retried over and over:
New connection on serial port 2
Closed connection on serial port 2
New connection on serial port 2
Closed connection on serial port 2
...repeats forever
What am I doing wrong?
Thanks…