Louisvdw / dbus-serialbattery

Battery Monitor driver for serial battery in VenusOS GX systems
MIT License
521 stars 164 forks source link

VenusOS 2.80 compatibility #38

Closed Louisvdw closed 2 years ago

Louisvdw commented 3 years ago

Check compatibility with VenusOS 2.80

In Venus 2.80, the rootfs is now read-only. To install the service, you need to remount it rw (which you can do with the script /opt/victronenergy/swupdate-scripts/remount-rw.sh), and then the service needs to be installed in /opt/victronenergy/service instead (which is overlayed onto /service at bootup, but reset to original at each boot).

pau1phi11ips commented 3 years ago

Sorry, could you clarify this please? I've tried this to copy it to the service folder but no joy

cp /data/etc/dbus-serialbattery/service/ /opt/victronenergy/service/dbus-serialbattery/ -R

Louisvdw commented 3 years ago

Those are notes in the ticket of what I need to look at to get the driver compatible with 2.80. It is best to stay on the 2.7* venusOS until the driver is tested, before moving to 2.80

Louisvdw commented 3 years ago

Beta v0.8beta1 include Venus OS v2.80 changes. Some GObject warnings are still there for now.

@pau1phi11ips if you want to test on v2.8 just make sure you remove any files and the folder you might have created at /opt/victronenergy/service/dbus-serialbattery/ before you reboot the device.

So on a V2.72 / V2.73 device you will need to update the driver first, then update the firmware to 2.80 and the battery will still be there on V2.80

pau1phi11ips commented 3 years ago

Sorry, been crazy busy. I'll try and test later today.

I've got a kinda odd setup using the Victron ESS and it didn't actually work with 2.73 and 2.80 fixed the issue so would prefer to stick with that.

pahorpet commented 2 years ago

Hi any news about testing 2.8v?

Louisvdw commented 2 years ago

Hi any news about testing 2.8v?

Do you mean if anyone has given feenback on the beta version for the driver? Then yes I have at least 1 person that gave feedback that it is running successfully.

pahorpet commented 2 years ago

OK, are you planning to merge into the master any time soon? As I want to give it a try as well.

Louisvdw commented 2 years ago

Yes, If I can get one more feadback I will merge it into master.

pahorpet commented 2 years ago

when I run it directly it is working but as service I am getting those: root@einstein:/opt/victronenergy# sh serial-starter/serial-starter.sh find: /service/dbus-serialbattery/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service: Too many levels of symbolic links find: /service/dbus-serialbattery.ttyUSB0/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service/service: Too many levels of symbolic links serstart starting INFO: loading config file /etc/venus/serial-starter.conf INFO: loading config file /data/conf/serial-starter.d

Louisvdw commented 2 years ago

Can you tell me if you install the updated driver before you installed venus 2.8 or afterwards? If afterwards, did you do a reboot of the system?

pahorpet commented 2 years ago

before, and after just update rc.local, etc and conf folder.

Louisvdw commented 2 years ago

The reboot (or initial boot with firmware) will run the rc.local and it creates the required symbolic links. But the build itself also has permissions on the files that is needed. Can you install it using these 2 commands and see if that helps. You will need to reboot so it will run the rc.local file

wget https://github.com/Louisvdw/dbus-serialbattery/releases/download/v0.8beta1/venus-data.tar.gz
tar -zxf venus-data.tar.gz -C /data
pahorpet commented 2 years ago

Chmod fixed that sorry, I had missed that.

Louisvdw commented 2 years ago

Is it working now?

pahorpet commented 2 years ago

yes

Louisvdw commented 2 years ago

ok great. I will merge the 2.80 changes then

SanderV4n commented 2 years ago

@Louisvdw Today I tested the 0.8 version today, first upgraded dbus-serialbattery the upgraded my venus GX to version 2.80~17. After the reboot I got some BMS alarms, but the BMS info is gone on VRM and in the remote console. This can be some simple python bug causing the service to not start, or something more severe.

Since I seem to have lost my reverse tunnel in the upgrade I have no way to access my venus to debug this. With a bit of luck I'm back at my boat at the end of next week... so till then I'm locked out.

Louisvdw commented 2 years ago

Hi @SanderV4n The first thing to try is to reboot the GX when you have access to it. There is some extra symlinks that are needed for the new venusOS version to work and that sometimes does not get created the first boot. If that does not work, then post the log file here so we can see what the issue is. (see troubleshoot section of the wiki)

