pymavlink
pymavlink copied to clipboard
mavutil: Add option to set dialect directly from file
Add option to set a dialect directly from a file anywhere on the system. The dialect file has to be generated beforehand from message definitions using mavgen.
This is useful in situations where different versions of the same dialect might be needed to talk to different devices (see https://github.com/ArduPilot/pymavlink/issues/864).
Example:
from pymavlink import mavutil
import os
os.environ['MAVLINK20'] = "1"
mavutil.set_dialect_from_file("/home/user/my_dialects/v20/my_special_dialect.py")
I'm not sure if this is something that pymavlink intends to support or if there are better solutions to this problem. Happy to be educated.
probably using venv for each dialect type could work.
That only works if you don't need to switch dialect at runtime. Imagine a test application that can connect (at runtime) to various devices that might not use the same dialect. In this case using different vens won't be an option.
Any chance to get a review on this?