Skip to content

Commit

Permalink
Fixes by @peterohman
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Jun 15, 2023
1 parent c2c102b commit eb28b61
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions etc/dbus-serialbattery/bms/hlpdatabms4s.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,8 @@ def refresh_data(self):
pass
return result

# def log_settings(self):
# logger.info(f'Battery {self.type} connected to dbus from {self.port}')
# logger.info(f'=== Settings ===')
# cell_counter = len(self.cells)
# logger.info(f'> Connection voltage {self.voltage}V | current {self.current}A | SOC {self.soc}%')
# logger.info(f'> Cell count {self.cell_count} | cells populated {cell_counter}')
# logger.info(f'> CCCM SOC {CCCM_SOC_ENABLE} | DCCM SOC {DCCM_SOC_ENABLE}')
# logger.info(f'> CCCM CV {CCCM_CV_ENABLE} | DCCM CV {DCCM_CV_ENABLE}')
# logger.info(f'> CCCM T {CCCM_T_ENABLE} | DCCM T {DCCM_T_ENABLE}')
# logger.info(f'> MIN_CELL_VOLTAGE {MIN_CELL_VOLTAGE}V | MAX_CELL_VOLTAGE {MAX_CELL_VOLTAGE}V')

return

def read_test_data(self):
test_data = self.read_serial_data_HLPdataBMS4S(b"pv\n", 1, 15)
test_data = self.read_serial_data_HLPdataBMS4S(b"pv\n", 0.2, 12)
if test_data is False:
return False
s1 = str(test_data)
Expand Down Expand Up @@ -220,14 +207,18 @@ def read_serial_data(command, port, baud, time, min_len):

def read_serialport_data(ser, command, time, min_len):
try:
if min_len == 12:
ser.write(b"\n")
sleep(0.2)
cnt = 0
while cnt < 3:
cnt += 1
ser.flushOutput()
ser.flushInput()
ser.write(command)
sleep(time)
res = ser.read(1000)
toread = ser.inWaiting()
res = ser.read(toread)
if len(res) >= min_len:
return res
return False
Expand Down

0 comments on commit eb28b61

Please sign in to comment.