BotoX / xiaomi-m365-compatible-bms

Xiaomi M365 compatible, open source firmware for ATMega328p+BQ769x0 BMS. Ninebot in proto_test branch
197 stars 45 forks source link

Issues Python serial communication #26

Open TorstenE81 opened 4 years ago

TorstenE81 commented 4 years ago

Hi, I'm currently building this BMS. Everything seems to work fine except of Python config tool. I always get the BOOTED Message but when I send debug_print() I usually just get some hex code like 55aa0322fa0500dbfe. If I call debug_print many times I sometimes get the desired debug information. If I call getSettings it always ends in a Python exeption that no data was received. I tried Python Version 3.7 on Ubuntu and 3.5 on a Raspberry. On Python 2.7 the script doesn't start.

Does anyone have a hint? Thanks in advance

Torsten

BotoX commented 4 years ago

Seems like the serial UART connection is bad. It has no error correction or even detection. So communication errors will cause this behavior.

TorstenE81 commented 4 years ago

That's the message I get after calling getSettings()

getSettings() b'55aa0322f1007079fe' Traceback (most recent call last): File "", line 1, in File "./configtool.py", line 199, in getSettings d = m365_recv() File "./configtool.py", line 187, in m365_recv d = g_Queue.get(True, 1) File "/usr/lib/python3.7/queue.py", line 178, in get raise Empty _queue.Empty

Today I tried another UART USB converter. Unfortunately without success.

Do you have some further advices?

mottscanley commented 3 years ago

@TorstenE81 did you ever solve this issue? For the love of god, I only managed to once get debug_print() response but never for getSettings(). Tried over hundred times. Wires seem to be connected well, swapped RX/TX multiple times. Same thing when using different serial tools and sending same commands but in hex.

EDIT: increasing delay after ser.write(0xFF) seems to fix this issue (idea from http://scarabeus.wz.cz/m365.html)