Repository navigation
Conversation
Reset connection state and clean up plugins when stopping the mavsdk_server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Calling
System.connect()a second time (e.g. to reconnect) restartsmavsdk_server.Before restarting,
_stop_mavsdk_server()callsself.__init__(port=self._port).That resets every constructor argument except
port, so the new server is started with thedefault MAVLink IDs instead of the ones the user chose:
After a reconnect, a companion computer or multi-vehicle setup that relies on a fixed
sysid/compid quietly gets the defaults.
Fix
_stop_mavsdk_server()now resets only the per-connection state (_server_process,_plugins, and the"localhost"address thatconnect()set) and leavesport,sysidand
compidas they were. Behaviour is otherwise unchanged:mavsdk_server_address, nothing is started or stopped (as before).Tests
Adds
tests/test_system.py(pytest, no runningmavsdk_serverneeded:_start_mavsdk_serverand_init_pluginsare mocked):port/sysid/compid. This fails onmainand passes with this change;mavsdk_server_addressis never started or stopped.Run with
python3 -m pytest testsfrom the repo root. CI doesn't run pytest yet. I'm happyto add a step to
main.ymlhere or in a follow-up, whichever you prefer.