emelianov / modbus-esp8266

Most complete Modbus library for Arduino. A library that allows your Arduino board to communicate via Modbus protocol, acting as a master, slave or both. Supports network transport (Modbus TCP) and Serial line/RS-485 (Modbus RTU). Supports Modbus TCP Security for ESP8266/ESP32.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proprietary Modbus function and use of rawRequest/rawResponce

arinci opened this issue · comments

commented

Hi, I'm using with great satisfaction this little gem of library.
I have a request regarding an issue I was not able to solve by myself. I need to send a message with proprietary Modbus function code 0x41, as this special function code is used in Huawei inverters for many things (file upload/download, authentication, etc).
This function code is used in other open source libraries to perform user authentication through Modbus protocol. An example of this is contained in huawei_solar.py python files (source code available here: https://pypi.org/project/huawei-solar/#files).

I thought it was quite easy to fill a buffer with the proprietary sequence of bytes, call the rawRequest to send buffer to the device (leaving the job to create the MBAP header that prepends the buffer to the rawRequest function) and wait for a response from device with rawResponce (or even better use a callback). But I was not able to get a reply from Huawei inverter.

Emilianov (and others guru), any suggestion? Do you think is it possible to use this library for this kind of job?
Thanks!

commented

I add here a little example of what I'm searching to do with modbus-esp8266 library.
Using ModbusPoll (https://www.modbustools.com/modbus_poll.html) I was able to send a custom proprietary request to the modbus device (using 'Test-Center' functionality), and get a response back.

This is a little extract of data communication:

Tx:AA AA 00 00 00 06 00 41 24 02 01 00
Rx:AA AA 00 00 00 15 00 41 24 11 70 8D 80 C0 F0 F7 10 0E 6F 44 B1 77 E1 64 AF CB 01

In TX we have MBAP header (first 7 bytes), the remaining bytes are for a request using function code 0x41, subcommands 0x24, length is 0x2 bytes, payload is 0x01 and 0x00.
With this request the modbus device reply with the message in second row.

Is possible to do this kind of proprietary modbus request (and process the reply from the slave device) using modbus-esp8266 library? If yes, is it possible to have a little help or an example?

Thanks!!!