SanderV4n commented 2 years ago

I tried to reboot multiple times via the remote console, but did not help.

I wont be able to have a look at the logs till i'm back at my boat, that will be next Thursday or Friday I hope.

SanderV4n commented 2 years ago

@Louisvdw I tried again, downgrading to 2.73, then back to 2.80. In 2.73 it still works, in 2.80 it does not work.

I checked the serial starter log: root@beaglebone:~# tail -f /data/log/serial-starter/current @4000000061502767183cc7d4 ERROR: no service template for dbus-serialbattery

So there seems to be something wrong with the service.

root@beaglebone:~# ls -hal /opt/victronenergy/service-templates/ drwxr-xr-x 16 root root 1.0K Sep 24 12:26 . drwxr-xr-x 48 root root 3.0K Sep 24 12:26 .. drwxr-xr-x 3 root root 1.0K Sep 24 12:09 can-bus-bms drwxr-xr-x 3 root root 1.0K Sep 24 12:05 dbus-bornay-windplus drwxr-xr-x 3 root root 1.0K Sep 24 12:22 dbus-cgwacs drwxr-xr-x 3 root root 1.0K Sep 24 12:05 dbus-fzsonick-48tl drwxr-xr-x 3 root root 1.0K Sep 24 12:05 dbus-imt-si-rs485tc drwxr-xr-x 3 root root 1.0K Sep 24 12:05 dbus-modbus-client.serial drwxr-xr-x 3 root root 1.0K Sep 24 12:05 dbus-modem drwxr-xr-x 3 root root 1.0K Sep 24 12:09 dbus-motordrive drwxr-xr-x 3 root root 1.0K Sep 24 12:09 dbus-valence drwxr-xr-x 3 root root 1.0K Sep 24 12:09 gps-dbus drwxr-xr-x 4 root root 1.0K Sep 24 12:09 mk2-dbus drwxr-xr-x 3 root root 1.0K Sep 24 12:22 mqtt-n2k drwxr-xr-x 3 root root 1.0K Sep 24 12:09 vecan-dbus drwxr-xr-x 3 root root 1.0K Sep 24 12:09 vedirect-interface

It seems all the symlinks are not created at boot (also not after a reboot), which means the rc.local did not run.

There are also a few python 3 related problems in te sinowealth code which I will fix.

Louisvdw commented 2 years ago

@SanderV4n can you tell me which method did you use to upgrade the serial battery driver? Did you download the driver to a USB-Flash drive, or did you run the install script from the device through SSH?

SanderV4n commented 2 years ago

Hi @Louisvdw, I extracted the archive as described on the wiki under: "install Spesific version/testing option:"

Louisvdw commented 2 years ago

I assume then you use the beta still. It should be very close to the released version, but it is a bit behind. Just check the v0.8 release as well which is the very latest.

SanderV4n commented 2 years ago

I used the latest 0.8 release.

Louisvdw commented 2 years ago

@SanderV4n can you run the following command on your device.

sh /data/rc.local

You should be able to see a template after this and the battery should be able to start. Let me know if this helps so I can adjust the install procedure.

dakoal commented 2 years ago

Hi, also using venus OS 2,80 BETA on Cerbo with 0.9beta serialbattery now

ls -lh /data/logs gives

drwx------ 2 root root 4.0K Sep 30 14:37 dbus-serialbattery.TTY drwx------ 2 root root 4.0K Sep 29 05:14 dbus-serialbattery.ttyACM0 drwx------ 2 root root 4.0K Sep 26 15:47 dbus-serialbattery.ttyUSB0

so the 0.9 Beta is not finding the rigth tty I think.

