Skip to content

Unexpected behavior of the Modbus Flex-FC node with FC 20 (0x14) #524

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

Open
tnn85 opened this issue Apr 5, 2025 · 5 comments
Open

Unexpected behavior of the Modbus Flex-FC node with FC 20 (0x14) #524

tnn85 opened this issue Apr 5, 2025 · 5 comments
Assignees
Labels

Comments

@tnn85
Copy link

tnn85 commented Apr 5, 2025

Which node-red-contrib-modbus version are you using?

5.43.0

What happened?

I'm trying to use the Flex-FC node to read a Siemens Sentron PAC2200 energy meter using the FC 20 (0x14)

.

FC 20 is actually a standardized FC according to the Modbus protocol, but unfortunately not available as a node in node-red-contrib-modbus.

I tried implementing it as shown here with a JSON object injected into the Flex-FC node by an injection node.
https://youtu.be/3TYG2UTtt4Q?feature=shared&t=116

I get a response from the energy meter, but it's 2 bytes longer than expected and isn't divided into the fields specified by the "Response Map."

The response of the energy meter to a request with this Flex-FC node also looks correct in Wireshark and exactly like a response to a request from Siemens Sentron Powerconfig V3.29, a program from Siemens for configuring the energy meter.

Image

Image

customFc : msg.payload : Object
object
data: array[6]
0: 0x43
1: 0x6a
2: 0x7e
3: 0xe4
4: 0xd9
5: 0x8b
length: 6

Server

Other/External server

How can this be reproduced?

Import this flow and simulate a Modbus TCP server with implemented FC 0x14 "Read File Record".

flows.json

What did you expect to happen?

I expected this structure of the response:

   "responseCard": [
        {
            "name": "responseDataLength",
            "data": 0,
            "offset": 0,
            "type": "uint8be"
        },
        {
            "name": "subReqFileResponsLength",
            "data": 0,
            "offset": 1,
            "type": "uint8be"
        },
        {
            "name": "subReqReferenceType",
            "data": 0,
            "offset": 2,
            "type": "uint8be"
        },
        {
            "name": "subReqRecordData",
            "data": 0,
            "offset": 3,
            "type": "uint32be"
        }
    ],

Other Information

No response

@tnn85 tnn85 added the bug label Apr 5, 2025
@grewek
Copy link

grewek commented May 15, 2025

Hello @tnn85

Just to let you know i look into this, i already have an idea of what is happening but i want to confirm this first before i tell you more.

@grewek grewek self-assigned this May 15, 2025
@grewek
Copy link

grewek commented May 16, 2025

Hey @tnn85

Okay i can now safely confirm that the following is happening:

The request is send succesfully by the flex fc logic, but the response goes in the wrong direction and get's handled by someone else in the chain this is the reason why the response has no fields and the data isn't formatted as intended. The last two additional bytes there have to be the CRC of the Message. This should be fixable we just need to indicate that the flex fc should always be handled seperate from all the other handlers!

Also thank you for the thorough bug report :)

@grewek
Copy link

grewek commented May 20, 2025

Hi @tnn85

I prepared a bugfix for the issue. You can find it here: https://github.com/BiancoRoyal/node-red-contrib-modbus/tree/feature/flex-fc-bugfix

Can you check if the new version is helping in any way?

In case you don't know how:

  1. Clone our repository with a git tool and check out the branch flex-fc-bugfix
  2. In the folder where you cloned and checked out the branch execute the following command: npm run build
  3. In a Terminal go into your local Node-RED installation (linux: ~/.node-red, windows: C:\Users\my_name\.node_red)
  4. Execute the command: npm install path/to/the/cloned/repository
    If you can't don't worry i will soon push this to master but want to talk to Klaus first :)

@tnn85
Copy link
Author

tnn85 commented May 20, 2025

Hi @grewek,

thanks a lot for your investigation and your bugfix.
Please let me some time to try it out. I am a little busy at the moment.

If I have problems I will let you know :)

@grewek
Copy link

grewek commented May 21, 2025

No rush, please take your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants