python-3.xuartmicropythonnextion

Not usual bytes to string decoding. How to?


I'm working with some interesting devices and some of them uses micropython and on this part have problem with encodings.

I need to make two devices communicating by UART-protocol.

First device (may it be Nextion Display) sends to second device (STM-32 with micropython on board) string 'hellobruh' via UART,

second device gets bytesarray b'\x80\x9ef\x06\x9e\xe0\x9e\xfe\x9e\x18\x86\xf8f~\x80\x9e'

so the first thing I should try in my python script is to use .decode('utf-8') but no encodings works to decode it back to 'hellobruh'. I've tried windows-1251, cp-***, iso-****-*, ascii. Tried also with just usual python3 - no results, so I've put all these tags here - problem is not special for any devices. What am i doing wrong? This example is so simple as helloworld app on any platform/lang, so I think it is not incorrent settings setted by me or any hardware problem, I think it is just I don't understand in full way which encoding I get on second device or how to decode it. Thanks to all!


Solution

  • Be very careful when working with any devices. If you think it should be encoding problem, it could be wrong baudrate as example, which problem I got in this stuff. Even if it looks like you're doing all well and without errors. Question is solved.