How to use a real serial device in SITL?

Hello everyone,
i am try to use a real serial 3dr telemetry in SITL, it’s baud rate has been set to 115200.
i followed the link: http://ardupilot.org/dev/docs/using-sitl-for-ardupilot-testing.html


and i run SITL with command as follow:
sim_vehicle.py -A “–uartE=uart:/dev/ttyUSB0” --console --map --out 192.168.1.104:14550
Does uartE is serial4? by the way, /dev/ttyUSB0 is the 3dr telemetry.


with GCS Missionplanner, the UDP link is OK. but with 3dr telimetry the connection can not de done.
3dr telemetry failed connect mission planner
image

when get UDP connection, i check the serial4 settings as follow:

I use a serial terminal tool to connet the 3dr telemetry, i can get serial data,

Did i miss something? how to use a real serial device in SITL?

Are you sure about that?
What console are you using? It’s working fine for me in Cygwin and WSL, but I use ‘ttyS0’ instead of ‘ttyUSB0’.

Try to read from your port with a simple script, like this in Python for example, and see if it’s working:

import sys
from pymavlink import mavutil

def main(port):
	decoder = mavutil.mavlink_connection(port, baud = 115200)
	decoder.mav.request_data_stream_send(decoder.target_system, decoder.target_component, mavutil.mavlink.MAV_DATA_STREAM_ALL, 1, 1)

	while True:
		msg = decoder.recv_match(blocking = False)
		if msg:
			print(msg)

if __name__ == '__main__':
	if len(sys.argv) > 1:
		port = sys.argv[1]
	else:
		sys.exit('No port specified')

	main(port)

Hi Echo, thanks for reply

my SITL host is Linux (Ubuntu), may be that’s why your serial device is ttyS0. as the picture show:

i will check my telemetry with your python script, thanks a lot.

My guess: You need to set the baud rate at the command line. Serial defaults to 57600, and you have your radio at 115200.

hi james_pattison, thanks for reply.

i rebuild the arducopter source, and the Serial default baud is 115200.

But you’re connecting via mavproxy (which handles the connection to sitl). You need to set the baud rate at both ends.

Just append it to the startup command: “…ttyUSB0, 115200”

Hi james_pattison, i changed my 3dr telemetry to 57600, and rebuild the arducopter with 57600, and now it work perfectly. thanks a lot.

So, what the logic behind this?

The 3DR radio is reliable at 57600, so that’s used as the default baud.
If you change it on the radio or in the code, you need to make sure that all components that need to connect are at the same setting, that’s all.