python icon indicating copy to clipboard operation
python copied to clipboard

[BUG] Config export encoding mismatch blocking import

Open todd2982 opened this issue 11 months ago • 5 comments

When running --export-config the file generated is using UTF-16 LE encoding, but the --configure option used to import that same file only accepts UTF-8 encoded files.

My environment is python 3.13 running on Windows 11 (not within WSL) using Meshtastic module version 2.5.9.

My current workaround is to use VS Code to save the exported file using the correct UTF8 encoding.

Error during import:

INFO file:ble_interface.py scan line:116 Scanning for BLE devices (takes 10 seconds)...
Connected to radio
Aborting due to: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

I'm unable to attach an export of the yml file due to github file restrictions. I can send the file directly if requested. I am also adding a link to a Stack Overflow thread that mentions the same issue with Python, but I'm not familiar enough with this module to make the changes myself.

https://stackoverflow.com/questions/3597480/how-to-make-python-3-print-utf8

todd2982 avatar Jan 05 '25 06:01 todd2982

Problem still exists in Meshtastic module version 2.5.10

todd2982 avatar Jan 15 '25 05:01 todd2982

I don't get an error as you described, rather the import appears to succeed printing all the values in the terminal. Could your default encoding be set to UTF-16?

When I run

python3 -c "import locale; print(locale.getpreferredencoding())"

I get

UTF-8

And running:

file -mime example_config.yaml

gets:

example_config.yaml: ASCII text

I'm on a mac with python3.13.2, meshtastic-python2.5.11

pdxlocations avatar Feb 17 '25 07:02 pdxlocations

You may have found my particular issue. I do think a check in the Python CLI should be made when running the config export to check for this possibility, or hard-code the encoding in the export. With the upcoming 2.6 release that will wipe all devices this is going to become a critical issue for those that may be in the same boat as me.

py -V Python 3.13.0

py -c "import locale; print(locale.getpreferredencoding())" cp1252

todd2982 avatar Feb 17 '25 14:02 todd2982

I wanted to follow up on this, I have encountered the exact same problem upgrading to 2.6. Python says my preferred encoding is cp1252 (Still on win 10), I was able to work around it by changing the encoding to UTF-8 in notepad++.

withoutgettingwet avatar Apr 30 '25 06:04 withoutgettingwet

I just did a fresh install of the Meshtastic CLI on a fresh windows 11 machine, and this error still persists!

digi-d2 avatar Jun 06 '25 17:06 digi-d2