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

The protocol is actually Modbus RTU tunneled over TCP #287

Open
sarnau opened this issue Apr 3, 2024 · 3 comments
Open

The protocol is actually Modbus RTU tunneled over TCP #287

sarnau opened this issue Apr 3, 2024 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@sarnau
Copy link

sarnau commented Apr 3, 2024

The protocol is simply Modbus RTU (the serial protocol) or also just called "TELNET" tunneled over TCP at port 8080.

To read data "holding register" are read (that is the $03 byte after the Unit-ID $01, which is the first byte). That's also the reason for the Modbus CRC at the end of the package. I would almost bet money on that the RS-422 Modbus port is using identical registers to communicate with the inverter. The registers value are 16-bit in MSB (high byte first), that is important e.g. for the serial number, which is stored in the registers 0 to 8 and therefore 18 ASCII characters long.

This also should make documenting it easier, because just the registers need to be documented – and not bytes in a buffer.

Here a minimal Python example to read the first 102 registers:

#!/usr/bin/env python3

from pymodbus.client.tcp import ModbusTcpClient as ModbusClient
from pymodbus.transaction import ModbusRtuFramer as ModbusFramer

client = ModbusClient(host='192.168.16.254', port=8080, framer=ModbusFramer)
client.connect()

print(client.read_holding_registers(0,102, slave=1).registers)

client.close()
@sarnau
Copy link
Author

sarnau commented Apr 25, 2024

I've documented my findings at https://github.com/sarnau/BYD-Battery-Box-Infos. I hope you'll find it helpful.

@christianh17 christianh17 added the documentation Improvements or additions to documentation label Dec 21, 2024
@christianh17
Copy link
Owner

Thanks a lot, I will leave this issue open, so I can find this information easily in the future.

@sarnau
Copy link
Author

sarnau commented Dec 21, 2024

Glad it helps.

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

No branches or pull requests

2 participants