Skip to content

Commit

Permalink
Merge pull request #713 from mr-manuel/dev
Browse files Browse the repository at this point in the history
Changes 2023.06.15
  • Loading branch information
mr-manuel authored Jun 15, 2023
2 parents 6441e56 + bd4fd22 commit 84491bb
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Changed: Improved driver reinstall when multiple Bluetooth BMS are enabled by @mr-manuel
* Changed: Improved Jkbms_Ble driver by @seidler2547 & @mr-manuel
* Changed: Reduce the big inrush current if the CVL jumps from Bulk/Absorbtion to Float https://github.com/Louisvdw/dbus-serialbattery/issues/659 by @Rikkert-RS
* Removed: Cronjob to restart Bluetooth service every 12 hours by @mr-manuel


## v1.0.20230531
Expand Down
2 changes: 1 addition & 1 deletion etc/dbus-serialbattery/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def unique_identifier(self) -> str:
On +/- 5 Ah you can identify 11 batteries
"""
string = (
"".join(filter(str.isalnum, self.hardware_version)) + "_"
"".join(filter(str.isalnum, str(self.hardware_version))) + "_"
if self.hardware_version is not None and self.hardware_version != ""
else ""
)
Expand Down
8 changes: 8 additions & 0 deletions etc/dbus-serialbattery/bms/daly.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,10 @@ def write_soc_and_datetime(self, ser):
if self.soc_to_set is None:
return False

# wait shortly, else the Daly is not ready and throws a lot of no reply errors
# if you see a lot of errors, try to increase in steps of 0.005
sleep(0.020)

cmd = bytearray(13)
now = datetime.now()

Expand Down Expand Up @@ -616,6 +620,10 @@ def write_charge_discharge_mos(self, ser):
):
return False

# wait shortly, else the Daly is not ready and throws a lot of no reply errors
# if you see a lot of errors, try to increase in steps of 0.005
sleep(0.020)

cmd = bytearray(self.command_base)

if self.trigger_force_disable_charge is not None:
Expand Down
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
16 changes: 14 additions & 2 deletions etc/dbus-serialbattery/bms/renogy.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ def test_connection(self):
try:
result = self.read_gen_data()
# get first data to show in startup log
if result:
self.refresh_data()
result = result and self.refresh_data()
except Exception as err:
logger.error(f"Unexpected {err=}, {type(err)=}")
result = False
Expand Down Expand Up @@ -145,6 +144,8 @@ def read_cell_data(self):
self.cells[c].voltage = 0
return True

"""
# Did not found who changed this. "command_env_temp_count" is missing
def read_temp_data(self):
# Check to see how many Enviromental Temp Sensors this battery has, it may have none.
num_env_temps = self.read_serial_data_renogy(self.command_env_temp_count)
Expand Down Expand Up @@ -172,6 +173,17 @@ def read_temp_data(self):
logger.info("temp2 = %s °C", temp2)
return True
"""

def read_temp_data(self):
temp1 = self.read_serial_data_renogy(self.command_bms_temp1)
temp2 = self.read_serial_data_renogy(self.command_bms_temp2)
if temp1 is False:
return False
self.temp1 = unpack(">H", temp1)[0] / 10
self.temp2 = unpack(">H", temp2)[0] / 10

return True

def read_bms_config(self):
return True
Expand Down
10 changes: 8 additions & 2 deletions etc/dbus-serialbattery/reinstall-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ if [ -d "/service/dbus-blebattery.0" ]; then
pkill -f "supervise dbus-blebattery.*"
pkill -f "multilog .* /var/log/dbus-blebattery.*"
pkill -f "python .*/dbus-serialbattery.py .*_Ble"

# kill opened bluetoothctl processes
pkill -f "^bluetoothctl "
fi


Expand Down Expand Up @@ -241,8 +244,11 @@ if [ "$length" -gt 0 ]; then
echo

# setup cronjob to restart Bluetooth
# remove if not needed anymore, has to be checked first
grep -qxF "5 0,12 * * * /etc/init.d/bluetooth restart" /var/spool/cron/root || echo "5 0,12 * * * /etc/init.d/bluetooth restart" >> /var/spool/cron/root
# remove if not needed anymore, has to be checked first --> seems that it's not needed anymore
# grep -qxF "5 0,12 * * * /etc/init.d/bluetooth restart" /var/spool/cron/root || echo "5 0,12 * * * /etc/init.d/bluetooth restart" >> /var/spool/cron/root

# remove cronjob
sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root

else

Expand Down
2 changes: 1 addition & 1 deletion etc/dbus-serialbattery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _get_list_from_config(


# Constants - Need to dynamically get them in future
DRIVER_VERSION = "1.0.20230612dev"
DRIVER_VERSION = "1.0.20230613dev"
zero_char = chr(48)
degree_sign = "\N{DEGREE SIGN}"

Expand Down

0 comments on commit 84491bb

Please sign in to comment.