Open miikaforma opened 1 year ago
Thanks for spotting same problem in my logger. I'll make some additional log for bytes 26-27 to confirm corrupted function code. Hope this solution will have 100% of faulty readings cover because after my tests which was based on Faults there was some discrepencies where I had faulty readings without faults.
The LSW-3 (or wifi sticks in general) seem to not mutex the RS485 bus in this multi master setup, so Modbus frames from the logger itself querying the inverter resp sending frames to portal are mixed with your requests/responses.
It seems like the inverter sometimes sends invalid data (rarely but happens) which results in this script logging wrong values. Unfortunately we can't stop the inverter from doing that. However we can choose to ignore the invalid responses (at least I think so). This has happened to me 3 times but unfortunately I only have the raw response from one of the cases. However I believe it gives enough knowledge for implementing a fix.
The issue comes from that the script expects the response to have valid 0x03 function payload. For some reason, I've gotten at least one response where there's actually two 0x04 function payloads in front of the requested 0x03 function payload 🤔 I've removed some "personal" data from the images but here's an example of the valid response and one invalid response.
Valid modbus frame:
Invalid modbus frame:
Possible things to fix the script from logging invalid values:
As a side note, while investigating this issue, I found this (https://github.com/kubaceg/sofar_g3_lsw3_logger_reader/issues/12) from another logger reader. I believe it's caused by this same invalid data.