libmodbus icon indicating copy to clipboard operation
libmodbus copied to clipboard

Topic/adding function read device identification

Open purewasa opened this issue 6 years ago • 1 comments

Bonjour et hello!

Over four years ago I send you a patch for libmodbus, that implements the Modbus protocol function READ DEVICE IDENTIFICATION. As an answer, you requested a more DRY Version (see libmodbus mailing list https://groups.google.com/forum/#!msg/libmodbus/eH1NcZ7YVdk/PXFJlvf26PwJ ). Unfortunately, at that time, it was not possible for me to rework the patch. Meanwhile, there is a greater need in my department to mainline the changes, we made to open source projects, that we use in our devices. Because of that, the focus has come back to libmodbus.

So, here is my more DRY and improved version of the patch from those days. It is based on the HEAD of the current master branch of libmodbus from your github account It consists of two commits:

  • one adding the function modbus_read_device_identification(), and
  • one providing a test tool.

The function has been used in our embedded devices with the non-DRY version for three years, now. There never seemed to be a problem, as far as I know. But it only has been used for serial Modbus RTU.

Even the new patch has only been tested with Modbus RTU, using Linux. It should be able to handle Modbus TCP correctly, as well, thanks to the improvements I made.

Modbus devices that implements the Modbus protocol specification correctly, but don't support the READ DEVICE IDENTIFICATION function send an "illegal function" exception. This case has been tested with one Modbus device.

purewasa avatar Mar 25 '19 14:03 purewasa

Dear karlp,

thank you for your reply.

As far as I can see all this MEI stuff is very much controller dependent and therefore not easy to abstract. The only thing that comes to my mind is: The library could abstract giving back the fields of the result as a linked list. Expressed in C++11 (just for clarification), the return type could be list<array>. But this is just a vague idea.

Unfortunately, I don't have the resources available at the moment to work on that.

Kind regards

purewasa

purewasa avatar Sep 19 '19 14:09 purewasa