Serial instead of UDP for DroneCore examples

Hello everyone !

We are trying to develop a code for a student project in a HITL configuration, but the DroneCore documentation says that serial is not yet supported. We don’t have the material to communicate with the flight controller using UDP, do you have an idea on how we could manage to run something equivalent to the Fly Mission example using a serial connection ?

Thank you for your help.

Serial is actually supported now.

Hi Julian,
I have just downloaded and built the Dronecode SDK but I have a problem using the serial connection on Linux.
If I connect through the usb port and use the command line “./takeoff_and_land serial:///dev/ttyACM0:115200”, my laptop connects to the drone and I get the following messages:

[10:36:36|Debug] New: System ID: 1 Comp ID: 1 (dronecore_impl.cpp:292)
[10:36:36|Debug] Component Autopilot added. (system_impl.cpp:339)
[10:36:37|Debug] Found 1 component(s). (system_impl.cpp:466)
[10:36:37|Debug] Discovered 3545547880866527033 (system_impl.cpp:468)
Discovered system with UUID: 3545547880866527033
Vehicle is getting ready to arm

On the contrary, if I use the SiK and the command “./takeoff_and_land serial:///dev/ttyUSB0:57600”, I get:

Waiting to discover system...
No system found, exiting.

Am I missing something? I hope you could help me find what’s wrong…
Thank you so much!

Hi elBarto, can you check if connection works over ttyUSB0 with QGroundControl?

And can you check if mavlink 2 is enabled for it?
You can e.g. do this in nsh> using mavlink status.

Thank you for your reply. QGroundControl works over ttyUSB0 (I don’t have to configure the connection, it works by itself) and this is the mavlink status output:

nsh> mavlink status
instance #0:
	GCS heartbeat:	265703 us ago
	mavlink chan: #0
	type:		3DR RADIO
	rssi:		188
	remote rssi:	189
	txbuf:		100
	noise:		44
	remote noise:	68
	rx errors:	1
	fixed:		0
	flow control:	ON
	tx: 0.562 kB/s
	txerr: 0.000 kB/s
	rx: 0.042 kB/s
	rate mult: 0.557
	accepting commands: YES, FTP enabled: NO
	transmitting enabled: YES
	mode: Normal
	MAVLink version: 2
	transport protocol: serial (/dev/ttyS1 @57600)
	ping statistics:
	 last: 2326.47 ms
	 mean: 1400.85 ms
	 max: 2340.97 ms
	 min: 116.64 ms
	 dropped packets: 0
instance #1:
	mavlink chan: #1
	no telem status.
	flow control:	OFF
	tx: 14.794 kB/s
	txerr: 0.000 kB/s
	rx: 0.000 kB/s
	rate mult: 1.000
	accepting commands: YES, FTP enabled: YES
	transmitting enabled: YES
	mode: Onboard
	MAVLink version: 1
	transport protocol: serial (/dev/ttyS2 @921600)
	ping statistics:
	 last: -0.00 ms
	 mean: -0.00 ms
	 max: -3038453144258059580735488.00 ms
	 min: 0.00 ms
	 dropped packets: 789591659

Suddenly, after I used the “” script, the Dronecode example started working… but it says:

> [12:19:21|Error] Error: more than one system found: (dronecore_impl.cpp:219)

Then it works

I have another question:“How can I enable Mavlink 2 for the TELEM2 port,too?”
I would like to use Dronecode also on my companion computer but the mavlink version is 1 on the TELEM2 port and it returs “No system found”.
Thank you!

[12:19:21|Error] Error: more than one system found: (dronecore_impl.cpp:219)

Do you have some other system sending mavlink heartbeats with another system ID? E.g. SITL or a companion computer sending mavlink? Or another drone in the network broadcasting?

but the mavlink version is 1


I set MAV_PROTO_VER to 2 and now both the instances are “MAVLink version: 2”.
Anyhow, if I launch “./takeoff_and_land serial:///dev/ttyUSB1:921600”, the example doesn’t work: it says “No system found, exiting”. The device ttyUSB1 is a usb-to-tty (FTD1232) adapter that I connected to TELEM2.
The SYS_COMPANION parameter is set to 921600. Should I change the bitrate? It seems that it cannot catch the heartbeat, am I right?
Thank you

