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

Added function "modbus_read_device_information_object" #443

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Schwaneberg
Copy link

This PR adds a new function to access the built in device information from Modbus devices.

Changes:

  • A new function code "MODBUS_FC_READ_DEVICE_INFORMATION" was added.
  • Device information object codes were added, e.g. MODBUS_OBJID_VENDORNAME.
  • Function "modbus_read_device_information_object(modbus_t ctx, unsigned char object_id, char dest);" was added.
  • Several internal functions were extended to handle the new function code.

Notes:
I successfully tested to code with a server that uses big endian word and byte order. Therefore, the mapping in modbus.c:1432 might be wrong for clients with little endian word order, depending on how strings are handled.

Signed-off-by: Oliver Schwaneberg oliver.schwaneberg@gmail.com

src/modbus.c Outdated
for (i = 0; i < rc; i++) {
dest[i] = rsp[offset + i];
}
dest[i] = '\0';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks dubious. While objects 1..6 are ascii per spec, the rest are all user defined. Should this function not just return the length as is done in many other libmodbus functions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably yes. I will change it.

@karlp
Copy link
Contributor

karlp commented Jul 31, 2018

You need to include documentation for your new functions too

@Schwaneberg
Copy link
Author

I will also add the documentations and update the PR.

Added function "modbus_read_device_information_object" to access device
specific information like "vendor name" or "product name".

Definitions for device information objects are added to modbus.h.

Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
@Schwaneberg
Copy link
Author

I have updated the PR. Please take a look.

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

Successfully merging this pull request may close these issues.

None yet

2 participants