Reading GCS messages on companion computer (Pymavlink)


How can I intercept and read MAVLink messages sent by a GCS such as QGC or Mission Planner from a script running on a companion computer?

Currently I have a script that can read MAVLink messages emitted by the FC and send commands to it. However, any message sent by the GCS goes straight to the FC and I want to intercept it, decide if a certain action should happen, then pass it on to the FC.
For example, if a user decides to click “Go to location” on the GCS, the MAVLink message sent should be intercepted by the script, decide if there is any additional behaviour to do (for example’s sake, flash a light) then either send the message to the FC or discard it.

How can I accomplish this?

I am using Python with Dronekit and Pymavlink. Thanks in advance!

Anyone know if this is possible?