Errors in current File: @400000006155cd2414f092a4 File "/opt/victronenergy/dbus-serialbattery/dbus-serialbattery.py", line 57, in get_battery_type @400000006155cd2415b2d51c if test.test_connection() is True: @400000006155cd2415b2f45c File "/data/etc/dbus-serialbattery/sinowealth.py", line 38, in test_connection @400000006155cd2415b303fc result = self.read_status_data() @400000006155cd2415b30bcc File "/data/etc/dbus-serialbattery/sinowealth.py", line 74, in read_status_data @400000006155cd2415b31b6c status_data = self.read_serial_data_sinowealth(self.command_status) @400000006155cd2415b57114 File "/data/etc/dbus-serialbattery/sinowealth.py", line 249, in read_serial_data_sinowealth @400000006155cd2415b5849c data = read_serial_data(self.generate_command(command), self.port, self.baud_rate, self.LENGTH_POS, self.LENGTH_CHECK, int(self @400000006155cd2415b59c0c File "/data/etc/dbus-serialbattery/sinowealth.py", line 245, in generate_command @400000006155cd2415b61cf4 buffer[1] = command @400000006155cd2415b716f4 TypeError: 'bytes' object cannot be interpreted as an integer

dakoal commented 2 years ago

if you want a ssh to the cerbo, tell me with pm

dakoal commented 2 years ago

on 2.73 also errors with 0,9 BETA. TTY is found correct (ACM0) but not working:

@400000006155cf01248382e4 No handlers could be found for logger "SerialBattery" @400000006155cf092b2301c4 Traceback (most recent call last): @400000006155cf092b2324ec File "/opt/victronenergy/dbus-serialbattery/dbus-serialbattery.py", line 108, in @400000006155cf092b23348c main() @400000006155cf092b233874 File "/opt/victronenergy/dbus-serialbattery/dbus-serialbattery.py", line 78, in main @400000006155cf092b234814 battery = get_battery_type(port) @400000006155cf092b234fe4 File "/opt/victronenergy/dbus-serialbattery/dbus-serialbattery.py", line 57, in get_battery_type @400000006155cf092b277a4c if test.test_connection() is True: @400000006155cf092b2789ec File "/data/etc/dbus-serialbattery/sinowealth.py", line 39, in test_connection @400000006155cf092b2795a4 result = result and self.read_remaining_capacity() @400000006155cf092b27a15c File "/data/etc/dbus-serialbattery/sinowealth.py", line 162, in read_remaining_capacity @400000006155cf092b27b0fc self.total_ah_drawn = self.capacity - self.capacity_remain @400000006155cf092b286894 TypeError: unsupported operand type(s) for -: 'NoneType' and 'float' @400000006155cf17156a529c No handlers could be found for logger "SerialBattery" @400000006155cf1c0fc91594 Traceback (most recent call last): @400000006155cf1c0fcb24ec File "/opt/victronenergy/dbus-serialbattery/dbus-serialbattery.py", line 108, in @400000006155cf1c0fcd8a34 main() @400000006155cf1c0fcf18a4 File "/opt/victronenergy/dbus-serialbattery/dbus-serialbattery.py", line 78, in main @400000006155cf1c0fd16a64 battery = get_battery_type(port) @400000006155cf1c0fd20a8c File "/opt/victronenergy/dbus-serialbattery/dbus-serialbattery.py", line 57, in get_battery_type @400000006155cf1c0fd33f24 if test.test_connection() is True: @400000006155cf1c0fd3c00c File "/data/etc/dbus-serialbattery/sinowealth.py", line 39, in test_connection @400000006155cf1c0fd4d94c result = result and self.read_remaining_capacity() @400000006155cf1c0fd55e1c File "/data/etc/dbus-serialbattery/sinowealth.py", line 162, in read_remaining_capacity @400000006155cf1c0fd7fdfc self.total_ah_drawn = self.capacity - self.capacity_remain @400000006155cf1c0fd951d4 TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'

Louisvdw commented 2 years ago

@dakoal if I remember we said you don't have the Sinowealth, but the normal Daly (from the cell logging ticket). So it just very strange that you end up with the Sinowealth which is the very last driver currently being tested.

Do you see any message in your log file like: Connection established to ...

dakoal commented 2 years ago

root@einstein:/tmp# grep "established" /data/log/serial-starter/current root@einstein:/tmp# grep "established" /data/log/dbus-serialbattery.ttyUSB0/current root@einstein:/tmp#

I have a ssh and HTTP port opened. How to send you a PM?

dakoal commented 2 years ago

In the windows tool from daly I can see also single cell voltages and change all parameters.

Louisvdw commented 2 years ago

I don't think github has PM functionality. Best would be https://energytalk.co.za/u/louisvdw/

But I think I can see what the issue is. Let me make some changes that you can test.

Louisvdw commented 2 years ago

Get the latest of these 2 files and replace the ones one your GX. https://github.com/Louisvdw/dbus-serialbattery/blob/bugfixes0.9/etc/dbus-serialbattery/sinowealth.py https://github.com/Louisvdw/dbus-serialbattery/blob/bugfixes0.9/etc/dbus-serialbattery/utils.py

Then check the dbus-serialbattery.ttyACM0 log and see if it connect now.

dakoal commented 2 years ago

@400000006155dee91532912c CCGX booted (0) @400000006155df0a0023f514 WARNING:SerialBattery:dbus-serialbattery v0.9beta1 @400000006155df0a00528ec4 WARNING:SerialBattery:Testing LltJbd @400000006155df0a11635504 ERROR:SerialBattery:>>> ERROR: No reply - returning @400000006155df0a11e0b2c4 WARNING:SerialBattery:Testing Ant @400000006155df0a22f95c8c ERROR:SerialBattery:>>> ERROR: No reply - returning @400000006155df0a23724994 ERROR:SerialBattery:>>> ERROR: Incorrect Data @400000006155df0a237d8c64 WARNING:SerialBattery:Testing Daly @400000006155df0a27ce6824 WARNING:SerialBattery:Connection established to Daly @400000006155df0a2d0375dc WARNING:SerialBattery:Battery connected to dbus from /dev/ttyUSB0 @400000006155df0d1242bc6c Traceback (most recent call last): @400000006155df0d12516654 File "/data/etc/dbus-serialbattery/dbushelper.py", line 140, in publish_battery @400000006155df0d1358d7bc self.publish_dbus() @400000006155df0d135ddce4 File "/data/etc/dbus-serialbattery/dbushelper.py", line 155, in publish_dbus @400000006155df0d146050f4 midpoint, deviation = self.battery.get_midvoltage() @400000006155df0d14659c6c File "/data/etc/dbus-serialbattery/battery.py", line 190, in get_midvoltage @400000006155df0d1484d49c half1voltage += self.cells[c].voltage @400000006155df0d1487f17c IndexError: list index out of range

SanderV4n commented 2 years ago

@dakoal @Louisvdw These are some Pyhon3 / Venus 2.80 issues, which I shortly observed and started to fix but lost connection to my boat, so unable to debug/test and fix. I will not be at the boat till end of next week, so wont be able to test the 0.9 version till then.

Louisvdw commented 2 years ago

That is the midvoltage graph calculations that is giving issues (something new)

Louisvdw commented 2 years ago

@dakoal Get this updated file as well and test again https://github.com/Louisvdw/dbus-serialbattery/blob/bugfixes0.9/etc/dbus-serialbattery/battery.py

dakoal commented 2 years ago

It's working now.

DALY BMS on TTL-USB Converter venus OS 2.80~21 on Cerbo serialbattery driver 0.9beta with the files changed from you

dakoal commented 2 years ago

Only until changing loglevel to info

@400000006155ebad268adfec INFO:SerialBattery:Starting dbus-serialbattery @400000006155ebad269be74c WARNING:SerialBattery:dbus-serialbattery v0.9beta1 @400000006155ebad26b631c4 WARNING:SerialBattery:Testing LltJbd @400000006155ebad37a2551c ERROR:SerialBattery:>>> ERROR: No reply - returning @400000006155ebad37db89a4 WARNING:SerialBattery:Testing Ant @400000006155ebae0d2e6d84 ERROR:SerialBattery:>>> ERROR: No reply - returning @400000006155ebae0d68367c ERROR:SerialBattery:>>> ERROR: Incorrect Data @400000006155ebae0d767304 WARNING:SerialBattery:Testing Daly @400000006155ebae14b88ae4 INFO:SerialBattery:DalyBMS 16 cells @400000006155ebae14cdd034 WARNING:SerialBattery:Connection established to Daly @400000006155ebae1c22d7bc WARNING:SerialBattery:Battery connected to dbus from /dev/ttyUSB0 @400000006155ebb10d84bf2c Traceback (most recent call last): @400000006155ebb10d84de6c File "/data/etc/dbus-serialbattery/dbushelper.py", line 140, in publish_battery @400000006155ebb10d84ee0c self.publish_dbus() @400000006155ebb10d84f1f4 File "/data/etc/dbus-serialbattery/dbushelper.py", line 201, in publish_dbus @400000006155ebb10d850194 self.battery.log_cell_data() @400000006155ebb10d850964 File "/data/etc/dbus-serialbattery/battery.py", line 242, in log_cell_data @400000006155ebb10d85151c cell_res += "[{0}]{1}V ".format(c+1, self.cells[c].voltage) @400000006155ebb10d86f594 IndexError: list index out of range

dakoal commented 2 years ago

setting back to warning everything is fine

Louisvdw commented 2 years ago

fixed in https://github.com/Louisvdw/dbus-serialbattery/releases/tag/v0.9beta2