Skip to content

Raise a clear error when play_tune is used over MAVLink 1 - #1258

Open
Abhayindia wants to merge 1 commit into
dronekit:masterfrom
Abhayindia:fix/play-tune-clean
Open

Abhayindia wants to merge 1 commit into
dronekit:masterfrom
Abhayindia:fix/play-tune-clean

Conversation

@Abhayindia

Copy link
Copy Markdown

Third fix out of the #1255 SITL sweep, after #1256 and #1257.

vehicle.play_tune() fails against any MAVLink 1 link with a confusing error that points at an unrelated message:

AttributeError: 'MAVLink' object has no attribute 'play_tune_encode'. Did you mean: 'altitude_encode'?

PLAY_TUNE exists only in the MAVLink 2 dialects. I checked all four:

dialect play_tune_encode
v20.ardupilotmega / v20.common present
v10.ardupilotmega / v10.common absent

Vehicle.message_factory is self._master.mav, bound to whatever dialect the link negotiates, and the APM:Copter 3.3 binary dronekit-sitl ships is from 2015, so the link comes up as pymavlink.dialects.v10.ardupilotmega. There is no MAVLink 1 equivalent to fall back to, so this raises an APIException saying why instead.

Verified against dronekit-sitl copter. Before, the example dies on the AttributeError above. After:

dronekit.APIException: play_tune requires MAVLink 2. This connection negotiated
MAVLink 1, whose dialects have no PLAY_TUNE message, so the tune cannot be sent.

One thing I deliberately left out of the message: I tried MAVLINK20=1 to force the newer dialect, and connect(..., wait_ready=True) then hangs until timeout against this SITL, so suggesting it would have sent people down a dead end.

Based on master, independent of #1256 and #1257. Note that #1253 has to be applied before any example can run at all, since import dronekit currently fails with ModuleNotFoundError: No module named 'past'; I tested this change with that fix applied locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant