Using Dronekit with CubePilot Orange/ADS-B Carrier board - Exception message handler error


I’ll be using this thread to document this error and hopefully my methods to solving it. If anybody has any ideas towards solving it i’d appreciate it

I’m trying to get Dronekit working with my new CubePilot Orange & the ADS-B Carrier board. Whenever I run a dronekit script that ran fine on my old pixhawk 1 board I get an error:

Exception in message handler for HEARTBEAT
mode 0 not available on mavlink definition

The problem is occasionally the program still executes fine. Other times doesnt.

Here it is running off my computer first, and then Pi0:

It failed on the Pi0 but it occasionally works. That’s the error i get when it fails.

I have reasons to believe that this is related to the Serial 5, and 6 parameters.

This thread from 2016 noted the “exception in message handler” error to be related to cross talk with ground systems and etc.

My first “solution” came when I loaded my old parameters from my old Pixhawk 1 that worked. I ran the Hello World code fine on the Pi0 and my ubuntu computer.

I noticed the error appearing when I connected my usb connection with mission planner, and disappearing when I disconnected missionplanner. This lead me to believe the problem was the usb connection. Upon loading my backup parameters for the CubePilot Orange, the “exception in message handler” problem reappeared regardless if i had missionplanner connected or not.

My next point of attack was to see what the different parameters was between my cubepilot orange params and the old Pixhawk 1 params. I specifically loaded only the different SR1_x SR2_x and the Serial5_PROTOCOL Serial5_Baud Rate Serial6_PROTOCOL commands. This lead to the “Exception in Message Handler” problem disappearing. From what I remember, Serial 5 and 6 runs the ADSB commands.

My thinking was the Serial 5 and 6 functions were interfering in cross talk similar to how usb does. I put those params back to what the cubepilot orange initially had, and the error came back.

This is currently where i’m at. I’ll be attempting to find where between serial 5 &6 this problem is coming from, and see if it’s possible to work around this. From what i remember, Serial 5&6 run comms with ADS-B and it’d be desirable to keep that.

If there’s any glaring errors with my methodology, or if there’s anything else I can try, please let me know.

okay, i’ve narrowed it down to Serial5_PROTOCOL

initially my cubepilot Orange had serial5_protocol at 1. Setting it to -1 solves my “Exception in message handler” problem. If i set this back to 1 and play with Serial6 instead, the problem reappears.

Sadly, serial 5 apparently runs ADS-B information to the ground station, which I’d rather have.

This problem might have been the fact that it tried to send ADS-B messages over dronekit, which dronekit I don’t believe is equipped to handle? Or maybe it’s the same interference issue.

I’ll attempt to fix this problem/make them work together later.

I believe this bit might be the solution:

the CubePilot might be attempting to send it over the serial port that the Pi is connected to.

Note to self: Backup 2 + original params/Serial5_protocol = -1.

I am using a raspberry 4 pi and I came up with the same issue.
“dronekit:Exception in message handler for HEARTBEAT”
“dronekit:APIException: mode(0, 4) not available on mavlink definition”
You are correct in that it is a communication error where dronekit is receiving multiple mavlink messages at the same time from the ADS-B as well as the pi.

I took your advice and made SERIAL5_PROTOCOL -1 and i stopped receiving the message handler errors. Which as you pointed out solves the problem but not really because you have now disabled the communication for ADS-B.

I was wondering if you have made any progress as to whether you can have both the ADS-B and the companion computer sending/receiving messages at the same time. The only solution I can think of is to have it be send directly to the ground station rather than through the serial port the computer is connected to.

Kind of. I think you’ll have to post on the ardupilot forums to get a for sure answer to this but from what I remember I think the guy who was working on MissionPlanner told me to ignore sysid(0,1). This would ignore messages from the ADSB serial port, as Dronekit doesn’t know how to read those yet. I’m not sure how to “ignore sysid(0,1)” (might just be that verbatim), or if the 0,1 were the right numbers, but I hope that’s a good direction for you to go into and find an answer from.

If you do find an answer, could you update this thread as well please? Thank you!

Okay thank you. I will look into it and I WILL GET THE ANSWER haha and I’ll update this thread.

1 Like

Did you get the answer??

I havent looked into this ever since then, but just curious, could you try fiddling with this and turn off SRx_ADSB for your dronekit telemetry port?

Any update on this? I am currently using the most recent version of drone kit with arudpilot 4.0.7 and am running into the " raise APIException(“mode (%s, %s) not available on mavlink definition” % (m.custom_mode, m.base_mode))
dronekit.APIException: mode (0, 4) not available on mavlink definition
ERROR:dronekit:Exception in message handler for HEARTBEAT"
error. Funny enough the code still compiles and produces the correct values, it just raises this issue and continues to run through the program. Any resolution to this? I am have dronekit 2.9.2 and pymavlink 2.4.15 on my raspi connected via serial to telem2 on cube orange.

hello, i got the same error, did you find a solution?

I am experiencing the same issue except it won’t even let me script connect due to the error. What about using a different library instead of Dronekit?

Hi guys, i had the same problem. After i applied what written above, i did uninstall the pymavlink first, then install the one of the earlier version of it and the problem solved. You should try that!

pip3 uninstall pymavlink
pip3 install pymavlink==2.4.0