-
-
Notifications
You must be signed in to change notification settings - Fork 72
Refactor condition to check for missing data #314
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
Conversation
Avoid not proper handled `TypeError: 'NoneType' object is not subscriptable` ``` @4000000068b973dd1eb993e4 ERROR:SerialBattery:Exception occurred: OSError(71, 'Protocol error') of type <class 'OSError'> in /data/apps/dbus-serialbattery/utils.py line #831 @4000000068b973dd21464d8c Traceback (most recent call last): @4000000068b973dd232fd5dc File "/data/apps/dbus-serialbattery/dbushelper.py", line 781, in publish_battery @4000000068b973dd232ff134 result = self.battery.refresh_data() @4000000068b973dd232ffcec ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @4000000068b973dd2332008c File "/data/apps/dbus-serialbattery/bms/jkbms_pb.py", line 173, in refresh_data @4000000068b973dd23321414 return self.read_status_data() @4000000068b973dd23321fcc ^^^^^^^^^^^^^^^^^^^^^^^ @4000000068b973dd2332279c File "/data/apps/dbus-serialbattery/bms/jkbms_pb.py", line 176, in read_status_data @4000000068b973dd23323b24 status_data = self.read_serial_data_jkbms_pb(self.command_status, 299) @4000000068b973dd23324ac4 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @4000000068b973dd2333aa54 File "/data/apps/dbus-serialbattery/bms/jkbms_pb.py", line 368, in read_serial_data_jkbms_pb @4000000068b973dd2333bddc if data[0] == 0x55 and data[1] == 0xAA: @4000000068b973dd2333c994 ~~~~^^^ @4000000068b973dd2335adf4 TypeError: 'NoneType' object is not subscriptable ```
|
Note that there are 2 more places with similar check that prob needs to be fixed. |
Fixed the same issue on the other 2 places
|
Thanks for helping to improve this driver! Do you want to further test this before I merge it? |
|
The log is much cleaner with these fixes. From the comments In the code it seems like the crc is bypasses. As i occasionally see odd values and saw also message about exceeding values i will take a look if I can get proper crc checking in place. |
|
Sounds great, thanks! |
|
e.g. here is my logging now when error occurs: So with this change it seems to properly catch the 'False' that comes from utils.py read_serial_data returning |
JKBMS PB: Refactor condition to check for missing data
JKBMS PB: Refactor condition to check for missing data
Avoid not proper handled
TypeError: 'NoneType' object is not subscriptable