pymavlink icon indicating copy to clipboard operation
pymavlink copied to clipboard

set_string parameter type mismatch

Open laol-tomsk opened this issue 6 months ago • 3 comments

As far as I understand, Message::set_string is a tool to fill string fields in messages. I tried using it to fill vendor_name and model_name in CAMERA_INFORMATION, and it looks like it's supposed to be done like this:

mavlink::common::msg::CAMERA_INFORMATION resp_msg{};
mavlink::set_string(resp_msg.vendor_name, std::string("Vendor Name"));
mavlink::set_string(resp_msg.model_name, std::string("Model Name"));

However, it does not work, because vendor_name and model_name in CAMERA_INFORMATION are both of type std::array<unsigned char, 32>&, while set_string needs its first argument to be std::array<char, _N> &a (i.e. unsigned char vs. char).

Shouldn't set_string accept std::array<unsigned char, _N> as well?

laol-tomsk avatar Aug 29 '25 04:08 laol-tomsk

Hello, can I work on this?

TiwariAry avatar Oct 04 '25 14:10 TiwariAry

Hello, can I work on this?

Yes, of course!

I think the shape of this request means there should be no functional change apart from an additional way of populating string fields.

Please state how you tested any patch you supplied. Provision of an additional test in the automated suite would be the best option there.

peterbarker avatar Oct 04 '25 23:10 peterbarker

Hello, can I work on this?

Yes, of course!

I think the shape of this request means there should be no functional change apart from an additional way of populating string fields.

Please state how you tested any patch you supplied. Provision of an additional test in the automated suite would be the best option there.

Sorry for late reply and thanks for allowing me to work on this.

I will set up the project in my machine and see what is the problem, then I will let you know.

I think this is more of a nuisance because problem is the mismatch between the type the code generator chose for a string field (unsigned char) and the type the utility function expects (char) instead of a bug because it can easily be worked around. I'll see what I can do.

TiwariAry avatar Oct 05 '25 14:10 TiwariAry