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

Worked fine for months, stopped with QPIRI reply too short (97 bytes) #120

Open
lukolszewski opened this issue Sep 16, 2024 · 3 comments
Open

Comments

@lukolszewski
Copy link

lukolszewski commented Sep 16, 2024

My 5kW EASUN SMH-ii-7K worked fine for months with the fix in inverter.cpp shown below:

  •    if (buf[0]!='(' || buf[replysize-1]!=0x0d) {
    
  •    if (buf[0]!='(' || buf[replysize-1]!=0x0a) {
    

(essentially my inverrter is adding extra LF on the end).

Now it stopped working after nothing has changed with the inverter with:
Mon Sep 16 23:03:03 2024 INVERTER: Debug set
Mon Sep 16 23:03:03 2024 INVERTER: Current CRC: 49 C1
Mon Sep 16 23:03:03 2024 INVERTER: QMOD reply size (5 bytes)
Mon Sep 16 23:03:03 2024 INVERTER: QMOD: 5 bytes read: (B
Mon Sep 16 23:03:03 2024 INVERTER: QMOD query finished
Mon Sep 16 23:03:03 2024 INVERTER: Current CRC: B7 A9
Mon Sep 16 23:03:04 2024 INVERTER: QPIGS reply size (110 bytes)
Mon Sep 16 23:03:04 2024 INVERTER: QPIGS: 110 bytes read: (244.4 50.0 229.9 50.0 0436 0252 006 394 52.80 000 100 0031 0000 000.0 00.00 00005 00010000 00 00 00000 010
Mon Sep 16 23:03:04 2024 INVERTER: QPIGS query finished
Mon Sep 16 23:03:04 2024 INVERTER: Current CRC: F8 54
Mon Sep 16 23:03:07 2024 INVERTER: QPIRI read timeout
Mon Sep 16 23:03:07 2024 INVERTER: QPIRI reply too short (97 bytes)
Mon Sep 16 23:03:07 2024 INVERTER: Current CRC: B4 DA
Mon Sep 16 23:03:07 2024 INVERTER: QPIWS reply size (36 bytes)
Mon Sep 16 23:03:07 2024 INVERTER: QPIWS: 36 bytes read: (00000000001000000000000000000000
Mon Sep 16 23:03:07 2024 INVERTER: QPIWS query finished
Mon Sep 16 23:03:12 2024 INVERTER: Current CRC: F8 54
Mon Sep 16 23:03:15 2024 INVERTER: QPIRI read timeout
Mon Sep 16 23:03:15 2024 INVERTER: QPIRI reply too short (97 bytes)
Mon Sep 16 23:03:20 2024 INVERTER: Current CRC: F8 54
Mon Sep 16 23:03:23 2024 INVERTER: QPIRI read timeout
Mon Sep 16 23:03:23 2024 INVERTER: QPIRI reply too short (97 bytes)
Mon Sep 16 23:03:28 2024 INVERTER: Current CRC: F8 54
Mon Sep 16 23:03:31 2024 INVERTER: QPIRI read timeout
Mon Sep 16 23:03:31 2024 INVERTER: QPIRI reply too short (97 bytes)

It just goes in a loop afterwards. I tried increasing QPIRI buffer, but it made no difference.

I tried decreasing QPIRI buffer to 97 and this chnaged the message to CRC fail:

Mon Sep 16 23:10:07 2024 INVERTER: Debug set
Mon Sep 16 23:10:07 2024 INVERTER: Current CRC: 49 C1
Mon Sep 16 23:10:07 2024 INVERTER: QMOD reply size (5 bytes)
Mon Sep 16 23:10:07 2024 INVERTER: QMOD: 5 bytes read: (B
Mon Sep 16 23:10:07 2024 INVERTER: QMOD query finished
Mon Sep 16 23:10:07 2024 INVERTER: Current CRC: B7 A9
Mon Sep 16 23:10:07 2024 INVERTER: QPIGS reply size (110 bytes)
Mon Sep 16 23:10:07 2024 INVERTER: QPIGS: 110 bytes read: (244.5 50.0 230.2 50.0 0459 0297 006 394 52.90 000 100 0027 0000 000.0 00.00 00006 00010000 00 00 00000 010
Mon Sep 16 23:10:07 2024 INVERTER: QPIGS query finished
Mon Sep 16 23:10:07 2024 INVERTER: Current CRC: F8 54
Mon Sep 16 23:10:08 2024 INVERTER: QPIRI reply size (97 bytes)
Mon Sep 16 23:10:08 2024 INVERTER: QPIRI: CRC Failed! Reply size: 97 Buffer: (230.0 30.4 230.0 50.0 30.4 7000 6200 48.0 44.0 42.0 56.4 53.5 2 30 110 0 2 3 2 01 0 0 53.0 0 1n
00000 010
Mon Sep 16 23:10:08 2024 INVERTER: Current CRC: B4 DA
Mon Sep 16 23:10:08 2024 INVERTER: QPIWS reply size (36 bytes)
Mon Sep 16 23:10:08 2024 INVERTER: QPIWS: 36 bytes read: (00000000000000000000000000000000
Mon Sep 16 23:10:08 2024 INVERTER: QPIWS query finished
Mon Sep 16 23:10:13 2024 INVERTER: Current CRC: F8 54
Mon Sep 16 23:10:14 2024 INVERTER: QPIRI reply size (97 bytes)
Mon Sep 16 23:10:14 2024 INVERTER: QPIRI: CRC Failed! Reply size: 97 Buffer: (230.0 30.4 230.0 50.0 30.4 7000 6200 48.0 44.0 42.0 56.4 53.5 2 30 110 0 2 3 2 01 0 0 53.0 0 1n
00000 010
Mon Sep 16 23:10:19 2024 INVERTER: Current CRC: F8 54
Mon Sep 16 23:10:19 2024 INVERTER: QPIRI reply size (97 bytes)
Mon Sep 16 23:10:19 2024 INVERTER: QPIRI: CRC Failed! Reply size: 97 Buffer: (230.0 30.4 230.0 50.0 30.4 7000 6200 48.0 44.0 42.0 56.4 53.5 2 30 110 0 2 3 2 01 0 0 53.0 0 1n
00000 010
Mon Sep 16 23:10:24 2024 INVERTER: Current CRC: F8 54
Mon Sep 16 23:10:25 2024 INVERTER: QPIRI reply size (97 bytes)
Mon Sep 16 23:10:25 2024 INVERTER: QPIRI: CRC Failed! Reply size: 97 Buffer: (230.0 30.4 230.0 50.0 30.4 7000 6200 48.0 44.0 42.0 56.4 53.5 2 30 110 0 2 3 2 01 0 0 53.0 0 1n
00000 010

The config that worked fine for months is:

qpiri=98

This allows you to modify the buffersize for the qpiws command

qpiws=36

This allows you to modify the buffersize for the qmod command

qmod=5

This allows you to modify the buffersize for the qpigs command

qpigs=110

No idea what is going on. Any tips?

@lukolszewski
Copy link
Author

lukolszewski commented Sep 16, 2024

I've commented out line that returns after failed CRC check. As far as I can tell it runs fine. If anyone has any idea how the response suddenly went from 98 bytes to 97 and CRC started failing I'd love to figure out what to do to be able to verify that CRC again.

After commenting out I now have this output:
./inverter_poller -d -1
Mon Sep 16 23:32:04 2024 INVERTER: Debug set
Mon Sep 16 23:32:04 2024 INVERTER: Current CRC: 49 C1
Mon Sep 16 23:32:04 2024 INVERTER: QMOD reply size (5 bytes)
Mon Sep 16 23:32:04 2024 INVERTER: QMOD: 5 bytes read: (B
Mon Sep 16 23:32:04 2024 INVERTER: QMOD query finished
Mon Sep 16 23:32:04 2024 INVERTER: Current CRC: B7 A9
Mon Sep 16 23:32:04 2024 INVERTER: QPIGS reply size (110 bytes)
Mon Sep 16 23:32:04 2024 INVERTER: QPIGS: 110 bytes read: (245.5 49.9 230.1 49.9 0437 0249 006 394 52.90 000 100 0030 0000 000.0 00.00 00005 00010000 00 00 00000 010
Mon Sep 16 23:32:04 2024 INVERTER: QPIGS query finished
Mon Sep 16 23:32:04 2024 INVERTER: Current CRC: F8 54
Mon Sep 16 23:32:05 2024 INVERTER: QPIRI reply size (97 bytes)
Mon Sep 16 23:32:05 2024 INVERTER: QPIRI: CRC Failed! Reply size: 97 Buffer: (230.0 30.4 230.0 50.0 30.4 7000 6200 48.0 44.0 42.0 56.4 53.5 2 30 110 0 2 3 2 01 0 0 53.0 0 1n
00000 010
Mon Sep 16 23:32:05 2024 INVERTER: QPIRI: 97 bytes read: (230.0 30.4 230.0 50.0 30.4 7000 6200 48.0 44.0 42.0 56.4 53.5 2 30 110 0 2 3 2 01 0 0 53.0 0
Mon Sep 16 23:32:05 2024 INVERTER: QPIRI query finished
Mon Sep 16 23:32:05 2024 INVERTER: Current CRC: B4 DA
Mon Sep 16 23:32:05 2024 INVERTER: QPIWS reply size (36 bytes)
Mon Sep 16 23:32:05 2024 INVERTER: QPIWS: 36 bytes read: (00000000001000000000000000000000
Mon Sep 16 23:32:05 2024 INVERTER: QPIWS query finished
INVERTER: ampfactor from config is 1.00
INVERTER: wattfactor from config is 1.01
{
"Inverter_mode":4,
"AC_grid_voltage":245.5,
"AC_grid_frequency":49.9,
"AC_out_voltage":230.1,
"AC_out_frequency":49.9,
"PV_in_voltage":0.0,
"PV_in_current":0.0,
"PV_in_watts":0.0,
"PV_in_watthour":0.0000,
"SCC_voltage":0.0000,
"Load_pct":6,
"Load_watt":249,
"Load_watthour":2.7667,
"Load_va":437,
"Bus_voltage":394,
"Heatsink_temperature":30,
"Battery_capacity":100,
"Battery_voltage":52.90,
"Battery_charge_current":0,
"Battery_discharge_current":5,
"Load_status_on":1,
"SCC_charge_on":0,
"AC_charge_on":0,
"Battery_recharge_voltage":44.0,
"Battery_under_voltage":42.0,
"Battery_bulk_voltage":56.4,
"Battery_float_voltage":53.5,
"Max_grid_charge_current":30,
"Max_charge_current":110,
"Out_source_priority":2,
"Charger_source_priority":3,
"Battery_redischarge_voltage":-57832225845275467612324936810496.0,
"Warnings":"00000000001000000000000000000000"
}
Mon Sep 16 23:32:06 2024 INVERTER: All queries complete, exiting loop.

As far as i can tell everything looks fine. I can't tell any difference in values.

@lukolszewski
Copy link
Author

I added some debug output that prints what CRC we are expecting and what we're getting as well as the buffer itself in hex. This is the result:
Mon Sep 16 23:48:59 2024 INVERTER: QPIRI: CRC Failed! Reply size: 97 Buffer: (230.0 30.4 230.0 50.0 30.4 7000 6200 48.0 44.0 42.0 56.4 53.5 2 30 110 0 2 3 2 01 0 0 53.0 0 1n
00000 010
Mon Sep 16 23:48:59 2024 CRC Expected 95 E3, but we got 31 6E

28 32 33 30 2E 30 20 33 30 2E 34 20 32 33 30 2E 30 20 35 30 2E 30 20 33 30 2E 34 20 37 30 30 30 20 36 32 30 30 20 34 38 2E 30 20 34 34 2E 30 20 34 32 2E 30 20 35 36 2E 34 20 35 33 2E
35 20 32 20 33 30 20 31 31 30 20 30 20 32 20 33 20 32 20 30 31 20 30 20 30 20 35 33 2E 30 20 30 20 31 6E 0A
Mon Sep 16 23:48:59 2024 INVERTER: QPIRI: 97 bytes read: (230.0 30.4 230.0 50.0 30.4 7000 6200 48.0 44.0 42.0 56.4 53.5 2 30 110 0 2 3 2 01 0 0 53.0 0

Indeed we are getting 31 6E. No idea why it worked before and now it fails to calculate proper CRC.

@lukolszewski
Copy link
Author

lukolszewski commented Sep 17, 2024

Anyway the workaround that is working for me is here: https://github.com/lukolszewski/docker-voltronic-homeassistant if anyone else needs it.

The CRC check is disabled for QPIRI so you may get garbage data if you have connectivity issues. For me it works fine for the time being. I have no idea why my inverter sends a wrong CRC for this particular response.

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

1 participant