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

[BUG] ModbusTCP 16bit register write - bad function code #1175

Open
AllmarkPL opened this issue May 2, 2024 · 8 comments
Open

[BUG] ModbusTCP 16bit register write - bad function code #1175

AllmarkPL opened this issue May 2, 2024 · 8 comments

Comments

@AllmarkPL
Copy link

Hello,
I'd run into an issue where I can't write values into single 16bit register of modbus device. I have created a single tag with INT16 datatype and proper device addressing, but when I tried to write data into it nothing happended. Quick look into modbus logs has shown that function 16 (multiple registers) is used instead of 06 (single registers) and communication is interrupted due to "bad lenght 8 (expected more than 8)". When I switched Fuxa tag datatype to INT32 all started working, but I can't leave it that way, because device I'm using have 6 consecutive 16bit registers which I got to use... Is there a way to properly send single 16bit register by modbus TCP in Fuxa? I don't think it's issue with the device itself, because I can write data into it using simulator or HMI.

To Reproduce

  1. Create a modbus TCP IP device with single INT16 tag
  2. Try to write any value either due to script action or by input.

Expected behavior
I think it may be a bug in modbus tcp plugin.

Environment

  • FUXA Version 1.1.19-1524
  • latest docker container
  • Platform/OS: Server: Ubuntu; Client: WIN11
  • Browser: Chrome 123.0.6312.86
@rvbatista
Copy link
Contributor

Hello, thanks for your issue.
Are you able to test both conditions with Wireshark capturing the packages?

@AllmarkPL
Copy link
Author

Hello,
as for now I can provide packet data for writing into modbus simulator software, I will have access to physical device on monday.
As You can see on packets below, the function code used for writing is in fact 16, and is lacking second byte in transmission which causes error. First screen is from writing by script, second is from writing by input box. Third is after changing datatype to INT32.
I think, that it was working properly in one of older versions, but I got to verify that.
Writing to INT16 by input box:
image
Writing to INT16 by script:
image
Device dataset:
image
Modbus dump:
image
Writing to INT32 by the same script:
image
Device datset:
image

@unocelli
Copy link
Member

unocelli commented May 7, 2024

Hi, have you try to update modbus-serial to 8.0.16?

@rvbatista
Copy link
Contributor

What are your modbus server? The reading is working? The usage of write multiple registers is in fact bad for efficiency, but it should work if your server have it implemented.

@AllmarkPL
Copy link
Author

Hello,
reading works without problem and writing 32 bit registers and booleans is working fine, also this error (FC16 used instead of FC06 when trying to write single INT16) appears on multiple devices and simulators I've tested. I will try to check modbus-serial version, because now I can confirm that this is case on version which is included in latest docker container (I don't have access to server now, but will check later and also test on modbus-serial 8.0.9 which I have on another server).

@rvbatista
Copy link
Contributor

The usage of FC16 instead of FC06 is in fact I'm the logic, today Fuxa will never use FC06. You know this is not exactly an error, since you can use FC16 to write only one register, but I trying to figure out why you are having an error in this case.

@unocelli
Copy link
Member

Hi, I added the possibility to set a frame delay that maybe can help (in master branch), would be nice to try and give me feedback

@AllmarkPL
Copy link
Author

Hello, thank You for reply. I tested it (tried several delay values from 10 ms to 2000 ms) just now, but it don't fix the issue - still the same error ("bad lenght 8, expected more than 8"). I had worked around it using OpenPLC on server and some DINT to INT processing, because I had to move forward with the project. I got to make it that way, because device which I'm working with had scrict registers addresing (separate memory part for 16 bit HR for setting and setpoints for which it will only accept FC06 modbus command separate and 32 bit memory registers for process settings).

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

No branches or pull requests

3 participants