pymavlink icon indicating copy to clipboard operation
pymavlink copied to clipboard

mavutil: Add option to set dialect directly from file

Open MauroPfister opened this issue 10 months ago • 3 comments

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.

MauroPfister avatar Mar 28 '24 16:03 MauroPfister

probably using venv for each dialect type could work.

khancyr avatar Mar 28 '24 17:03 khancyr

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.

MauroPfister avatar Mar 28 '24 17:03 MauroPfister

Any chance to get a review on this?

MauroPfister avatar May 30 '24 14:05 MauroPfister