Variant or associated item not found in `MavMessage`

After updating the mavlink from 0.9.0 to latest 0.11.2 , I am getting the follwoing error

MavMessage::common(ref cmsg) => match cmsg {
| ^^^^^^ variant or associated item not found in MavMessage

I know that API was changed in mavlink v0.11.0, but I am not sure how to write it , I was not able to find any examples online

my code looks something like

 Message::MavMessage(msg) => {
                            match msg {
                                MavMessage::common(ref cmsg) => match cmsg {

The enum variants are the same, they've just been flattened. So you should move everything in the match cmsg { ... } directly into the match msg { ... }, and remove the MavMessage::common(ref cmsg) => ... arm.

can you please tell me how can I resolve this error

let msg = MavMessage::common(MavCommon::SET_GPS_GLOBAL_ORIGIN(data)); // Updated this argument also 
     |                               ^^^^^^ variant or associated item not found in `MavMessage`

I tried looking into the documentation and they have SET_GPS_GLOBAL_ORIGIN_DATA but they are different .

Replace MavMessage::common(MavCommon::SET_GPS_GLOBAL_ORIGIN(data)) with MavMessage::SET_GPS_GLOBAL_ORIGIN(data), and change the type of data from common::SET_GPS_GLOBAL_ORIGIN_DATA to ardupilotmega::SET_GPS_GLOBAL_ORIGIN_DATA. The documentation for 0.11.0 includes an extra extension field that the documentation for 0.9.0 excluded, but you won't actually see that in your code unless you enable the emit-extensions feature.

1 Like

Thank You

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.