-
-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data length mismatch jkbms_ble #593
Comments
Could you try to install the latest version? If you have the same problem, please try to swap these lines and check, if it works again: After data = bytearray(res)
while len(data) <= length + length_check:
res = ser.read(length + length_check)
data.extend(res) |
@transistorgit FYI. Could you troubleshoot this? With my JKBMS it's working over Bluetooth and Serial connection. |
Latest version has the same issue but changing those lines fixed the problem Edit: The title might be confusing, I have a JBD bms but the branch used is jkbms_ble |
I uncommented the debug log line Results with old working code
And with current code which does not work
|
Hi, I checked the JBD file and compared it with a protocol description I found here. @mr-manuel how to proceed? I think the bug is in the JBD code. But it may be that also some other types are affected. (also the values in daly.py were wrong). @iLeeeZi can you make a test with the new code and change line 60 in the driver to I would help, but problem is, I just can test with daly... brgds |
Please insert debuggig info, if it fails because of this problem, so that if the driver fails on another BMS the user has only to post the logs and we know how to fix it. Please open a PR in the jkbms_ble branch with the fix. |
Now I also have problems with my JKBMS. 2023-04-29 21:33:14.240937500 INFO:SerialBattery:Testing Jkbms
2023-04-29 21:33:30.235914500 ERROR:SerialBattery:>>> ERROR: No reply - returning [len:297/296]
2023-04-29 21:33:30.739856500 INFO:SerialBattery:Testing Jkbms
2023-04-29 21:33:46.737382500 ERROR:SerialBattery:>>> ERROR: No reply - returning [len:297/296]
2023-04-29 21:33:47.241881500 INFO:SerialBattery:Testing Jkbms
2023-04-29 21:34:03.235518500 ERROR:SerialBattery:>>> ERROR: No reply - returning [len:297/296] Since before all BMS were working. Is it not better to fix it in a way, that only the Daly BMS is affected? |
yes, that would be easier. The design of a generic serial read function in utils.py is complicated. The protocols are quite different. I would suggest that each driver has its own local serial read function. I can do this for daly, and other bms‘ can stay with the generic function as long as it works. While checking the JBD protocol I saw that it has a stop byte to make parsing safer, but it can‘t be handled by the generic function. Also, looking into the jkbms protocol spec, it says it has 4 checksum bytes. But In the driver is CHECK_LENGTH = 1. Also Jkbms counts all bytes of the frame except the 2 start bytes. Daly counts just the data frame bytes. So the read function in utils.py can‘t handle them all correctly. It is more coincidence that it works. Take the sample telegram in jkbms.py:18 - it is 21 bytes long, length code is 0x13 = 19d. Lets say the receive function has already received the full 21 bytes. In the while statement in utils.py:373 it waits for 19+1 bytes. As it has already received 21 bytes, it suceeds by coincidence. If you agree, I will move the serial read function into the daly.py and revert utils.py to the original state. |
Thats a good idea. When not defined in a specific battery driver, then the serial read function of the
Yes please. Update your PR (#484) and open another PR for the |
yes, integrating the serial reader into battery.py would also be nice, because that would be a cleaner architecture. right now it would be quite a big change. I just did it for daly now. If the serial stuff would go into the battery class, we also need to inject the serial port from outside. otherwise the class would depend on hardware what it make it impossible to unit test in future. |
I corrected the serial stuff in #484 but added some additional stuff in jkbms_ble. hope that is Ok, as I don't now your process how you handle changes. |
That's ok, thanks! |
@iLeeeZi could you try with the the latest nightly? |
No errors with the latest nightly, seems to be working now! |
Describe the bug
There seems to be issue with jkbms_ble branch after fix for #397
Reverted changes for utils.py and everything is working again
Battery/BMS:
Logs
The text was updated successfully, but these errors were encountered: