Skip to content
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

- reworked handling of bluetooth responses to handle more than 2 13-b… #29

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

KevinEeckman
Copy link

…ytes frames

  • added support for more bluetooth commands
  • added unit tests

…ytes frames

- added support for more bluetooth commands
- added unit tests
@KevinEeckman
Copy link
Author

fixes #28

- reduced logging amount when getting invalid data frames
- improved error codes translation (Google Translate on daly spec)
- added scenario management on unit tests
@dreadnought
Copy link
Owner

Hi
thanks for investing the effort to create the PR. I like your changes and also that you've created some tests.

Regarding your open question about the max_responses, I have two reasons to believe that the old values are a good choice:

  1. There is this Part 4_ Daly RS485+UART Protocol.pdf that says:

Each unit voltage of 2 byte, according to the actual number of units sent, a maximum of 96 byte, divided into 16 frames sent

  1. When I look at the output of the line self.logger.debug("got %s" % result) in daly_bms_bluetooth.py, it gives me 16 bytearrays:

got [bytearray(b'\x01\x0f\xa2\x0f\xf7\x0f\xec\xed'), bytearray(b'\x02\x0f\xd7\x0f\xc2\x0f\xdb\xed'), bytearray(b'\x03\x0f\xd4\x0f\xe1\x10*\xed'), bytearray(b'\x04\x0f\xb1\x0f\x9a\x0f\xb3\xed'), bytearray(b'\x05\x0f\xcc\x0f\xb5\x00\x00\xed'), bytearray(b'\x06\x00\x00\x00\x00\x00\x00\xed'), bytearray(b'\x07\x00\x00\x00\x00\x00\x00\xed'), bytearray(b'\x08\x00\x00\x00\x00\x00\x00\xed'), bytearray(b'\t\x00\x00\x00\x00\x00\x00\xed'), bytearray(b'\n\x00\x00\x00\x00\x00\x00\xed'), bytearray(b'\x0b\x00\x00\x00\x00\x00\x00\xed'), bytearray(b'\x0c\x00\x00\x00\x00\x00\x00\xed'), bytearray(b'\r\x00\x00\x00\x00\x00\x00\xed'), bytearray(b'\x0e\x00\x00\x00\x00\x00\x00\xed'), bytearray(b'\x0f\x00\x00\x00\x00\x00\x00\xed'), bytearray(b'\x10\x00\x00\x00\x00\x00\x00\xed')]

When it doesn't cause any delays or other issues for you, I would prefer to keep the old values. Otherwise we have to make it a configurable option.

@KevinEeckman
Copy link
Author

KevinEeckman commented Aug 22, 2022

Hi
Interestingly enough, this is the output I get on my BMS :

[bytearray(b'\x01\x0c\xce\x0c\xd9\x0c\xd6@'), bytearray(b'\x02\x0c\xd9\x0c\xd4\x0c\xd9@'),
bytearray(b'\x03\x0c\xd4\x0c\xd7\x0c\xd6@'), bytearray(b'\x04\x0c\xd9\x0c\xd4\x0c\xd9@'),
bytearray(b'\x05\x0c\xd4\x0c\xd9\x0c\xd6@'), bytearray(b'\x06\x0c\xd7\x00\x00\x00\x00@'),
bytearray(b'\x07\x00\x00\x00\x00\x00\x00@'), bytearray(b'\x08\x00\x00\x00\x00\x00\x00@'),
bytearray(b'\t\x00\x00\x00\x00\x00\x00@'), bytearray(b'\n\x00\x00\x00\x00\x00\x00@'),
bytearray(b'\x0b\x00\x00\x00\x00\x00\x00@'), bytearray(b'\x0f\x00\x00\x00\x00\x00\x00@')]

ie I only have 12 frames. How many cells do you have on your battery ?

I will try to come up with a way to autodetect this value. @dreadnought could you send me a raw output sample from your BMS ? For example, this is the raw data that matches the output above :

b'\xa5\x01\x95\x08\x01\r7\r6\r4\x9b\xa7\xa5\x01\x95\x08\x02\r5\r5\r5\x9b\xa6'
b'\xa5\x01\x95\x08\x03\r4\r>\r6\x9b\xb0\xa5\x01\x95\x08\x04\r7\r6\r7\x9b\xad'
b'\xa5\x01\x95\x08\x05\r4\r5\r4\x9b\xa7\xa5\x01\x95\x08\x06\r7\x00\x00\x00\x00'
b'\x9b(\xa5\x01\x95\x08\x07\x00\x00\x00\x00\x00\x00\x9b\xe5\xa5\x01\x95\x08\x08'
b'\x00\x00\x00\x00\x00\x00\x9b\xe6\xa5\x01\x95\x08\t\x00\x00\x00\x00\x00\x00'
b'\x9b\xe7\xa5\x01\x95\x08\n\x00\x00\x00\x00\x00\x00\x9b\xe8\xa5\x01\x95\x08'
b'\x0b\x00\x00\x00\x00\x00\x00\x9b\xe9\xa5\xa8\x00@\x00p$@\x00\r0\x00\x00p$'
b'@\x008\xa7\x00\x00m2\x00\x00p$@\x00S1\x00\x00\x00\x00\x00\x00\xa8\x00\xa5\x01'
b'\x95\x08\x0f\x00\x00\x00\x00\x00\x00\x9b\xed\xa5\x01\x95\x08\x10')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants