Convert strings to unicode before passing to pymavlink - #1703
peterbarker wants to merge 2 commits into
Conversation
pymavlink's generated *_send methods require bytes for char[] fields since the typed Python3 generator was adopted (pymavlink 2.4.38), so e.g. message LOG_STREAM_NAMED_VALUE 1 1 "'XKF4'" "'SS'" died with "TypeError: must be str or None, not bytes". Look up the message class's fieldtypes and encode any str supplied for a char field; bytes arguments are passed through unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pymavlink's generated statustext_send requires bytes for the text field since the typed Python3 generator was adopted (pymavlink 2.4.38), so the example module's boredom statustext died with "TypeError: must be str or None, not bytes". This is the crash reported in pymavlink issue ArduPilot#1225. Co-Authored-By: j3kestrel <17890332+j3kestrel@users.noreply.github.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
37428a4 to
2e843dc
Compare
|
Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting. Reviewed at head Verified correct: the direction matches pymavlink's contract (it now annotates these parameters Four sibling call sites raise
Two notes. Encoded text is truncated at the field width by |
Avoid the need to specify the encoding of a string when using the
messagecommand by simply converting any passed-in-string to bytes before passing to pymavlinkThis fixes the same problem as in ArduPilot/pymavlink#1225
This is basically, "give pymavlink what it wants", which is unicode.