P.S.: I lowered the bitrate to 57600 but the result is still the same. On the contrary, the QGroundControl works even through TELEM2@57600.

Hm, and this is on the onboard computer? Do you have the permissions? Can you check if screen /dev/ttyUSB1 57600 works and spits out some binary characters (aka mavlink)?

Actually I am not using the onboard computer yet…I have both the Sik Radio and the usb-to-ttl adapter connected to the same laptop on two different usb ports… so, the permissions should be the same.
I checked with picocom.

This is ttyusb0:

picocom v2.2
port is        : /dev/ttyUSB0
flowcontrol    : none
baudrate is    : 57600
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
nolock is      : yes
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,
Type [C-a] [C-h] to see available commands
Terminal ready
"�A�A� � � ]�� � � � � � � � � � ����$NF���������T)���95��g��	O
                                                                            Q��P �.9�@p�e:��X���s<�e�Q%�.�D<ޅ6<�(?f�H��ϙ:�{Ĺ�<�R��.��D<�A7<K*?f1�9�d:(��:��SJ7S�;�<�@ɮX�9Z�TA�.AE<_d7<g,? ��9�D�:�p�G��Uͯ.��E<��7<*?poX9n�\:�ʫ��`�*VAگ.��������jjjjjjjj������$WF����������1����=����

And this one is ttyUSB1:

picocom v2.2
port is        : /dev/ttyUSB1
flowcontrol    : none
baudrate is    : 921600
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
nolock is      : yes
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,
Type [C-a] [C-h] to see available commands
Terminal ready
�����/�E<z�(<o�?s��:4D���Qq8&-� ���/��`?459;x!�;-t�>6E�:`�1�M���m�>�i��e�}�=���Xv�6E�:`�1�M���>�\j�%��>���GJ��@�QHB�e������/��-���G:����/��E<�(<��?�E2�
                                               �h���J:�� ��p�e�J��@J��@��	���	�����

Ok so clearly mavlink 2 is arriving but the SDK fails to recognize a system.

What system ID are you using? Can you try with system ID 1, so MAV_SYS_ID set to 1?

mmm…it is already set to 1

Hm, so how could I try to reproduce this?

I set up a Pixhawk, set it to mavlink 2 and try to connect to Telem2?

Yes, but first you have to set SYS_COMPANION to “Companion Link (921600 baud, 8N1)” to enable the TELEM2 port.

Right, ok, thanks. I’ll let you know when I get to this in the next days, otherwise ping me again please!

Ok, thank you so much!

Ok, so I set SYS_COMPANION to 57600 and was able to connect to Telem2 of my Pixhawk using the example:

./fly_mission serial:///dev/ttyUSB0:57600

as well as the integration tests (change add_udp_connection() to add_serial_connection("/dev/ttyUSB0", 57600).

make && build/default/integration_tests/integration_tests_runner -- --gtest_filter="SitlTest.TelemetryAsync"

I then tried to set SYS_COMPANION to 921600 and it did not work, neither with the SDK nor with QGC. Note that I had to disable the “Pixhawk” auto-connection in QGC, otherwise it would just connect via USB. I then manually added a serial connection at the port and baudrate in QGC and it did not work but show a strange error:

My best guess is that baudrate 921600 on a Pixhawk (currently) doesn’t work. I suggest you try to use 57600 for SYS_COMPANION and try again.

Hi Julian,
thank you, I changed the baudrate and it finally worked!

Then I changed SYS_COMPANION back to 921600 and I wrote a little piece of code using native mavlink protocol to test the baudrate.
It works @921600, too. I have been able to get the HEARTBEAT message and read the mavlink version.
I uploaded the code here:

1 Like

Awesome, that means something is wrong in the SDK at 921600 (and also QGC presumably). I’ll have to check that! Thanks a lot for sharing that.

1 Like

Hi Julian,
would you please drop me a message when a fix to the SDK is released?
Thank you very much!