Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inverter sometimes sending invalid data #55

Open
miikaforma opened this issue Sep 22, 2023 · 2 comments
Open

Inverter sometimes sending invalid data #55

miikaforma opened this issue Sep 22, 2023 · 2 comments

Comments

@miikaforma
Copy link

miikaforma commented Sep 22, 2023

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:
image

Invalid modbus frame:
image

Possible things to fix the script from logging invalid values:

  1. Start reading the data and if the modbus frame doesn't start with the 0x03 function code, stop the script (or re-request the data and try again but remember to not create infinite loop in case the inverter keeps providing faulty data).
  2. Start reading the modbus frame and ignore the invalid 0x04 function payloads until the correct 0x03 function is reached (can easily skip since there's the length right after the function code, then just also skip the two bytes at the end (registerEnd and Crc16)). The 0x03 function payload in my invalid response actually did have the correct updated data. Just it's not where the script expects it to be.
  3. The comment here on the Serial in the header is interesting but I'm not sure if it would work for this.

As a side note, while investigating this issue, I found this (kubaceg/sofar_g3_lsw3_logger_reader#12) from another logger reader. I believe it's caused by this same invalid data.

@kubaceg
Copy link

kubaceg commented Oct 27, 2023

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.

@netadair
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants