Flight Mode can't changed by MAVLINK via Python (pymavlink)

Hello, i want to change the Flight Mode via Python (pymavlink) and a companion pc, but it doesn’t working.
ArduCopter 3.5.2 with Pixhawk and the latest pymavlink library on the Raspberry Pi.

It’s possible to change the Flight Mode via the Mission Planner and the RC but not over the Mavlink-Commands.

Primary I want to use the Guided Mode. But also when I want to change in Alt_Hold it’s not possible.

With the Mission Planner no problem.

When I use the follow commands from the library it’s possible to change in RTL or in LOITER

self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_NAV_RETURN_TO_LAUNCH, 0, 0, 0, 0, 0, 0, 0, 0)

self.mav.command_long_send(self.target_system, self.target_component, mavlink.MAV_CMD_NAV_LOITER_UNLIM, 0, 0, 0, 0, 0, 0, 0, 0)

But the follow command doesn’t work for me:

self.mav.command_long_send(self.target_system, self.target_component,
mavlink.MAV_CMD_DO_SET_MODE, 0, mode, custom_mode, custom_sub_mode, 0, 0, 0, 0)

I tried 89 Dez for mode (base_mode) and 4,5 for custom_mode but no change is visible.

What I’m doing wrong?

And which command is used by the Mission Planner in the SourceCode?

Copter does not currently support MAV_CMD_DO_SET_MODE. The other vehicles do. It just hasn’t been implemented in copter yet.

In copter, mode changes are using the older MSG_SET_MODE. Referenced here: https://github.com/ArduPilot/ardupilot/blob/e298e87791c6ac9a377c41b8283ad7043bfd14a3/libraries/GCS_MAVLink/GCS_Common.cpp#L1293

Thank you very much. Okay I understand.
But now I have to find the correct Mavlink-Message for that in the pymavlink-library right?

But how can I use it?

I believe this is what you’re looking for. It’s from the solo repo but should be the same. https://github.com/OpenSolo/mavlink-solo/blob/4060b70d7cd0a7ffe66f45fcd041e6f9af308852/message_definitions/v1.0/common.xml#L1692