Skip to content

Commit

Permalink
Fix Lynx Ion BMS doesn't work as battery monitor
Browse files Browse the repository at this point in the history
The script uses the device instance as a reference to
select the correct service from DBus. The problem
was that by default CAN products device instance is 0
which is not unique. Fixed by adding service type filter.
  • Loading branch information
jepefe committed Sep 3, 2018
1 parent 5e23821 commit ddb0168
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions startstop.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,15 @@ def _determineservices(self):

if batterymeasurement:
battery_instance = int(batterymeasurement.split('_', 3)[3].split('/')[0])
newbatteryservice = self._get_servicename_by_instance(battery_instance)
service_type = None

if 'vebus' in batterymeasurement:
service_type = 'vebus'
elif 'battery' in batterymeasurement:
service_type = 'battery'

newbatteryservice = self._get_servicename_by_instance(battery_instance, service_type)


if newbatteryservice and newbatteryservice != oldservice:
if selectedbattery == 'nobattery':
Expand Down Expand Up @@ -834,12 +842,18 @@ def _determineservices(self):
self.log_info('Error getting Vebus service!')
self._vebusservice = None

def _get_servicename_by_instance(self, instance):
services = self._dbusmonitor.get_service_list()
def _get_servicename_by_instance(self, instance, service_type=None):
sv = None
for i in services:
if services[i] == instance:
sv = i
services = self._dbusmonitor.get_service_list()

for service in services:
if service_type and service_type not in service:
continue

if services[service] == instance:
sv = service
break

return sv

def _get_monotonic_seconds(self):
Expand Down

0 comments on commit ddb0168

Please sign in to comment.