[Mission Planner Programming Question]How to distinguish the MAVLinkInterface object currently connected

Hello.

I’m working on some plugins for multiple vehicle connected situation.

below code was useful when there are only two vehicle and their firmware version and kind is different :

foreach (MAVLinkInterface mav in MainV2.Comports)
                {
                    if (mav.MAV.cs.firmware == MissionPlanner.ArduPilot.Firmwares.ArduCopter2)
                    {

but, If there is many vehicle that have same firmware, It is hard to distinguish which one is currently selected by user in the mission planner.

I mean, in below scroll bar, user can select various vehicles, and programmer can’t know which vessel is selected in mission planner. :

firmware select scroll

I chekced that this code effectively found the vehicle that is currently selected by user, but I’m not sure it is correct way to find selected object.

Console.WriteLine("Firmware Version : ");
Console.WriteLine(MainV2.comPort.MAV.cs.firmware); 

Im unassure that it will find currently connected vehicle in any situations.
Is there other way find vehicle currently connected? is there any properties on mavlink object to confirm that or any UI object to check that

Vehicle is identified by its sysid as a unique identifier.

Yes, but what if the sysid is not organized in advance?

is Access by “MainV2.comPort.MAV.cs.XXX” only the solution for accessing vehicle?

MainV2.Comports is a list MavlinkInterface objects (ports) all open vehicle connection has a port object in this list. MainV2.comPort is only a reference to a list item.
The items in the list is updated regardless of what is selected in the dropdown.
Comports.sysidcurrent contains the selected vehicle sysid.

Note: Actually it is not only sysid but sysid and componentID. You should take it into consideration if you have a vehicle with a component that communicates via mavlink and has it’s own componentID.

MainV2.Comports is a list MavlinkInterface objects (ports) all open vehicle connection has a port object in this list. MainV2.comPort is only a reference to a list item.
The items in the list is updated regardless of what is selected in the dropdown.

← I know it, I think there is misunderstanding between us, sorry for my long and complex post.

suppose we have to setup specific parameters for only one vehicle that is currently selected(in multiple vehicle connection situation)

How do you know that one vehicle is connected?

and different with your saying, If I change selection in dropdown list, “MainV2.comPort.MAV.cs.XXX” object is changed.
for example, If I select Rover in dropdown list, it will print parameters of rover, and If I select quadrotor in dropdown list, it will print parameters of copter.

and What if the sysid is not organized well before connecting vehicle to mission planner? Can we know which vehicle is selected?

I think we should have the method to determine which vehicle is currently selected…

will contain the firmware type of the connected vehicle.
However it is better to know your sysid.