Skip to content
New issue

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

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

Already on GitHub? # to your account

Proprietary Modbus function and use of rawRequest/rawResponce #279

Open
arinci opened this issue Mar 28, 2023 · 2 comments
Open

Proprietary Modbus function and use of rawRequest/rawResponce #279

arinci opened this issue Mar 28, 2023 · 2 comments

Comments

@arinci
Copy link

arinci commented Mar 28, 2023

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!

@arinci
Copy link
Author

arinci commented Apr 6, 2023

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!!!

@Beavisgood
Copy link

Beavisgood commented Mar 7, 2025

Hello, I use ModBus RTU master for receive data from device.

I had make request 0B 42 07 00 17 FF 00 00 57 8F, and device answer 0B 42 07 00 17 8B 00 00 20 00 BB 00 01 08 00 FF 00 FF....., but I can't receive this data

  MB_buf[0]=  F_42;       
  MB_buf[1]=  READ;       
  MB_buf[2]=  DI_B1;   
  MB_buf[3]=  DI_B2;   
  MB_buf[4]=  0xFF;
  MB_buf[5]=  0x00;
  MB_buf[6]=  0x00;
  mb.rawRequest(MB_ID_AF_1, MB_buf, 7, cbWrite);
  mb.rawResponce(MB_ID_AF_1, MB_buf, 0xFF);

Could you share example how I can send a message with proprietary Modbus function code, and recive data from User defined function 0x41 0x42 0x43.....
Thank you!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants